@abaplint/core 2.106.7 → 2.106.9
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/build/src/abap/5_syntax/expressions/select.js +8 -4
- package/build/src/abap/5_syntax/expressions/sql_compare.js +7 -2
- package/build/src/registry.js +1 -1
- package/build/src/rules/no_prefixes.js +11 -4
- package/build/src/rules/unused_methods.js +22 -0
- package/build/src/rules/unused_types.js +22 -0
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ const _scope_type_1 = require("../_scope_type");
|
|
|
11
11
|
const sql_source_1 = require("./sql_source");
|
|
12
12
|
const sql_compare_1 = require("./sql_compare");
|
|
13
13
|
const sql_order_by_1 = require("./sql_order_by");
|
|
14
|
+
const dynamic_1 = require("./dynamic");
|
|
14
15
|
const isSimple = /^\w+$/;
|
|
15
16
|
class Select {
|
|
16
17
|
runSyntax(node, scope, filename, skipImplicitInto = false) {
|
|
@@ -21,7 +22,7 @@ class Select {
|
|
|
21
22
|
if (from === undefined) {
|
|
22
23
|
throw new Error(`Missing FROM`);
|
|
23
24
|
}
|
|
24
|
-
const fields = this.findFields(node);
|
|
25
|
+
const fields = this.findFields(node, scope, filename);
|
|
25
26
|
if (fields.length === 0
|
|
26
27
|
&& node.findDirectExpression(Expressions.SQLFieldListLoop) === undefined) {
|
|
27
28
|
throw new Error(`fields missing`);
|
|
@@ -179,17 +180,20 @@ class Select {
|
|
|
179
180
|
}
|
|
180
181
|
return new basic_1.VoidType("SELECT_todo");
|
|
181
182
|
}
|
|
182
|
-
findFields(node) {
|
|
183
|
-
var _a;
|
|
183
|
+
findFields(node, scope, filename) {
|
|
184
|
+
var _a, _b;
|
|
184
185
|
let expr = undefined;
|
|
185
186
|
const ret = [];
|
|
186
187
|
expr = node.findFirstExpression(Expressions.SQLFieldList);
|
|
187
188
|
if (expr === undefined) {
|
|
188
189
|
expr = node.findDirectExpression(Expressions.SQLFieldListLoop);
|
|
189
190
|
}
|
|
191
|
+
if (((_a = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dynamic) {
|
|
192
|
+
new dynamic_1.Dynamic().runSyntax(expr.getFirstChild(), scope, filename);
|
|
193
|
+
}
|
|
190
194
|
for (const field of (expr === null || expr === void 0 ? void 0 : expr.findDirectExpressionsMulti([Expressions.SQLField, Expressions.SQLFieldName])) || []) {
|
|
191
195
|
let code = field.concatTokens().toUpperCase();
|
|
192
|
-
const as = ((
|
|
196
|
+
const as = ((_b = field.findDirectExpression(Expressions.SQLAsName)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
|
|
193
197
|
if (as !== "") {
|
|
194
198
|
code = code.replace(" AS " + as, "");
|
|
195
199
|
}
|
|
@@ -4,13 +4,18 @@ exports.SQLCompare = void 0;
|
|
|
4
4
|
const Expressions = require("../../2_statements/expressions");
|
|
5
5
|
const nodes_1 = require("../../nodes");
|
|
6
6
|
const basic_1 = require("../../types/basic");
|
|
7
|
+
const dynamic_1 = require("./dynamic");
|
|
7
8
|
const source_1 = require("./source");
|
|
8
9
|
const sql_source_1 = require("./sql_source");
|
|
9
10
|
class SQLCompare {
|
|
10
11
|
runSyntax(node, scope, filename, tables) {
|
|
11
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
12
13
|
let sourceType;
|
|
13
14
|
let token;
|
|
15
|
+
if (((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dynamic) {
|
|
16
|
+
new dynamic_1.Dynamic().runSyntax(node.getFirstChild(), scope, filename);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
14
19
|
for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
|
|
15
20
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
16
21
|
}
|
|
@@ -36,7 +41,7 @@ class SQLCompare {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
|
-
const fieldName = (
|
|
44
|
+
const fieldName = (_b = node.findDirectExpression(Expressions.SQLFieldName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
40
45
|
if (fieldName && sourceType && token) {
|
|
41
46
|
// check compatibility for rule sql_value_conversion
|
|
42
47
|
const targetType = this.findType(fieldName, tables, scope);
|
package/build/src/registry.js
CHANGED
|
@@ -22,6 +22,7 @@ class NoPrefixesConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
22
22
|
this.types = "^TY_";
|
|
23
23
|
/** importing, exporting, returning and changing parameters, case insensitive regex */
|
|
24
24
|
this.methodParameters = "^[ICER].?_";
|
|
25
|
+
this.allowIsPrefixBoolean = true;
|
|
25
26
|
// todo, public localClass: string = "";
|
|
26
27
|
// todo, public localInterface: string = "";
|
|
27
28
|
// todo, public functionModuleParameters: string = "";
|
|
@@ -166,12 +167,18 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/sub-sections/AvoidEncodi
|
|
|
166
167
|
return ret;
|
|
167
168
|
}
|
|
168
169
|
checkMethodParameters(topNode, regex, file) {
|
|
170
|
+
var _a, _b;
|
|
169
171
|
const ret = [];
|
|
170
172
|
for (const method of topNode.findAllStatements(Statements.MethodDef)) {
|
|
171
|
-
for (const
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
for (const param of method.findAllExpressionsMulti([Expressions.MethodDefReturning, Expressions.MethodParam])) {
|
|
174
|
+
const nameToken = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.MethodParamName);
|
|
175
|
+
const type = (_b = (_a = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.TypeParam)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
176
|
+
if (this.getConfig().allowIsPrefixBoolean === true && (type === null || type === void 0 ? void 0 : type.endsWith("TYPE ABAP_BOOL"))) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.concatTokens();
|
|
180
|
+
if (nameToken && name && name !== "" && name.match(regex)) {
|
|
181
|
+
const issue = issue_1.Issue.atToken(file, nameToken.getFirstToken(), MESSAGE, this.getMetadata().key, this.conf.severity);
|
|
175
182
|
ret.push(issue);
|
|
176
183
|
}
|
|
177
184
|
}
|
|
@@ -70,6 +70,7 @@ Skips:
|
|
|
70
70
|
`,
|
|
71
71
|
tags: [],
|
|
72
72
|
pragma: "##CALLED",
|
|
73
|
+
pseudoComment: "EC CALLED",
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
76
|
getConfig() {
|
|
@@ -146,11 +147,32 @@ Skips:
|
|
|
146
147
|
if (statement.getPragmas().some(t => t.getStr() === this.getMetadata().pragma)) {
|
|
147
148
|
continue;
|
|
148
149
|
}
|
|
150
|
+
else if (this.suppressedbyPseudo(statement, file)) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
149
153
|
const message = "Method \"" + i.identifier.getName() + "\" not used";
|
|
150
154
|
issues.push(issue_1.Issue.atIdentifier(i.identifier, message, this.getMetadata().key, this.conf.severity));
|
|
151
155
|
}
|
|
152
156
|
return issues;
|
|
153
157
|
}
|
|
158
|
+
suppressedbyPseudo(statement, file) {
|
|
159
|
+
if (statement === undefined) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if (file === undefined) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
let next = false;
|
|
166
|
+
for (const s of file.getStatements()) {
|
|
167
|
+
if (next === true && s.get() instanceof _statement_1.Comment) {
|
|
168
|
+
return s.concatTokens().includes(this.getMetadata().pseudoComment + "");
|
|
169
|
+
}
|
|
170
|
+
if (s === statement) {
|
|
171
|
+
next = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
154
176
|
searchGlobalSubclasses(obj) {
|
|
155
177
|
var _a, _b;
|
|
156
178
|
if (this.wa.getLength() === 0
|
|
@@ -59,6 +59,7 @@ class UnusedTypes {
|
|
|
59
59
|
extendedInformation: `Unused types are not reported if the object contains parser or syntax errors.`,
|
|
60
60
|
tags: [_irule_1.RuleTag.Quickfix],
|
|
61
61
|
pragma: "##NEEDED",
|
|
62
|
+
pseudoComment: "EC NEEDED",
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
getConfig() {
|
|
@@ -126,11 +127,32 @@ class UnusedTypes {
|
|
|
126
127
|
if (statement.getPragmas().some(t => t.getStr() === this.getMetadata().pragma)) {
|
|
127
128
|
continue;
|
|
128
129
|
}
|
|
130
|
+
else if (this.suppressedbyPseudo(statement, file)) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
129
133
|
const fix = this.buildFix(file, statement);
|
|
130
134
|
ret.push(issue_1.Issue.atIdentifier(t, message, this.getMetadata().key, this.conf.severity, fix));
|
|
131
135
|
}
|
|
132
136
|
return ret;
|
|
133
137
|
}
|
|
138
|
+
suppressedbyPseudo(statement, file) {
|
|
139
|
+
if (statement === undefined) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
if (file === undefined) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
let next = false;
|
|
146
|
+
for (const s of file.getStatements()) {
|
|
147
|
+
if (next === true && s.get() instanceof _statement_1.Comment) {
|
|
148
|
+
return s.concatTokens().includes(this.getMetadata().pseudoComment + "");
|
|
149
|
+
}
|
|
150
|
+
if (s === statement) {
|
|
151
|
+
next = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
134
156
|
////////////////////////////
|
|
135
157
|
traverse(node, obj, add) {
|
|
136
158
|
if (node.getIdentifier().stype !== _scope_type_1.ScopeType.BuiltIn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.106.
|
|
3
|
+
"version": "2.106.9",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"mocha": "^10.4.0",
|
|
60
60
|
"c8": "^9.1.0",
|
|
61
61
|
"source-map-support": "^0.5.21",
|
|
62
|
-
"ts-json-schema-generator": "
|
|
62
|
+
"ts-json-schema-generator": "=2.0.1",
|
|
63
63
|
"typescript": "^5.4.5"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|