@atlisp/lint 0.1.29 → 0.2.0
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/dist/checks/empty-catch.js +7 -2
- package/dist/config.js +34 -33
- package/dist/formatters-html.js +4 -2
- package/dist/formatters-sarif.js +2 -2
- package/dist/formatters.js +13 -8
- package/dist/locale.js +6 -2
- package/dist/presets.js +30 -30
- package/dist/rules.js +33 -33
- package/dist/types.d.ts +2 -1
- package/dist/validate.js +1 -1
- package/package.json +1 -1
|
@@ -37,8 +37,13 @@ function isInQuote(node) {
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
function isWrappedByCatchError(node) {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
let p = node.parent;
|
|
41
|
+
while (p) {
|
|
42
|
+
if ((0, parser_1.astIsList)(p, 'vl-catch-all-error-p'))
|
|
43
|
+
return true;
|
|
44
|
+
p = p.parent;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
42
47
|
}
|
|
43
48
|
function isSetqStored(node) {
|
|
44
49
|
const parent = node.parent;
|
package/dist/config.js
CHANGED
|
@@ -58,36 +58,36 @@ const DEFAULT_CONFIG = {
|
|
|
58
58
|
token_in_url: 'warn',
|
|
59
59
|
open_without_close: 'warn',
|
|
60
60
|
bare_function_names: 'off',
|
|
61
|
-
line_length: '
|
|
61
|
+
line_length: 'info',
|
|
62
62
|
function_complexity: 'warn',
|
|
63
|
-
parameter_naming: '
|
|
63
|
+
parameter_naming: 'info',
|
|
64
64
|
unused_variable: 'warn',
|
|
65
|
-
missing_doc: '
|
|
66
|
-
trailing_whitespace: '
|
|
65
|
+
missing_doc: 'info',
|
|
66
|
+
trailing_whitespace: 'info',
|
|
67
67
|
undeclared_setq: 'warn',
|
|
68
68
|
module_registration: 'off',
|
|
69
69
|
namespace_header: 'off',
|
|
70
70
|
unused_parameter: 'warn',
|
|
71
71
|
constant_condition: 'warn',
|
|
72
|
-
redundant_progn: '
|
|
72
|
+
redundant_progn: 'info',
|
|
73
73
|
empty_branch: 'warn',
|
|
74
74
|
unused_let_binding: 'warn',
|
|
75
75
|
recursive_call: 'warn',
|
|
76
76
|
variable_shadow: 'warn',
|
|
77
77
|
unused_local_fun: 'warn',
|
|
78
|
-
multiple_setq: '
|
|
79
|
-
redundant_quotes: '
|
|
78
|
+
multiple_setq: 'info',
|
|
79
|
+
redundant_quotes: 'info',
|
|
80
80
|
trailing_paren: 'warn',
|
|
81
|
-
empty_comment: '
|
|
81
|
+
empty_comment: 'info',
|
|
82
82
|
redundant_setq: 'warn',
|
|
83
|
-
redundant_nil_else: '
|
|
84
|
-
single_arg_and_or: '
|
|
85
|
-
redundant_let: '
|
|
83
|
+
redundant_nil_else: 'info',
|
|
84
|
+
single_arg_and_or: 'info',
|
|
85
|
+
redundant_let: 'info',
|
|
86
86
|
self_compare: 'warn',
|
|
87
|
-
misplaced_else: '
|
|
87
|
+
misplaced_else: 'info',
|
|
88
88
|
quote_vs_function: 'warn',
|
|
89
89
|
commented_code: 'warn',
|
|
90
|
-
double_not: '
|
|
90
|
+
double_not: 'info',
|
|
91
91
|
setq_single_arg: 'warn',
|
|
92
92
|
assoc_without_cdr: 'warn',
|
|
93
93
|
identical_branches: 'warn',
|
|
@@ -98,36 +98,37 @@ const DEFAULT_CONFIG = {
|
|
|
98
98
|
missing_export: 'warn',
|
|
99
99
|
unused_package_dep: 'warn',
|
|
100
100
|
error_handling: 'warn',
|
|
101
|
-
global_naming: '
|
|
101
|
+
global_naming: 'info',
|
|
102
102
|
extra_parens: 'warn',
|
|
103
103
|
arg_count: 'warn',
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
builtin_arg_count: 'error',
|
|
105
|
+
strcat_usage: 'info',
|
|
106
|
+
cond_simplify: 'info',
|
|
107
|
+
quote_style: 'info',
|
|
107
108
|
eq_usage: 'warn',
|
|
108
109
|
lambda_syntax: 'off',
|
|
109
|
-
comment_style: '
|
|
110
|
+
comment_style: 'info',
|
|
110
111
|
empty_catch: 'warn',
|
|
111
|
-
nth_usage: '
|
|
112
|
-
append_single: '
|
|
112
|
+
nth_usage: 'info',
|
|
113
|
+
append_single: 'info',
|
|
113
114
|
setq_multiple: 'warn',
|
|
114
|
-
function_order: '
|
|
115
|
-
magic_number: '
|
|
116
|
-
mixed_indent: '
|
|
117
|
-
long_function_call: '
|
|
118
|
-
no_return: '
|
|
115
|
+
function_order: 'info',
|
|
116
|
+
magic_number: 'info',
|
|
117
|
+
mixed_indent: 'info',
|
|
118
|
+
long_function_call: 'info',
|
|
119
|
+
no_return: 'info',
|
|
119
120
|
shadow_builtin: 'warn',
|
|
120
121
|
dynamic_doc: 'warn',
|
|
121
|
-
loop_optimization: '
|
|
122
|
-
type_check: '
|
|
122
|
+
loop_optimization: 'info',
|
|
123
|
+
type_check: 'info',
|
|
123
124
|
format_indent: 'off',
|
|
124
|
-
redundant_if: '
|
|
125
|
-
unused_catch_result: '
|
|
126
|
-
string_concat_loop: '
|
|
127
|
-
if_without_else: '
|
|
128
|
-
redundant_list: '
|
|
125
|
+
redundant_if: 'info',
|
|
126
|
+
unused_catch_result: 'info',
|
|
127
|
+
string_concat_loop: 'info',
|
|
128
|
+
if_without_else: 'info',
|
|
129
|
+
redundant_list: 'info',
|
|
129
130
|
entget_in_loop: 'warn',
|
|
130
|
-
promise_handler: '
|
|
131
|
+
promise_handler: 'info',
|
|
131
132
|
module_cycle: 'warn',
|
|
132
133
|
arg_count_project: 'warn',
|
|
133
134
|
},
|
package/dist/formatters-html.js
CHANGED
|
@@ -14,7 +14,9 @@ function formatHtml(issues, errorCount, warningCount) {
|
|
|
14
14
|
for (const iss of issues) {
|
|
15
15
|
const tag = iss.severity === 'error'
|
|
16
16
|
? '<span class="badge bg-danger">ERROR</span>'
|
|
17
|
-
:
|
|
17
|
+
: iss.severity === 'warn'
|
|
18
|
+
? '<span class="badge bg-warning text-dark">WARN</span>'
|
|
19
|
+
: '<span class="badge bg-info text-dark">INFO</span>';
|
|
18
20
|
rows += `<tr><td>${tag}</td><td>${iss.rule}</td><td>${iss.file}</td><td>${iss.line || '-'}</td><td>${escHtml(iss.message)}</td></tr>\n`;
|
|
19
21
|
}
|
|
20
22
|
let summaryHtml = '';
|
|
@@ -63,7 +65,7 @@ function formatHtml(issues, errorCount, warningCount) {
|
|
|
63
65
|
<span class="fw-bold">${escHtml(iss.file)}:${iss.line || '-'}</span>
|
|
64
66
|
<br><span class="text-muted">${escHtml(iss.message)}</span>
|
|
65
67
|
</div>
|
|
66
|
-
${iss.severity === 'error' ? '<span class="badge bg-danger rounded-pill">ERROR</span>' : '<span class="badge bg-warning text-dark rounded-pill">WARN</span>'}
|
|
68
|
+
${iss.severity === 'error' ? '<span class="badge bg-danger rounded-pill">ERROR</span>' : iss.severity === 'warn' ? '<span class="badge bg-warning text-dark rounded-pill">WARN</span>' : '<span class="badge bg-info text-dark rounded-pill">INFO</span>'}
|
|
67
69
|
</li>
|
|
68
70
|
`).join('')}
|
|
69
71
|
</ul>
|
package/dist/formatters-sarif.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.formatSarif = formatSarif;
|
|
4
4
|
function formatSarif(issues, errorCount, warningCount) {
|
|
5
5
|
const results = issues.map(iss => {
|
|
6
|
-
const level = iss.severity === 'error' ? 'error' : 'warning';
|
|
6
|
+
const level = iss.severity === 'error' ? 'error' : iss.severity === 'warn' ? 'warning' : 'note';
|
|
7
7
|
return {
|
|
8
8
|
level,
|
|
9
9
|
message: {
|
|
@@ -32,7 +32,7 @@ function formatSarif(issues, errorCount, warningCount) {
|
|
|
32
32
|
tool: {
|
|
33
33
|
driver: {
|
|
34
34
|
name: '@atlisp/lint',
|
|
35
|
-
version: '0.
|
|
35
|
+
version: '0.2.0',
|
|
36
36
|
informationUri: 'https://github.com/atlisp/lint',
|
|
37
37
|
rules: issues.map(iss => ({
|
|
38
38
|
id: iss.rule,
|
package/dist/formatters.js
CHANGED
|
@@ -22,8 +22,8 @@ function formatDefault(issues, fileContents) {
|
|
|
22
22
|
errors++;
|
|
23
23
|
else if (iss.severity === 'warn')
|
|
24
24
|
warnings++;
|
|
25
|
-
const tagColor = iss.severity === 'error' ? colors.red : colors.yellow;
|
|
26
|
-
const tag = iss.severity === 'error' ? (0, locale_1.t)('summary.tag_fail') : (0, locale_1.t)('summary.tag_warn');
|
|
25
|
+
const tagColor = iss.severity === 'error' ? colors.red : iss.severity === 'warn' ? colors.yellow : colors.cyan;
|
|
26
|
+
const tag = iss.severity === 'error' ? (0, locale_1.t)('summary.tag_fail') : iss.severity === 'warn' ? (0, locale_1.t)('summary.tag_warn') : (0, locale_1.t)('summary.tag_info');
|
|
27
27
|
const loc = iss.line > 0 ? `${(0, locale_1.t)('summary.line')} ${iss.line}` : '';
|
|
28
28
|
const prefix = useColor ? `${tagColor}${tag}${colors.reset}` : tag;
|
|
29
29
|
lines.push(`${prefix}: ${iss.file} — ${loc}${loc ? ': ' : ''}${iss.message}`.trim());
|
|
@@ -46,33 +46,38 @@ function formatDefault(issues, fileContents) {
|
|
|
46
46
|
if (lines.length > 0)
|
|
47
47
|
lines.push('');
|
|
48
48
|
const summaryColor = errors > 0 ? colors.red : warnings > 0 ? colors.yellow : colors.cyan;
|
|
49
|
+
const infoCount = issues.filter(i => i.severity === 'info').length;
|
|
49
50
|
if (useColor) {
|
|
50
51
|
lines.push(`${colors.cyan}${(0, locale_1.t)('summary.header')}${colors.reset}`);
|
|
51
|
-
if (errors === 0 && warnings === 0) {
|
|
52
|
+
if (errors === 0 && warnings === 0 && infoCount === 0) {
|
|
52
53
|
lines.push(`${colors.gray}${(0, locale_1.t)('summary.all_ok')}${colors.reset}`);
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
|
-
lines.push(`${summaryColor}${(0, locale_1.t)('summary.errors_warnings', errors, warnings)}${colors.reset}`);
|
|
56
|
+
lines.push(`${summaryColor}${(0, locale_1.t)('summary.errors_warnings', errors, warnings, infoCount)}${colors.reset}`);
|
|
56
57
|
}
|
|
57
58
|
lines.push(`${colors.cyan}${(0, locale_1.t)('summary.done')}${colors.reset}`);
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
61
|
lines.push((0, locale_1.t)('summary.header'));
|
|
61
|
-
if (errors === 0 && warnings === 0) {
|
|
62
|
+
if (errors === 0 && warnings === 0 && infoCount === 0) {
|
|
62
63
|
lines.push((0, locale_1.t)('summary.all_ok'));
|
|
63
64
|
}
|
|
64
65
|
else {
|
|
65
|
-
lines.push((0, locale_1.t)('summary.errors_warnings', errors, warnings));
|
|
66
|
+
lines.push((0, locale_1.t)('summary.errors_warnings', errors, warnings, infoCount));
|
|
66
67
|
}
|
|
67
68
|
lines.push((0, locale_1.t)('summary.done'));
|
|
68
69
|
}
|
|
69
70
|
return lines.join('\n');
|
|
70
71
|
}
|
|
71
72
|
function formatJson(issues, errorCount, warningCount) {
|
|
73
|
+
const err = errorCount ?? issues.filter(i => i.severity === 'error').length;
|
|
74
|
+
const warn = warningCount ?? issues.filter(i => i.severity === 'warn').length;
|
|
75
|
+
const info = issues.filter(i => i.severity === 'info').length;
|
|
72
76
|
return JSON.stringify({
|
|
73
77
|
issues,
|
|
74
|
-
error_count:
|
|
75
|
-
warning_count:
|
|
78
|
+
error_count: err,
|
|
79
|
+
warning_count: warn,
|
|
80
|
+
info_count: info,
|
|
76
81
|
}, null, 2);
|
|
77
82
|
}
|
|
78
83
|
//# sourceMappingURL=formatters.js.map
|
package/dist/locale.js
CHANGED
|
@@ -74,10 +74,11 @@ const messages = {
|
|
|
74
74
|
'sbcl.not_found': 'SBCL (Steel Bank Common Lisp) is required but not found.\nInstall it from: https://www.sbcl.org/platform-table.html\nOr on Windows via: winget install sbcl\nOr on macOS via: brew install sbcl\nOr on Linux via: apt install sbcl',
|
|
75
75
|
'summary.tag_fail': 'FAIL',
|
|
76
76
|
'summary.tag_warn': 'WARN',
|
|
77
|
+
'summary.tag_info': 'INFO',
|
|
77
78
|
'summary.line': 'Line',
|
|
78
79
|
'summary.header': '=== Summary ===',
|
|
79
80
|
'summary.all_ok': ' All files OK',
|
|
80
|
-
'summary.errors_warnings': ' {0} error(s), {1} warning(s)',
|
|
81
|
+
'summary.errors_warnings': ' {0} error(s), {1} warning(s), {2} info(s)',
|
|
81
82
|
'summary.done': '=== Done ===',
|
|
82
83
|
'index.no_files': 'No .lsp files found',
|
|
83
84
|
'index.config_exists': 'atlisp-lint.json already exists',
|
|
@@ -141,6 +142,8 @@ Options:
|
|
|
141
142
|
vlax_without_loading: '文件中使用了 vlax-* 函数但未调用 vl-load-com',
|
|
142
143
|
token_in_url: '字符串中可能泄露令牌:URL 中包含 token=',
|
|
143
144
|
open_without_close: '文件中有 {0} 个 open() 调用,但只有 {1} 个 close() 调用(可能存在资源泄露)',
|
|
145
|
+
'builtin_arg_count.too_few': "内置函数 '{0}' 调用时传入了 {1} 个参数,至少需要 {2} 个",
|
|
146
|
+
'builtin_arg_count.too_many': "内置函数 '{0}' 调用时传入了 {1} 个参数,最多允许 {2} 个",
|
|
144
147
|
arg_count: "函数 '{0}' 调用时传入了 {1} 个参数,但定义时为 {2} 个",
|
|
145
148
|
bare_function_names: "函数 '{0}' 缺少命名空间前缀(缺少 @:: 或 C: 前缀)",
|
|
146
149
|
module_registration: '模块文件缺少 @::*modules* 注册(应在文件末尾附近)',
|
|
@@ -195,10 +198,11 @@ Options:
|
|
|
195
198
|
'sbcl.not_found': '未找到 SBCL(Steel Bank Common Lisp)。\n请从以下地址安装:https://www.sbcl.org/platform-table.html\nWindows 下可用:winget install sbcl\nmacOS 下可用:brew install sbcl\nLinux 下可用:apt install sbcl',
|
|
196
199
|
'summary.tag_fail': '失败',
|
|
197
200
|
'summary.tag_warn': '警告',
|
|
201
|
+
'summary.tag_info': '信息',
|
|
198
202
|
'summary.line': '行',
|
|
199
203
|
'summary.header': '=== 概要 ===',
|
|
200
204
|
'summary.all_ok': ' 所有文件检查通过',
|
|
201
|
-
'summary.errors_warnings': ' {0} 个错误,{1}
|
|
205
|
+
'summary.errors_warnings': ' {0} 个错误,{1} 个警告,{2} 条信息',
|
|
202
206
|
'summary.done': '=== 完成 ===',
|
|
203
207
|
'index.no_files': '未找到 .lsp 文件',
|
|
204
208
|
'index.config_exists': 'atlisp-lint.json 已存在',
|
package/dist/presets.js
CHANGED
|
@@ -13,65 +13,65 @@ exports.PRESETS = {
|
|
|
13
13
|
vl_registry_write: 'off',
|
|
14
14
|
token_in_url: 'warn',
|
|
15
15
|
open_without_close: 'warn',
|
|
16
|
-
line_length: '
|
|
16
|
+
line_length: 'info',
|
|
17
17
|
function_complexity: 'warn',
|
|
18
|
-
parameter_naming: '
|
|
18
|
+
parameter_naming: 'info',
|
|
19
19
|
unused_variable: 'warn',
|
|
20
|
-
missing_doc: '
|
|
21
|
-
trailing_whitespace: '
|
|
20
|
+
missing_doc: 'info',
|
|
21
|
+
trailing_whitespace: 'info',
|
|
22
22
|
unused_parameter: 'warn',
|
|
23
23
|
constant_condition: 'warn',
|
|
24
|
-
redundant_progn: '
|
|
24
|
+
redundant_progn: 'info',
|
|
25
25
|
empty_branch: 'warn',
|
|
26
26
|
unused_let_binding: 'warn',
|
|
27
27
|
recursive_call: 'warn',
|
|
28
28
|
variable_shadow: 'warn',
|
|
29
29
|
unused_local_fun: 'warn',
|
|
30
|
-
multiple_setq: '
|
|
31
|
-
redundant_quotes: '
|
|
30
|
+
multiple_setq: 'info',
|
|
31
|
+
redundant_quotes: 'info',
|
|
32
32
|
trailing_paren: 'warn',
|
|
33
|
-
empty_comment: '
|
|
33
|
+
empty_comment: 'info',
|
|
34
34
|
redundant_setq: 'warn',
|
|
35
|
-
redundant_nil_else: '
|
|
36
|
-
single_arg_and_or: '
|
|
37
|
-
redundant_let: '
|
|
35
|
+
redundant_nil_else: 'info',
|
|
36
|
+
single_arg_and_or: 'info',
|
|
37
|
+
redundant_let: 'info',
|
|
38
38
|
self_compare: 'warn',
|
|
39
|
-
misplaced_else: '
|
|
39
|
+
misplaced_else: 'info',
|
|
40
40
|
quote_vs_function: 'warn',
|
|
41
41
|
commented_code: 'warn',
|
|
42
|
-
double_not: '
|
|
42
|
+
double_not: 'info',
|
|
43
43
|
setq_single_arg: 'warn',
|
|
44
44
|
assoc_without_cdr: 'warn',
|
|
45
45
|
identical_branches: 'warn',
|
|
46
46
|
while_constant: 'warn',
|
|
47
47
|
cond_duplicate: 'warn',
|
|
48
48
|
error_handling: 'warn',
|
|
49
|
-
global_naming: '
|
|
49
|
+
global_naming: 'info',
|
|
50
50
|
extra_parens: 'warn',
|
|
51
51
|
arg_count: 'warn',
|
|
52
52
|
builtin_arg_count: 'error',
|
|
53
|
-
strcat_usage: '
|
|
54
|
-
cond_simplify: '
|
|
55
|
-
quote_style: '
|
|
53
|
+
strcat_usage: 'info',
|
|
54
|
+
cond_simplify: 'info',
|
|
55
|
+
quote_style: 'info',
|
|
56
56
|
eq_usage: 'warn',
|
|
57
57
|
lambda_syntax: 'off',
|
|
58
|
-
comment_style: '
|
|
58
|
+
comment_style: 'info',
|
|
59
59
|
empty_catch: 'warn',
|
|
60
|
-
nth_usage: '
|
|
61
|
-
append_single: '
|
|
60
|
+
nth_usage: 'info',
|
|
61
|
+
append_single: 'info',
|
|
62
62
|
setq_multiple: 'warn',
|
|
63
|
-
mixed_indent: '
|
|
64
|
-
long_function_call: '
|
|
65
|
-
no_return: '
|
|
63
|
+
mixed_indent: 'info',
|
|
64
|
+
long_function_call: 'info',
|
|
65
|
+
no_return: 'info',
|
|
66
66
|
shadow_builtin: 'warn',
|
|
67
67
|
dynamic_doc: 'warn',
|
|
68
|
-
redundant_if: '
|
|
69
|
-
unused_catch_result: '
|
|
70
|
-
string_concat_loop: '
|
|
71
|
-
if_without_else: '
|
|
72
|
-
redundant_list: '
|
|
68
|
+
redundant_if: 'info',
|
|
69
|
+
unused_catch_result: 'info',
|
|
70
|
+
string_concat_loop: 'info',
|
|
71
|
+
if_without_else: 'info',
|
|
72
|
+
redundant_list: 'info',
|
|
73
73
|
entget_in_loop: 'warn',
|
|
74
|
-
promise_handler: '
|
|
74
|
+
promise_handler: 'info',
|
|
75
75
|
module_cycle: 'warn',
|
|
76
76
|
arg_count_project: 'warn',
|
|
77
77
|
},
|
|
@@ -103,7 +103,7 @@ exports.PRESETS = {
|
|
|
103
103
|
recursive_call: 'error',
|
|
104
104
|
variable_shadow: 'error',
|
|
105
105
|
unused_local_fun: 'error',
|
|
106
|
-
multiple_setq: '
|
|
106
|
+
multiple_setq: 'info',
|
|
107
107
|
redundant_quotes: 'error',
|
|
108
108
|
trailing_paren: 'error',
|
|
109
109
|
empty_comment: 'error',
|
package/dist/rules.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.generateRulesMarkdown = generateRulesMarkdown;
|
|
|
5
5
|
exports.RULES = [
|
|
6
6
|
{
|
|
7
7
|
name: 'append_single',
|
|
8
|
-
defaultSeverity: '
|
|
8
|
+
defaultSeverity: 'info',
|
|
9
9
|
description: '检测 (append (list ...)) 推荐使用 cons',
|
|
10
10
|
category: '风格',
|
|
11
11
|
},
|
|
@@ -34,9 +34,9 @@ exports.RULES = [
|
|
|
34
34
|
description: '检测 command shell 调用(命令注入风险)',
|
|
35
35
|
category: '安全',
|
|
36
36
|
},
|
|
37
|
-
{ name: 'comment_style', defaultSeverity: '
|
|
37
|
+
{ name: 'comment_style', defaultSeverity: 'info', description: '检测 ; 后缺少空格的注释', category: '风格' },
|
|
38
38
|
{ name: 'commented_code', defaultSeverity: 'warn', description: '检测被注释掉的代码', category: '风格' },
|
|
39
|
-
{ name: 'cond_simplify', defaultSeverity: '
|
|
39
|
+
{ name: 'cond_simplify', defaultSeverity: 'info', description: '检测可简化为 if 的单分支 cond', category: '风格' },
|
|
40
40
|
{
|
|
41
41
|
name: 'constant_condition',
|
|
42
42
|
defaultSeverity: 'warn',
|
|
@@ -53,7 +53,7 @@ exports.RULES = [
|
|
|
53
53
|
{ name: 'duplicate_defun', defaultSeverity: 'warn', description: '检测多次定义的函数名', category: '正确性' },
|
|
54
54
|
{
|
|
55
55
|
name: 'double_not',
|
|
56
|
-
defaultSeverity: '
|
|
56
|
+
defaultSeverity: 'info',
|
|
57
57
|
description: '检测双重 (not (not ...)) 可简化为单个 not',
|
|
58
58
|
category: '风格',
|
|
59
59
|
},
|
|
@@ -65,7 +65,7 @@ exports.RULES = [
|
|
|
65
65
|
description: '检测未检查结果的 vl-catch-all-apply',
|
|
66
66
|
category: '最佳实践',
|
|
67
67
|
},
|
|
68
|
-
{ name: 'empty_comment', defaultSeverity: '
|
|
68
|
+
{ name: 'empty_comment', defaultSeverity: 'info', description: '检测空注释行(只有分号没有内容)', category: '风格' },
|
|
69
69
|
{ name: 'encoding', defaultSeverity: 'error', description: '检查 UTF-8 BOM 和非 UTF-8 编码', category: '编码' },
|
|
70
70
|
{ name: 'eq_usage', defaultSeverity: 'warn', description: '检测 eq 与数字比较', category: '最佳实践' },
|
|
71
71
|
{
|
|
@@ -81,7 +81,7 @@ exports.RULES = [
|
|
|
81
81
|
description: '检查函数行数和嵌套深度是否超限',
|
|
82
82
|
category: '复杂度',
|
|
83
83
|
},
|
|
84
|
-
{ name: 'function_order', defaultSeverity: '
|
|
84
|
+
{ name: 'function_order', defaultSeverity: 'info', description: '检测函数定义在使用之后', category: '风格' },
|
|
85
85
|
{ name: 'format_indent', defaultSeverity: 'off', description: '检测代码缩进是否符合格式化规范', category: '风格' },
|
|
86
86
|
{
|
|
87
87
|
name: 'identical_branches',
|
|
@@ -89,53 +89,53 @@ exports.RULES = [
|
|
|
89
89
|
description: '检测 if 中 then 和 else 分支完全相同',
|
|
90
90
|
category: '正确性',
|
|
91
91
|
},
|
|
92
|
-
{ name: 'global_naming', defaultSeverity: '
|
|
92
|
+
{ name: 'global_naming', defaultSeverity: 'info', description: '检测全局变量是否使用 *...* 命名', category: '风格' },
|
|
93
93
|
{
|
|
94
94
|
name: 'lambda_syntax',
|
|
95
95
|
defaultSeverity: 'off',
|
|
96
96
|
description: '检测 (function (lambda ...)) 建议使用缩写',
|
|
97
97
|
category: '风格',
|
|
98
98
|
},
|
|
99
|
-
{ name: 'line_length', defaultSeverity: '
|
|
100
|
-
{ name: 'long_function_call', defaultSeverity: '
|
|
99
|
+
{ name: 'line_length', defaultSeverity: 'info', description: '检查行长度是否超过限制', category: '风格' },
|
|
100
|
+
{ name: 'long_function_call', defaultSeverity: 'info', description: '检测单行参数过多的函数调用', category: '风格' },
|
|
101
101
|
{
|
|
102
102
|
name: 'loop_optimization',
|
|
103
|
-
defaultSeverity: '
|
|
103
|
+
defaultSeverity: 'info',
|
|
104
104
|
description: '检测可优化的 while/assoc 循环',
|
|
105
105
|
category: '最佳实践',
|
|
106
106
|
},
|
|
107
|
-
{ name: 'magic_number', defaultSeverity: '
|
|
107
|
+
{ name: 'magic_number', defaultSeverity: 'info', description: '检测硬编码的魔法数字', category: '风格' },
|
|
108
108
|
{
|
|
109
109
|
name: 'misplaced_else',
|
|
110
|
-
defaultSeverity: '
|
|
110
|
+
defaultSeverity: 'info',
|
|
111
111
|
description: '检测 (if (not ...) ...) 建议交换分支',
|
|
112
112
|
category: '风格',
|
|
113
113
|
},
|
|
114
|
-
{ name: 'missing_doc', defaultSeverity: '
|
|
114
|
+
{ name: 'missing_doc', defaultSeverity: 'info', description: '检测缺少注释说明的函数', category: '风格' },
|
|
115
115
|
{ name: 'missing_export', defaultSeverity: 'warn', description: '检测函数未注册到 @::*modules*', category: '架构' },
|
|
116
|
-
{ name: 'mixed_indent', defaultSeverity: '
|
|
116
|
+
{ name: 'mixed_indent', defaultSeverity: 'info', description: '检测缩进中混用 tab 和空格', category: '风格' },
|
|
117
117
|
{
|
|
118
118
|
name: 'module_registration',
|
|
119
119
|
defaultSeverity: 'off',
|
|
120
120
|
description: '检测模块文件是否注册到 *modules*',
|
|
121
121
|
category: '架构',
|
|
122
122
|
},
|
|
123
|
-
{ name: 'multiple_setq', defaultSeverity: '
|
|
123
|
+
{ name: 'multiple_setq', defaultSeverity: 'info', description: '检测多个连续 setq 可以合并', category: '风格' },
|
|
124
124
|
{
|
|
125
125
|
name: 'namespace_header',
|
|
126
126
|
defaultSeverity: 'off',
|
|
127
127
|
description: '检测文件是否包含 (in-package ...) 头',
|
|
128
128
|
category: '架构',
|
|
129
129
|
},
|
|
130
|
-
{ name: 'no_return', defaultSeverity: '
|
|
131
|
-
{ name: 'nth_usage', defaultSeverity: '
|
|
130
|
+
{ name: 'no_return', defaultSeverity: 'info', description: '检测没有返回值的函数', category: '最佳实践' },
|
|
131
|
+
{ name: 'nth_usage', defaultSeverity: 'info', description: '检测 (nth 0 ...) 推荐使用 car', category: '风格' },
|
|
132
132
|
{
|
|
133
133
|
name: 'open_without_close',
|
|
134
134
|
defaultSeverity: 'warn',
|
|
135
135
|
description: '检测 open/close 数量不匹配(资源泄露)',
|
|
136
136
|
category: '最佳实践',
|
|
137
137
|
},
|
|
138
|
-
{ name: 'parameter_naming', defaultSeverity: '
|
|
138
|
+
{ name: 'parameter_naming', defaultSeverity: 'info', description: '检查参数名是否首字母大写', category: '风格' },
|
|
139
139
|
{ name: 'parens', defaultSeverity: 'error', description: '检查括号是否匹配(考虑字符串和注释)', category: '语法' },
|
|
140
140
|
{
|
|
141
141
|
name: 'quit_exit',
|
|
@@ -143,7 +143,7 @@ exports.RULES = [
|
|
|
143
143
|
description: '检测 quit/exit 调用(会终止 CAD 进程)',
|
|
144
144
|
category: '安全',
|
|
145
145
|
},
|
|
146
|
-
{ name: 'quote_style', defaultSeverity: '
|
|
146
|
+
{ name: 'quote_style', defaultSeverity: 'info', description: '检测 (quote ...) 建议使用缩写', category: '风格' },
|
|
147
147
|
{
|
|
148
148
|
name: 'quote_vs_function',
|
|
149
149
|
defaultSeverity: 'warn',
|
|
@@ -156,11 +156,11 @@ exports.RULES = [
|
|
|
156
156
|
description: '检测函数调用自身(可能无限递归)',
|
|
157
157
|
category: '正确性',
|
|
158
158
|
},
|
|
159
|
-
{ name: 'redundant_if', defaultSeverity: '
|
|
160
|
-
{ name: 'redundant_let', defaultSeverity: '
|
|
161
|
-
{ name: 'redundant_nil_else', defaultSeverity: '
|
|
162
|
-
{ name: 'redundant_progn', defaultSeverity: '
|
|
163
|
-
{ name: 'redundant_quotes', defaultSeverity: '
|
|
159
|
+
{ name: 'redundant_if', defaultSeverity: 'info', description: '检测 when/unless 中冗余 progn(when/unless 已隐含 progn)', category: '风格' },
|
|
160
|
+
{ name: 'redundant_let', defaultSeverity: 'info', description: '检测无绑定的 let 建议改用 progn', category: '风格' },
|
|
161
|
+
{ name: 'redundant_nil_else', defaultSeverity: 'info', description: '检测 if 中冗余的 nil 分支', category: '风格' },
|
|
162
|
+
{ name: 'redundant_progn', defaultSeverity: 'info', description: '检测分支中多余的 progn', category: '风格' },
|
|
163
|
+
{ name: 'redundant_quotes', defaultSeverity: 'info', description: "检测冗余双引号(如 ''x)", category: '风格' },
|
|
164
164
|
{ name: 'redundant_setq', defaultSeverity: 'warn', description: '检测 setq 变量赋值为自身', category: '风格' },
|
|
165
165
|
{
|
|
166
166
|
name: 'self_compare',
|
|
@@ -171,11 +171,11 @@ exports.RULES = [
|
|
|
171
171
|
{ name: 'setq_single_arg', defaultSeverity: 'warn', description: '检测 setq 只有变量名缺少值', category: '正确性' },
|
|
172
172
|
{ name: 'setq_multiple', defaultSeverity: 'warn', description: '检测多个连续 setq 可以合并', category: '风格' },
|
|
173
173
|
{ name: 'shadow_builtin', defaultSeverity: 'warn', description: '检测覆盖内置函数的 defun', category: '最佳实践' },
|
|
174
|
-
{ name: 'single_arg_and_or', defaultSeverity: '
|
|
174
|
+
{ name: 'single_arg_and_or', defaultSeverity: 'info', description: '检测单参数 and/or 建议简化', category: '风格' },
|
|
175
175
|
{ name: 'startapp', defaultSeverity: 'warn', description: '检测 startapp 调用(启动外部程序)', category: '安全' },
|
|
176
176
|
{
|
|
177
177
|
name: 'strcat_usage',
|
|
178
|
-
defaultSeverity: '
|
|
178
|
+
defaultSeverity: 'info',
|
|
179
179
|
description: '检测是否使用 + 而非 strcat 拼接字符串',
|
|
180
180
|
category: '最佳实践',
|
|
181
181
|
},
|
|
@@ -186,8 +186,8 @@ exports.RULES = [
|
|
|
186
186
|
category: '安全',
|
|
187
187
|
},
|
|
188
188
|
{ name: 'trailing_paren', defaultSeverity: 'warn', description: '检测多余闭合括号', category: '语法' },
|
|
189
|
-
{ name: 'trailing_whitespace', defaultSeverity: '
|
|
190
|
-
{ name: 'type_check', defaultSeverity: '
|
|
189
|
+
{ name: 'trailing_whitespace', defaultSeverity: 'info', description: '检测行尾多余空格', category: '风格' },
|
|
190
|
+
{ name: 'type_check', defaultSeverity: 'info', description: '检测 getvar 结果未做类型检查', category: '最佳实践' },
|
|
191
191
|
{
|
|
192
192
|
name: 'undeclared_setq',
|
|
193
193
|
defaultSeverity: 'warn',
|
|
@@ -228,12 +228,12 @@ exports.RULES = [
|
|
|
228
228
|
description: '检测 vlax-* 使用前未调用 vl-load-com',
|
|
229
229
|
category: '最佳实践',
|
|
230
230
|
},
|
|
231
|
-
{ name: 'unused_catch_result', defaultSeverity: '
|
|
232
|
-
{ name: 'string_concat_loop', defaultSeverity: '
|
|
233
|
-
{ name: 'if_without_else', defaultSeverity: '
|
|
234
|
-
{ name: 'redundant_list', defaultSeverity: '
|
|
231
|
+
{ name: 'unused_catch_result', defaultSeverity: 'info', description: '检测 vl-catch-all-apply 结果被当布尔值用', category: '正确性' },
|
|
232
|
+
{ name: 'string_concat_loop', defaultSeverity: 'info', description: '检测循环内字符串拼接', category: '性能' },
|
|
233
|
+
{ name: 'if_without_else', defaultSeverity: 'info', description: '检测 if 无 else 分支', category: '风格' },
|
|
234
|
+
{ name: 'redundant_list', defaultSeverity: 'info', description: '检测 (list) 等价于 nil', category: '风格' },
|
|
235
235
|
{ name: 'entget_in_loop', defaultSeverity: 'warn', description: '检测循环内 entget', category: '性能' },
|
|
236
|
-
{ name: 'promise_handler', defaultSeverity: '
|
|
236
|
+
{ name: 'promise_handler', defaultSeverity: 'info', description: '检测 vlax-invoke 缺少回调处理器', category: '最佳实践' },
|
|
237
237
|
{ name: 'module_cycle', defaultSeverity: 'warn', description: '检测模块循环依赖', category: '架构' },
|
|
238
238
|
{ name: 'arg_count_project', defaultSeverity: 'warn', description: '跨文件检查函数参数数量', category: '正确性' },
|
|
239
239
|
{ name: 'builtin_arg_count', defaultSeverity: 'error', description: '检查 AutoLISP 内置函数调用参数个数是否匹配', category: '正确性' },
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Severity = 'off' | 'warn' | 'error';
|
|
1
|
+
export type Severity = 'off' | 'info' | 'warn' | 'error';
|
|
2
2
|
export interface Fix {
|
|
3
3
|
range: [number, number];
|
|
4
4
|
replacement: string;
|
|
@@ -72,5 +72,6 @@ export interface FormattedResult {
|
|
|
72
72
|
issues: Issue[];
|
|
73
73
|
error_count: number;
|
|
74
74
|
warning_count: number;
|
|
75
|
+
info_count: number;
|
|
75
76
|
}
|
|
76
77
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/validate.js
CHANGED
|
@@ -86,7 +86,7 @@ const VALID_RULES = [
|
|
|
86
86
|
'module_cycle',
|
|
87
87
|
'arg_count_project',
|
|
88
88
|
];
|
|
89
|
-
const VALID_SEVERITIES = ['off', 'warn', 'error'];
|
|
89
|
+
const VALID_SEVERITIES = ['off', 'info', 'warn', 'error'];
|
|
90
90
|
function validateConfig(config) {
|
|
91
91
|
const errors = [];
|
|
92
92
|
if (config.locale && config.locale !== 'zh' && config.locale !== 'en') {
|