@atlisp/lint 0.2.1 → 0.2.3

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.
@@ -12,7 +12,7 @@
12
12
  "command_shell": "warn",
13
13
  "startapp": "warn",
14
14
  "vl_registry_write": "off",
15
- "vlax_without_loading": "warn",
15
+ "vlax_without_loading": "info",
16
16
  "token_in_url": "warn",
17
17
  "open_without_close": "warn",
18
18
  "bare_function_names": "off",
@@ -46,7 +46,7 @@
46
46
  "commented_code": "warn",
47
47
  "double_not": "warn",
48
48
  "setq_single_arg": "warn",
49
- "assoc_without_cdr": "warn",
49
+ "assoc_without_cdr": "info",
50
50
  "identical_branches": "warn",
51
51
  "while_constant": "warn",
52
52
  "cond_duplicate": "warn",
@@ -71,9 +71,9 @@
71
71
  "setq_multiple": "warn",
72
72
  "format_indent": "off",
73
73
  "function_order": "off",
74
- "magic_number": "off",
74
+ "magic_number": "info",
75
75
  "mixed_indent": "warn",
76
- "long_function_call": "warn",
76
+ "long_function_call": "info",
77
77
  "no_return": "warn",
78
78
  "shadow_builtin": "warn",
79
79
  "dynamic_doc": "warn",
@@ -82,7 +82,7 @@
82
82
  "redundant_if": "warn",
83
83
  "undeclared_setq": "warn",
84
84
  "unused_catch_result": "off",
85
- "string_concat_loop": "off",
85
+ "string_concat_loop": "info",
86
86
  "if_without_else": "off",
87
87
  "redundant_list": "warn",
88
88
  "entget_in_loop": "warn",
@@ -35,7 +35,7 @@ const BUILTIN_ARITY = {
35
35
  minusp: { min: 1, max: 1 },
36
36
  plusp: { min: 1, max: 1 },
37
37
  eq: { min: 2, max: 2 },
38
- equal: { min: 2, max: 2 },
38
+ equal: { min: 2, max: 3 },
39
39
  '=': { min: 2, max: -1 },
40
40
  '/=': { min: 2, max: -1 },
41
41
  '<': { min: 2, max: -1 },
@@ -12,7 +12,7 @@ function checkMagicNumber(content, file) {
12
12
  if (m) {
13
13
  const num = m[1];
14
14
  if (num !== '10' && num !== '20' && num !== '100' && num !== '1000') {
15
- issues.push({ file, line: i + 1, severity: 'warn', rule: 'magic_number', message: (0, locale_1.t)('magic_number', num) });
15
+ issues.push({ file, line: i + 1, severity: 'off', rule: 'magic_number', message: (0, locale_1.t)('magic_number', num) });
16
16
  }
17
17
  }
18
18
  }
@@ -47,7 +47,7 @@ function checkStringConcatInLoop(content, file) {
47
47
  issues.push({
48
48
  file,
49
49
  line: i + 1,
50
- severity: 'warn',
50
+ severity: 'info',
51
51
  rule: 'string_concat_loop',
52
52
  message: (0, locale_1.t)('string_concat_loop', name),
53
53
  });
package/dist/config.js CHANGED
@@ -113,7 +113,7 @@ const DEFAULT_CONFIG = {
113
113
  append_single: 'info',
114
114
  setq_multiple: 'warn',
115
115
  function_order: 'off',
116
- magic_number: 'info',
116
+ magic_number: 'off',
117
117
  mixed_indent: 'info',
118
118
  long_function_call: 'info',
119
119
  no_return: 'info',
package/dist/presets.js CHANGED
@@ -141,7 +141,7 @@ exports.PRESETS = {
141
141
  append_single: 'error',
142
142
  setq_multiple: 'error',
143
143
  function_order: 'off',
144
- magic_number: 'warn',
144
+ magic_number: 'off',
145
145
  mixed_indent: 'error',
146
146
  long_function_call: 'error',
147
147
  no_return: 'error',
@@ -154,7 +154,7 @@ exports.PRESETS = {
154
154
  module_registration: 'error',
155
155
  namespace_header: 'error',
156
156
  unused_catch_result: 'error',
157
- string_concat_loop: 'off',
157
+ string_concat_loop: 'info',
158
158
  if_without_else: 'off',
159
159
  redundant_list: 'error',
160
160
  entget_in_loop: 'warn',
package/dist/rules.js CHANGED
@@ -104,7 +104,7 @@ exports.RULES = [
104
104
  description: '检测可优化的 while/assoc 循环',
105
105
  category: '最佳实践',
106
106
  },
107
- { name: 'magic_number', defaultSeverity: 'info', description: '检测硬编码的魔法数字', category: '风格' },
107
+ { name: 'magic_number', defaultSeverity: 'off', description: '检测硬编码的魔法数字', category: '风格' },
108
108
  {
109
109
  name: 'misplaced_else',
110
110
  defaultSeverity: 'info',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/lint",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "AutoLISP static analysis tool — parens, security, conventions, SBCL syntax validation",
5
5
  "keywords": [
6
6
  "CAD",
@@ -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
- }
@@ -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)
@@ -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 ()))