Skip to content

Commit 74ac198

Browse files
committed
Lint fixes
1 parent a506428 commit 74ac198

1 file changed

Lines changed: 56 additions & 32 deletions

File tree

skill/autoloaded/lint.scm

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@
4444
))
4545
))
4646

47+
(@no_lint
48+
(_\@lint_add_control_rule ( _\@lint_add_rule _\@lint_add_control_rule SK_RULE ) t
49+
(SK_PUSH_VAR 'formlist)
50+
(let ( ( args (SK_ARGS) )
51+
)
52+
(when (eq 'SK_CONTROL (car args)) (pop args))
53+
(foreach map sexp (cdr args) (SK_CHECK_FORM sexp))
54+
)
55+
(SK_POP_VAR 'formlist)))
56+
57+
(@no_lint
58+
(_\@lint_add_control_rule ( SK_HINT SK_WARNING SK_ERROR ) t
59+
;; TODO - This rule should work like `lsprintf' one
60+
nil))
61+
4762

4863
;; ===============================================================================================================
4964
;; Rules
@@ -64,8 +79,10 @@
6479
;; -------------------------------------------------------
6580

6681
;; This is required at least when running Lint from the SKILL Interpreter
67-
(_\@lint_add_rule ( status sstatus ) (not (errset (funcall 'status (car (SK_ARGS)))))
68-
(SK_ERROR UNKNOWN_STATUS_FLAG "Unknown (s)status flag: %N\n" (SK_FORM)))
82+
(@no_lint
83+
(_\@lint_add_rule ( status sstatus ) (not (errset (funcall 'status (car (SK_ARGS)))))
84+
(SK_ERROR UNKNOWN_STATUS_FLAG "Unknown (s)status flag: %N\n" (SK_FORM))
85+
))
6986

7087

7188
;; -------------------------------------------------------
@@ -283,15 +300,13 @@
283300
(unless (and (listp defs) (forall def defs (and (listp def) (cdr def) (not (cddr def)))))
284301
(SK_ERROR SP_WITH_DEFS "`@letf' first argument should be a list of expression-value pairs: %N" defs)
285302
)
286-
(let ( ( vars (mapcar 'car defs) )
287-
)
288-
;; Check definitions, then check body
289-
(foreach map def defs
290-
(SK_CHECK_FORM (list (caar def)))
291-
(SK_CHECK_FORM (cdar def))
292-
)
293-
(foreach map sexp body (SK_CHECK_FORM sexp ))
294-
)))
303+
;; Check definitions, then check body
304+
(foreach map def defs
305+
(SK_CHECK_FORM (list (caar def)))
306+
(SK_CHECK_FORM (cdar def))
307+
)
308+
(foreach map sexp body (SK_CHECK_FORM sexp ))
309+
))
295310

296311
(_\@lint_add_control_rule ( @with ) t
297312
;; Expand macro to raise WARN MACROEXP1 in case of errors
@@ -322,17 +337,18 @@
322337

323338
(_\@lint_add_control_rule ( @assertion ) t
324339
(destructuringBind ( @key doc skip info warn error out @rest body ) (SK_ARGS)
340+
doc ; Lint waiver
325341
(foreach map sexp (list skip info warn error out) (SK_CHECK_FORM (list (car sexp))))
326342
(foreach map sexp body (SK_CHECK_FORM sexp ))
327343
));dbind
328344

329345

330-
331346
;; ===============================================================================================================
332347
;; Sharp Lint Functions
333348
;; ===============================================================================================================
334349

335350
(let ( ignores )
351+
ignores
336352

337353
(@fun add_ignore
338354
( ( name ?type symbol )
@@ -373,29 +389,37 @@
373389
;; *WARNING* (sklint): calling NLambda from Scheme code
374390

375391
(inSkill
376-
377-
(@fun @lint
378-
( @key
379-
( files ?type ( string ... ) )
380-
( ignores ?type list ?def () )
381-
( file_by_file ?type t|nil ?def (equal "TRUE" (getShellEnvVar "SKILL_SHARP_LINT_FILE_BY_FILE")) )
382-
)
383-
?doc "`sklint' wrapper with custom ignores."
384-
?out nil
385-
?global t
386-
(@letf ( ( (status printinfix) nil )
392+
(defun _\@lint ( @key file ignores )
393+
"`sklint' wrapper"
394+
;; TODO - No idea why but lint only works fine the second time on some file...
395+
;; Workaround is to run it once first but redirect its output
396+
(@with ( ( port (outfile "/dev/null" ))
387397
)
388-
(if file_by_file
389-
(forall file files
390-
(sklint ?file file ?ignores (nconc ignores (_\@lint_get_ignores))))
391-
(sklint ?file files ?ignores (nconc ignores (_\@lint_get_ignores)))
392-
);if
393-
));letf ;fun
398+
(@letf ( ( (@poport) port )
399+
)
400+
(sklint ?file file ?ignores ignores)
401+
))
402+
(sklint ?file file ?ignores ignores)
403+
))
394404

395-
);inSkill
405+
(@fun @lint
406+
( @key
407+
( files ?type ( string ... ) )
408+
( ignores ?type list ?def () )
409+
( file_by_file ?type t|nil ?def (equal "TRUE" (getShellEnvVar "SKILL_SHARP_LINT_FILE_BY_FILE")) )
410+
)
411+
?doc "`sklint' wrapper with custom ignores."
412+
?out nil
413+
?global t
414+
(@letf ( ( (status printinfix) nil )
415+
)
416+
(if file_by_file
417+
(forall file files
418+
(_\@lint ?file file ?ignores (nconc ignores (_\@lint_get_ignores))))
419+
(_\@lint ?file files ?ignores (nconc ignores (_\@lint_get_ignores)))
420+
);if
421+
));letf ;fun
396422

397-
;; TODO - Use (car (exists ...)) instead of (car (setof ...)) rule.
398423
;; TOOD - Always use `printf, `fprintf', `lsprintf', ... with more than one argument, at least (fprintf "%s" str)
399424

400-
; ))
401425
;*/

0 commit comments

Comments
 (0)