@atlisp/lint 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/atlisp-lint.default.json +2 -2
- package/dist/config.js +2 -2
- package/dist/presets.js +3 -3
- package/dist/rules.js +1 -1
- package/package.json +1 -1
- package/dist/atlisp-lint.default.json +0 -90
- package/dist/lib/lint-sbcl.lisp +0 -161
- package/dist/stub-packages.json +0 -41
package/atlisp-lint.default.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"vlax_without_loading": "warn",
|
|
16
16
|
"token_in_url": "warn",
|
|
17
17
|
"open_without_close": "warn",
|
|
18
|
-
"bare_function_names": "
|
|
18
|
+
"bare_function_names": "off",
|
|
19
19
|
"line_length": "warn",
|
|
20
20
|
"function_complexity": "warn",
|
|
21
21
|
"parameter_naming": "warn",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"recursive_call": "warn",
|
|
33
33
|
"variable_shadow": "warn",
|
|
34
34
|
"unused_local_fun": "warn",
|
|
35
|
-
"multiple_setq": "
|
|
35
|
+
"multiple_setq": "off",
|
|
36
36
|
"redundant_quotes": "warn",
|
|
37
37
|
"trailing_paren": "warn",
|
|
38
38
|
"empty_comment": "warn",
|
package/dist/config.js
CHANGED
|
@@ -57,7 +57,7 @@ const DEFAULT_CONFIG = {
|
|
|
57
57
|
vlax_without_loading: 'warn',
|
|
58
58
|
token_in_url: 'warn',
|
|
59
59
|
open_without_close: 'warn',
|
|
60
|
-
bare_function_names: '
|
|
60
|
+
bare_function_names: 'off',
|
|
61
61
|
line_length: 'warn',
|
|
62
62
|
function_complexity: 'warn',
|
|
63
63
|
parameter_naming: 'warn',
|
|
@@ -75,7 +75,7 @@ const DEFAULT_CONFIG = {
|
|
|
75
75
|
recursive_call: 'warn',
|
|
76
76
|
variable_shadow: 'warn',
|
|
77
77
|
unused_local_fun: 'warn',
|
|
78
|
-
multiple_setq: '
|
|
78
|
+
multiple_setq: 'off',
|
|
79
79
|
redundant_quotes: 'warn',
|
|
80
80
|
trailing_paren: 'warn',
|
|
81
81
|
empty_comment: 'warn',
|
package/dist/presets.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.PRESETS = {
|
|
|
27
27
|
recursive_call: 'warn',
|
|
28
28
|
variable_shadow: 'warn',
|
|
29
29
|
unused_local_fun: 'warn',
|
|
30
|
-
multiple_setq: '
|
|
30
|
+
multiple_setq: 'off',
|
|
31
31
|
redundant_quotes: 'warn',
|
|
32
32
|
trailing_paren: 'warn',
|
|
33
33
|
empty_comment: 'warn',
|
|
@@ -87,7 +87,7 @@ exports.PRESETS = {
|
|
|
87
87
|
vlax_without_loading: 'error',
|
|
88
88
|
token_in_url: 'error',
|
|
89
89
|
open_without_close: 'error',
|
|
90
|
-
bare_function_names: '
|
|
90
|
+
bare_function_names: 'off',
|
|
91
91
|
line_length: 'error',
|
|
92
92
|
function_complexity: 'error',
|
|
93
93
|
parameter_naming: 'error',
|
|
@@ -102,7 +102,7 @@ exports.PRESETS = {
|
|
|
102
102
|
recursive_call: 'error',
|
|
103
103
|
variable_shadow: 'error',
|
|
104
104
|
unused_local_fun: 'error',
|
|
105
|
-
multiple_setq: '
|
|
105
|
+
multiple_setq: 'off',
|
|
106
106
|
redundant_quotes: 'error',
|
|
107
107
|
trailing_paren: 'error',
|
|
108
108
|
empty_comment: 'error',
|
package/dist/rules.js
CHANGED
|
@@ -120,7 +120,7 @@ exports.RULES = [
|
|
|
120
120
|
description: '检测模块文件是否注册到 *modules*',
|
|
121
121
|
category: '架构',
|
|
122
122
|
},
|
|
123
|
-
{ name: 'multiple_setq', defaultSeverity: '
|
|
123
|
+
{ name: 'multiple_setq', defaultSeverity: 'off', description: '检测多个连续 setq 可以合并', category: '风格' },
|
|
124
124
|
{
|
|
125
125
|
name: 'namespace_header',
|
|
126
126
|
defaultSeverity: 'off',
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"locale": "zh",
|
|
3
|
-
"source": {
|
|
4
|
-
"globs": ["**/*.lsp"],
|
|
5
|
-
"exclude": ["**/node_modules/**", "**/vendor/**", "**/.git/**"]
|
|
6
|
-
},
|
|
7
|
-
"checks": {
|
|
8
|
-
"parens": "error",
|
|
9
|
-
"encoding": "warn",
|
|
10
|
-
"cl_syntax": "warn",
|
|
11
|
-
"quit_exit": "error",
|
|
12
|
-
"command_shell": "error",
|
|
13
|
-
"startapp": "warn",
|
|
14
|
-
"vl_registry_write": "warn",
|
|
15
|
-
"vlax_without_loading": "off",
|
|
16
|
-
"token_in_url": "warn",
|
|
17
|
-
"open_without_close": "warn",
|
|
18
|
-
"bare_function_names": "off",
|
|
19
|
-
"line_length": "warn",
|
|
20
|
-
"function_complexity": "warn",
|
|
21
|
-
"parameter_naming": "warn",
|
|
22
|
-
"unused_variable": "warn",
|
|
23
|
-
"missing_doc": "warn",
|
|
24
|
-
"error_handling": "warn",
|
|
25
|
-
"global_naming": "warn",
|
|
26
|
-
"extra_parens": "warn",
|
|
27
|
-
"arg_count": "warn",
|
|
28
|
-
"strcat_usage": "warn",
|
|
29
|
-
"cond_simplify": "warn",
|
|
30
|
-
"redundant_progn": "warn",
|
|
31
|
-
"quote_style": "warn",
|
|
32
|
-
"eq_usage": "warn",
|
|
33
|
-
"lambda_syntax": "warn",
|
|
34
|
-
"comment_style": "warn",
|
|
35
|
-
"empty_catch": "warn",
|
|
36
|
-
"nth_usage": "warn",
|
|
37
|
-
"append_single": "warn",
|
|
38
|
-
"setq_multiple": "warn",
|
|
39
|
-
"function_order": "off",
|
|
40
|
-
"magic_number": "off",
|
|
41
|
-
"mixed_indent": "warn",
|
|
42
|
-
"long_function_call": "warn",
|
|
43
|
-
"no_return": "warn",
|
|
44
|
-
"shadow_builtin": "warn",
|
|
45
|
-
"dynamic_doc": "warn",
|
|
46
|
-
"loop_optimization": "off",
|
|
47
|
-
"type_check": "off",
|
|
48
|
-
"redundant_if": "warn",
|
|
49
|
-
"trailing_whitespace": "warn",
|
|
50
|
-
"module_registration": "off",
|
|
51
|
-
"namespace_header": "off"
|
|
52
|
-
},
|
|
53
|
-
"line_length": {
|
|
54
|
-
"max": 100,
|
|
55
|
-
"tab_width": 2
|
|
56
|
-
},
|
|
57
|
-
"function_complexity": {
|
|
58
|
-
"max_lines": 60,
|
|
59
|
-
"max_nesting": 6
|
|
60
|
-
},
|
|
61
|
-
"cl_syntax": {
|
|
62
|
-
"keywords": ["&key"]
|
|
63
|
-
},
|
|
64
|
-
"dangerous_calls": {
|
|
65
|
-
"quit": "error",
|
|
66
|
-
"exit": "error",
|
|
67
|
-
"command_shell": "error",
|
|
68
|
-
"startapp": "warn",
|
|
69
|
-
"vl_registry_write": "warn"
|
|
70
|
-
},
|
|
71
|
-
"module_registration": {
|
|
72
|
-
"severity": "off",
|
|
73
|
-
"patterns": [],
|
|
74
|
-
"dirs": ["modules"]
|
|
75
|
-
},
|
|
76
|
-
"namespace_header": {
|
|
77
|
-
"severity": "off",
|
|
78
|
-
"package": "",
|
|
79
|
-
"deps": [],
|
|
80
|
-
"search_lines": 15
|
|
81
|
-
},
|
|
82
|
-
"bare_function_names": {
|
|
83
|
-
"allowlist": ["T", "nil"],
|
|
84
|
-
"namespace_pattern": "^[a-z]+:"
|
|
85
|
-
},
|
|
86
|
-
"sbcl": {
|
|
87
|
-
"walk_exclude": [".vscode", "vendor", ".git"],
|
|
88
|
-
"defmacro_allow_files": ["compat-cl"]
|
|
89
|
-
}
|
|
90
|
-
}
|
package/dist/lib/lint-sbcl.lisp
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
;; @lisp SBCL Lint — syntax validation via SBCL
|
|
2
|
-
;; Usage: sbcl --script lint-sbcl.lisp <src-dir> <stub-packages.json> <walk-exclude-json> <defmacro-allow-files-json> <locale>
|
|
3
|
-
|
|
4
|
-
(require :uiop)
|
|
5
|
-
|
|
6
|
-
(defparameter *errors* 0)
|
|
7
|
-
(defparameter *warnings* 0)
|
|
8
|
-
(defparameter *checked* 0)
|
|
9
|
-
(defparameter *locale* "zh")
|
|
10
|
-
|
|
11
|
-
;; ── i18n ──────────────────────────────────────────────────────────────
|
|
12
|
-
(defun i18n (key)
|
|
13
|
-
(cdr (assoc key
|
|
14
|
-
(if (string= *locale* "zh")
|
|
15
|
-
'((:not-found . "not found symbol")
|
|
16
|
-
(:syntax-error . "syntax error")
|
|
17
|
-
(:vec-syntax . "#( vector syntax")
|
|
18
|
-
(:char-syntax . "# backslash char literal")
|
|
19
|
-
(:eval-syntax . "#. read-time eval")
|
|
20
|
-
(:defmacro . "defmacro")
|
|
21
|
-
(:trailing-ws . "trailing whitespace")
|
|
22
|
-
(:ok . "OK")
|
|
23
|
-
(:fail . "FAIL")
|
|
24
|
-
(:header . " @lisp SBCL Lint")
|
|
25
|
-
(:source . " Source")
|
|
26
|
-
(:found . " Found ~d .lsp files")
|
|
27
|
-
(:scanned . " Scanned")
|
|
28
|
-
(:errors . " Errors")
|
|
29
|
-
(:warnings . " Warnings"))
|
|
30
|
-
'((:not-found . "not found symbol")
|
|
31
|
-
(:syntax-error . "syntax error")
|
|
32
|
-
(:vec-syntax . "#( vector syntax")
|
|
33
|
-
(:char-syntax . "# backslash char literal")
|
|
34
|
-
(:eval-syntax . "#. read-time eval")
|
|
35
|
-
(:defmacro . "defmacro")
|
|
36
|
-
(:trailing-ws . "trailing whitespace")
|
|
37
|
-
(:ok . "OK")
|
|
38
|
-
(:fail . "FAIL")
|
|
39
|
-
(:header . " @lisp SBCL Lint")
|
|
40
|
-
(:source . " Source")
|
|
41
|
-
(:found . " Found ~d .lsp files")
|
|
42
|
-
(:scanned . " Scanned")
|
|
43
|
-
(:errors . " Errors")
|
|
44
|
-
(:warnings . " Warnings"))))))
|
|
45
|
-
|
|
46
|
-
;; ── Stub packages from external file ──────────────────────────────────
|
|
47
|
-
(defun load-stub-packages (file-path)
|
|
48
|
-
(flet ((ensure-pkg (name &optional use-list)
|
|
49
|
-
(unless (find-package name)
|
|
50
|
-
(make-package name :use (or use-list '())))))
|
|
51
|
-
(with-open-file (s file-path :direction :input)
|
|
52
|
-
(let ((packages (read s)))
|
|
53
|
-
(dolist (pkg packages)
|
|
54
|
-
(ensure-pkg (first pkg) (second pkg)))))))
|
|
55
|
-
|
|
56
|
-
;; ── File walking ──────────────────────────────────────────────────────
|
|
57
|
-
(defun source-files (dir)
|
|
58
|
-
(sort
|
|
59
|
-
(remove-if-not
|
|
60
|
-
(lambda (p)
|
|
61
|
-
(let ((n (pathname-type p)))
|
|
62
|
-
(and n (string-equal n "lsp"))))
|
|
63
|
-
(uiop:directory-files dir))
|
|
64
|
-
'string< :key #'namestring))
|
|
65
|
-
|
|
66
|
-
(defun walk-tree (dir exclude-dirs)
|
|
67
|
-
(let ((result (source-files dir)))
|
|
68
|
-
(dolist (sub (uiop:subdirectories dir))
|
|
69
|
-
(let ((name (car (last (pathname-directory sub)))))
|
|
70
|
-
(unless (find name exclude-dirs :test 'string=)
|
|
71
|
-
(setf result (append result (walk-tree sub exclude-dirs))))))
|
|
72
|
-
result))
|
|
73
|
-
|
|
74
|
-
;; ── Per-file check ────────────────────────────────────────────────────
|
|
75
|
-
(defun check-file (path src-dir defmacro-allow-files)
|
|
76
|
-
(incf *checked*)
|
|
77
|
-
(let* ((rel (enough-namestring path src-dir))
|
|
78
|
-
(fullname (format nil "~a.~a" (pathname-name path) (pathname-type path))))
|
|
79
|
-
(format t " ~a ... " rel)
|
|
80
|
-
(force-output)
|
|
81
|
-
;; Syntax check via READ
|
|
82
|
-
(handler-case
|
|
83
|
-
(with-open-file (s path :direction :input)
|
|
84
|
-
(loop for form = (read s nil :eof)
|
|
85
|
-
until (eq form :eof)))
|
|
86
|
-
(error (e)
|
|
87
|
-
(let ((msg (princ-to-string e)))
|
|
88
|
-
(cond
|
|
89
|
-
((search "not found" msg)
|
|
90
|
-
(format t "~% [NOTE] ~a: ~a~%" rel (i18n :not-found))
|
|
91
|
-
(incf *warnings*))
|
|
92
|
-
(t
|
|
93
|
-
(format t "~a~% [ERROR] ~a: ~a~%" (i18n :fail) rel (i18n :syntax-error))
|
|
94
|
-
(incf *errors*)
|
|
95
|
-
(return-from check-file))))))
|
|
96
|
-
;; Trailing whitespace
|
|
97
|
-
(with-open-file (s path :direction :input)
|
|
98
|
-
(loop for line = (read-line s nil nil)
|
|
99
|
-
for lineno from 1
|
|
100
|
-
while line
|
|
101
|
-
when (and (> (length line) 0)
|
|
102
|
-
(find (char line (1- (length line))) '(#\Space #\Tab)))
|
|
103
|
-
do (progn
|
|
104
|
-
(format t "~% [WARN] ~a line ~d: ~a~%" rel lineno (i18n :trailing-ws))
|
|
105
|
-
(incf *warnings*))))
|
|
106
|
-
;; CL-ism checks: raw content scan
|
|
107
|
-
(with-open-file (s path :direction :input)
|
|
108
|
-
(let ((content (make-string (file-length s))))
|
|
109
|
-
(file-position s 0)
|
|
110
|
-
(read-sequence content s)
|
|
111
|
-
(when (search "#(" content)
|
|
112
|
-
(format t "~% [WARN] ~a: ~a~%" rel (i18n :vec-syntax))
|
|
113
|
-
(incf *warnings*))
|
|
114
|
-
(when (search "#\\" content)
|
|
115
|
-
(format t "~% [WARN] ~a: ~a~%" rel (i18n :char-syntax))
|
|
116
|
-
(incf *warnings*))
|
|
117
|
-
(when (search "#." content)
|
|
118
|
-
(format t "~% [WARN] ~a: ~a~%" rel (i18n :eval-syntax))
|
|
119
|
-
(incf *warnings*))
|
|
120
|
-
(when (and (search "defmacro" content)
|
|
121
|
-
(not (some (lambda (s) (search s fullname)) defmacro-allow-files)))
|
|
122
|
-
(format t "~% [WARN] ~a: ~a~%" rel (i18n :defmacro))
|
|
123
|
-
(incf *warnings*))))
|
|
124
|
-
(format t "~a~%" (i18n :ok))))
|
|
125
|
-
|
|
126
|
-
;; ── Main ──────────────────────────────────────────────────────────────
|
|
127
|
-
(defun main ()
|
|
128
|
-
(let* ((args (uiop:command-line-arguments))
|
|
129
|
-
(src-dir (first args))
|
|
130
|
-
(stub-file (second args))
|
|
131
|
-
(walk-exclude (if (third args)
|
|
132
|
-
(read-from-string (third args))
|
|
133
|
-
'(".vscode" "test" "experiment" "tools" ".git")))
|
|
134
|
-
(defmacro-allow (if (fourth args)
|
|
135
|
-
(read-from-string (fourth args))
|
|
136
|
-
'("compat-cl")))
|
|
137
|
-
(locale (fifth args)))
|
|
138
|
-
(when locale (setf *locale* locale))
|
|
139
|
-
(load-stub-packages stub-file)
|
|
140
|
-
|
|
141
|
-
(format t "~%==================================================~%")
|
|
142
|
-
(format t "~a~%" (i18n :header))
|
|
143
|
-
(format t "~a: ~a~%" (i18n :source) (namestring (pathname src-dir)))
|
|
144
|
-
(format t "==================================================~%~%")
|
|
145
|
-
(setf *errors* 0 *warnings* 0 *checked* 0)
|
|
146
|
-
|
|
147
|
-
(let ((files (walk-tree src-dir walk-exclude)))
|
|
148
|
-
(format t "~a~%~%" (format nil (i18n :found) (length files)))
|
|
149
|
-
(dolist (f files)
|
|
150
|
-
(check-file f src-dir defmacro-allow)))
|
|
151
|
-
|
|
152
|
-
(format t "~%==================================================~%")
|
|
153
|
-
(format t "~a: ~d~%" (i18n :scanned) *checked*)
|
|
154
|
-
(format t "~a: ~d~%" (i18n :errors) *errors*)
|
|
155
|
-
(format t "~a: ~d~%" (i18n :warnings) *warnings*)
|
|
156
|
-
(format t "==================================================~%~%")
|
|
157
|
-
(if (> *errors* 0)
|
|
158
|
-
(uiop:quit 1)
|
|
159
|
-
(uiop:quit 0))))
|
|
160
|
-
|
|
161
|
-
(main)
|
package/dist/stub-packages.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
((AUTOLISP ())
|
|
2
|
-
(@ (COMMON-LISP AUTOLISP))
|
|
3
|
-
(C ())
|
|
4
|
-
(JSON ())
|
|
5
|
-
(SIDEBAR ())
|
|
6
|
-
(FUN ())
|
|
7
|
-
(DCL ())
|
|
8
|
-
(BASE ())
|
|
9
|
-
(STRING ())
|
|
10
|
-
(BLOCK ())
|
|
11
|
-
(ENTITY ())
|
|
12
|
-
(LAYER ())
|
|
13
|
-
(LAYOUT ())
|
|
14
|
-
(CURVE ())
|
|
15
|
-
(LIST ())
|
|
16
|
-
(M ())
|
|
17
|
-
(P ())
|
|
18
|
-
(UI ())
|
|
19
|
-
(SYS ())
|
|
20
|
-
(EXCEL ())
|
|
21
|
-
(WORD ())
|
|
22
|
-
(RE ())
|
|
23
|
-
(VECTRA ())
|
|
24
|
-
(DOS ())
|
|
25
|
-
(AT-PM ())
|
|
26
|
-
(QRENCODE ())
|
|
27
|
-
(NETWORK ())
|
|
28
|
-
(PKGMAN ())
|
|
29
|
-
(DATETIME ())
|
|
30
|
-
(DICT ())
|
|
31
|
-
(@NLP ())
|
|
32
|
-
(AT-SIDEBAR ())
|
|
33
|
-
(S ())
|
|
34
|
-
(VL ())
|
|
35
|
-
(VLR ())
|
|
36
|
-
(VLAX ())
|
|
37
|
-
(THEME ())
|
|
38
|
-
(AJAX ())
|
|
39
|
-
(ATLISP ())
|
|
40
|
-
(LOG ())
|
|
41
|
-
(ATLISP-CORE ()))
|