@abaplint/core 2.86.8 → 2.88.1
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/abaplint.d.ts +1 -0
- package/build/src/abap/types/method_parameters.js +8 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/global_class.js +2 -3
- package/build/src/rules/index.js +3 -2
- package/build/src/rules/{pragma_placement.js → pragma_style.js} +28 -10
- package/build/src/rules/slow_parameter_passing.js +85 -0
- package/build/src/rules/unnecessary_pragma.js +122 -0
- package/package.json +2 -2
- package/build/src/rules/check_no_handler_pragma.js +0 -81
package/build/abaplint.d.ts
CHANGED
|
@@ -2646,6 +2646,7 @@ export declare const enum IdentifierMeta {
|
|
|
2646
2646
|
EventParameter = "event_parameter",
|
|
2647
2647
|
FormParameter = "form_parameter",
|
|
2648
2648
|
ReadOnly = "read_only",
|
|
2649
|
+
PassByValue = "pass_by_value",
|
|
2649
2650
|
InlineDefinition = "inline",
|
|
2650
2651
|
BuiltIn = "built-in",
|
|
2651
2652
|
DDIC = "ddic",
|
|
@@ -163,7 +163,14 @@ class MethodParameters {
|
|
|
163
163
|
if (p === undefined) {
|
|
164
164
|
continue;
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
const extraMeta = [];
|
|
167
|
+
if (opt.concatTokens().toUpperCase().startsWith("VALUE(")) {
|
|
168
|
+
extraMeta.push("pass_by_value" /* PassByValue */);
|
|
169
|
+
}
|
|
170
|
+
else if (meta.includes("importing" /* MethodImporting */)) {
|
|
171
|
+
extraMeta.push("read_only" /* ReadOnly */);
|
|
172
|
+
}
|
|
173
|
+
target.push(new method_param_1.MethodParam().runSyntax(p, scope, this.filename, [...meta, ...extraMeta]));
|
|
167
174
|
if (opt.getLastToken().getStr().toUpperCase() === "OPTIONAL") {
|
|
168
175
|
const name = target[target.length - 1].getName().toUpperCase();
|
|
169
176
|
this.optional.push(name);
|
package/build/src/registry.js
CHANGED
|
@@ -18,9 +18,8 @@ class GlobalClass extends _abap_rule_1.ABAPRule {
|
|
|
18
18
|
return {
|
|
19
19
|
key: "global_class",
|
|
20
20
|
title: "Global class checks",
|
|
21
|
-
shortDescription: `Checks related to global classes
|
|
22
|
-
|
|
23
|
-
* global classes must be in own files
|
|
21
|
+
shortDescription: `Checks related to global classes`,
|
|
22
|
+
extendedInformation: `* global classes must be in own files
|
|
24
23
|
|
|
25
24
|
* file names must match class name
|
|
26
25
|
|
package/build/src/rules/index.js
CHANGED
|
@@ -30,7 +30,7 @@ __exportStar(require("./check_abstract"), exports);
|
|
|
30
30
|
__exportStar(require("./check_comments"), exports);
|
|
31
31
|
__exportStar(require("./check_ddic"), exports);
|
|
32
32
|
__exportStar(require("./check_include"), exports);
|
|
33
|
-
__exportStar(require("./
|
|
33
|
+
__exportStar(require("./unnecessary_pragma"), exports);
|
|
34
34
|
__exportStar(require("./check_subrc"), exports);
|
|
35
35
|
__exportStar(require("./check_syntax"), exports);
|
|
36
36
|
__exportStar(require("./check_text_elements"), exports);
|
|
@@ -110,7 +110,7 @@ __exportStar(require("./omit_receiving"), exports);
|
|
|
110
110
|
__exportStar(require("./parser_702_chaining"), exports);
|
|
111
111
|
__exportStar(require("./parser_error"), exports);
|
|
112
112
|
__exportStar(require("./parser_missing_space"), exports);
|
|
113
|
-
__exportStar(require("./
|
|
113
|
+
__exportStar(require("./pragma_style"), exports);
|
|
114
114
|
__exportStar(require("./prefer_corresponding"), exports);
|
|
115
115
|
__exportStar(require("./prefer_inline"), exports);
|
|
116
116
|
__exportStar(require("./prefer_is_not"), exports);
|
|
@@ -129,6 +129,7 @@ __exportStar(require("./selection_screen_naming"), exports);
|
|
|
129
129
|
__exportStar(require("./sequential_blank"), exports);
|
|
130
130
|
__exportStar(require("./short_case"), exports);
|
|
131
131
|
__exportStar(require("./sicf_consistency"), exports);
|
|
132
|
+
__exportStar(require("./slow_parameter_passing"), exports);
|
|
132
133
|
__exportStar(require("./space_before_colon"), exports);
|
|
133
134
|
__exportStar(require("./space_before_dot"), exports);
|
|
134
135
|
__exportStar(require("./sql_escape_host_variables"), exports);
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PragmaStyle = exports.PragmaStyleConf = void 0;
|
|
4
4
|
const issue_1 = require("../issue");
|
|
5
5
|
const _abap_rule_1 = require("./_abap_rule");
|
|
6
6
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
7
7
|
const _irule_1 = require("./_irule");
|
|
8
|
-
|
|
8
|
+
const keyword_case_1 = require("./keyword_case");
|
|
9
|
+
class PragmaStyleConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.style = keyword_case_1.KeywordCaseStyle.Upper;
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
|
-
exports.
|
|
11
|
-
class
|
|
15
|
+
exports.PragmaStyleConf = PragmaStyleConf;
|
|
16
|
+
class PragmaStyle extends _abap_rule_1.ABAPRule {
|
|
12
17
|
constructor() {
|
|
13
18
|
super(...arguments);
|
|
14
|
-
this.conf = new
|
|
19
|
+
this.conf = new PragmaStyleConf();
|
|
15
20
|
}
|
|
16
21
|
getMetadata() {
|
|
17
22
|
return {
|
|
18
|
-
key: "
|
|
19
|
-
title: "Pragma
|
|
20
|
-
shortDescription: `
|
|
23
|
+
key: "pragma_style",
|
|
24
|
+
title: "Pragma Style",
|
|
25
|
+
shortDescription: `Check pragmas placment and case`,
|
|
21
26
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
22
27
|
extendedInformation: `https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abenpragma.htm`,
|
|
23
28
|
badExample: `DATA field ##NO_TEXT TYPE i.`,
|
|
@@ -29,6 +34,9 @@ class PragmaPlacement extends _abap_rule_1.ABAPRule {
|
|
|
29
34
|
}
|
|
30
35
|
setConfig(conf) {
|
|
31
36
|
this.conf = conf;
|
|
37
|
+
if (this.conf.style === undefined) {
|
|
38
|
+
this.conf.style = keyword_case_1.KeywordCaseStyle.Upper;
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
runParsed(file) {
|
|
34
42
|
const issues = [];
|
|
@@ -47,10 +55,20 @@ class PragmaPlacement extends _abap_rule_1.ABAPRule {
|
|
|
47
55
|
issues.push(issue);
|
|
48
56
|
continue; // max one finding per statement
|
|
49
57
|
}
|
|
58
|
+
if (this.conf.style === keyword_case_1.KeywordCaseStyle.Upper && p.getStr() !== p.getStr().toUpperCase()) {
|
|
59
|
+
const message = "Upper case pragmas";
|
|
60
|
+
const issue = issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.conf.severity);
|
|
61
|
+
issues.push(issue);
|
|
62
|
+
}
|
|
63
|
+
else if (this.conf.style === keyword_case_1.KeywordCaseStyle.Lower && p.getStr() !== p.getStr().toLowerCase()) {
|
|
64
|
+
const message = "Lower case pragmas";
|
|
65
|
+
const issue = issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.conf.severity);
|
|
66
|
+
issues.push(issue);
|
|
67
|
+
}
|
|
50
68
|
}
|
|
51
69
|
}
|
|
52
70
|
return issues;
|
|
53
71
|
}
|
|
54
72
|
}
|
|
55
|
-
exports.
|
|
56
|
-
//# sourceMappingURL=
|
|
73
|
+
exports.PragmaStyle = PragmaStyle;
|
|
74
|
+
//# sourceMappingURL=pragma_style.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlowParameterPassing = exports.SlowParameterPassingConf = void 0;
|
|
4
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
5
|
+
const issue_1 = require("../issue");
|
|
6
|
+
const _irule_1 = require("./_irule");
|
|
7
|
+
const _abap_object_1 = require("../objects/_abap_object");
|
|
8
|
+
const syntax_1 = require("../abap/5_syntax/syntax");
|
|
9
|
+
const _scope_type_1 = require("../abap/5_syntax/_scope_type");
|
|
10
|
+
const _reference_1 = require("../abap/5_syntax/_reference");
|
|
11
|
+
class SlowParameterPassingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
12
|
+
}
|
|
13
|
+
exports.SlowParameterPassingConf = SlowParameterPassingConf;
|
|
14
|
+
class SlowParameterPassing {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.conf = new SlowParameterPassingConf();
|
|
17
|
+
}
|
|
18
|
+
getMetadata() {
|
|
19
|
+
return {
|
|
20
|
+
key: "slow_parameter_passing",
|
|
21
|
+
title: "Slow Parameter Passing",
|
|
22
|
+
shortDescription: `Detects show pass by value passing for methods where parameter is not changed`,
|
|
23
|
+
tags: [_irule_1.RuleTag.Performance],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
getConfig() {
|
|
27
|
+
return this.conf;
|
|
28
|
+
}
|
|
29
|
+
setConfig(conf) {
|
|
30
|
+
this.conf = conf;
|
|
31
|
+
}
|
|
32
|
+
initialize(reg) {
|
|
33
|
+
this.reg = reg;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
run(obj) {
|
|
37
|
+
const issues = [];
|
|
38
|
+
if (!(obj instanceof _abap_object_1.ABAPObject)) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const top = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop();
|
|
42
|
+
const methods = this.listMethodNodes(top);
|
|
43
|
+
for (const m of methods) {
|
|
44
|
+
const vars = m.getData().vars;
|
|
45
|
+
for (const v in vars) {
|
|
46
|
+
const id = vars[v];
|
|
47
|
+
if (id.getMeta().includes("pass_by_value" /* PassByValue */) === false) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const writes = this.listWritePositions(m, id);
|
|
51
|
+
if (writes.length === 0) {
|
|
52
|
+
const message = "Parameter " + id.getName() + " passed by VALUE but not changed";
|
|
53
|
+
issues.push(issue_1.Issue.atIdentifier(id, message, this.getMetadata().key, this.getConfig().severity));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return issues;
|
|
58
|
+
}
|
|
59
|
+
listWritePositions(node, id) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const ret = [];
|
|
62
|
+
for (const v of node.getData().references) {
|
|
63
|
+
if (v.referenceType === _reference_1.ReferenceType.DataWriteReference
|
|
64
|
+
&& ((_a = v.resolved) === null || _a === void 0 ? void 0 : _a.getFilename()) === id.getFilename()
|
|
65
|
+
&& ((_b = v.resolved) === null || _b === void 0 ? void 0 : _b.getStart().equals(id.getStart()))) {
|
|
66
|
+
ret.push(v.position.getStart());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return ret;
|
|
70
|
+
}
|
|
71
|
+
listMethodNodes(node) {
|
|
72
|
+
const ret = [];
|
|
73
|
+
if (node.getIdentifier().stype === _scope_type_1.ScopeType.Method) {
|
|
74
|
+
ret.push(node);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (const c of node.getChildren()) {
|
|
78
|
+
ret.push(...this.listMethodNodes(c));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return ret;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.SlowParameterPassing = SlowParameterPassing;
|
|
85
|
+
//# sourceMappingURL=slow_parameter_passing.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnnecessaryPragma = exports.UnnecessaryPragmaConf = void 0;
|
|
4
|
+
const issue_1 = require("../issue");
|
|
5
|
+
const Statements = require("../abap/2_statements/statements");
|
|
6
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
7
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
8
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
9
|
+
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
10
|
+
const _irule_1 = require("./_irule");
|
|
11
|
+
class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
12
|
+
}
|
|
13
|
+
exports.UnnecessaryPragmaConf = UnnecessaryPragmaConf;
|
|
14
|
+
class UnnecessaryPragma extends _abap_rule_1.ABAPRule {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.conf = new UnnecessaryPragmaConf();
|
|
18
|
+
}
|
|
19
|
+
getMetadata() {
|
|
20
|
+
return {
|
|
21
|
+
key: "unnecessary_pragma",
|
|
22
|
+
title: "Unnecessary Pragma",
|
|
23
|
+
shortDescription: `Finds pragmas which can be removed`,
|
|
24
|
+
extendedInformation: `* NO_HANDLER with handler
|
|
25
|
+
|
|
26
|
+
* NEEDED without definition
|
|
27
|
+
|
|
28
|
+
* NO_TEXT without texts`,
|
|
29
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
30
|
+
badExample: `TRY.
|
|
31
|
+
...
|
|
32
|
+
CATCH zcx_abapgit_exception ##NO_HANDLER.
|
|
33
|
+
RETURN. " it has a handler
|
|
34
|
+
ENDTRY.
|
|
35
|
+
MESSAGE w125(zbar) WITH c_foo INTO message ##NEEDED ##NO_TEXT.`,
|
|
36
|
+
goodExample: `TRY.
|
|
37
|
+
...
|
|
38
|
+
CATCH zcx_abapgit_exception.
|
|
39
|
+
RETURN.
|
|
40
|
+
ENDTRY.
|
|
41
|
+
MESSAGE w125(zbar) WITH c_foo INTO message.`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getConfig() {
|
|
45
|
+
return this.conf;
|
|
46
|
+
}
|
|
47
|
+
setConfig(conf) {
|
|
48
|
+
this.conf = conf;
|
|
49
|
+
}
|
|
50
|
+
runParsed(file) {
|
|
51
|
+
const issues = [];
|
|
52
|
+
let noHandler = false;
|
|
53
|
+
const statements = file.getStatements();
|
|
54
|
+
for (let i = 0; i < statements.length; i++) {
|
|
55
|
+
const statement = statements[i];
|
|
56
|
+
if (statement.get() instanceof Statements.EndTry) {
|
|
57
|
+
noHandler = false;
|
|
58
|
+
}
|
|
59
|
+
else if (statement.get() instanceof _statement_1.Comment) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
else if (noHandler === true && !(statement.get() instanceof Statements.Catch)) {
|
|
63
|
+
const message = "NO_HANDLER pragma or pseudo comment can be removed";
|
|
64
|
+
const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity);
|
|
65
|
+
issues.push(issue);
|
|
66
|
+
noHandler = false;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
noHandler = this.containsNoHandler(statement, statements[i + 1]);
|
|
70
|
+
}
|
|
71
|
+
issues.push(...this.checkText(statement, file));
|
|
72
|
+
issues.push(...this.checkNeeded(statement, file));
|
|
73
|
+
}
|
|
74
|
+
return issues;
|
|
75
|
+
}
|
|
76
|
+
checkText(statement, file) {
|
|
77
|
+
const p = statement.getPragmas().find(t => t.getStr().toUpperCase() === "##NO_TEXT");
|
|
78
|
+
if (p === undefined) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
if (statement.findFirstExpression(Expressions.ConstantString) === undefined
|
|
82
|
+
&& statement.findFirstExpression(Expressions.StringTemplate) === undefined) {
|
|
83
|
+
const message = "There is no text, NO_TEXT can be removed";
|
|
84
|
+
return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
|
|
85
|
+
}
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
checkNeeded(statement, file) {
|
|
89
|
+
const p = statement.getPragmas().find(t => t.getStr().toUpperCase() === "##NEEDED");
|
|
90
|
+
if (p === undefined) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
if (statement.findFirstExpression(Expressions.InlineData) === undefined
|
|
94
|
+
&& !(statement.get() instanceof Statements.Parameter)
|
|
95
|
+
&& !(statement.get() instanceof Statements.Data)
|
|
96
|
+
&& !(statement.get() instanceof Statements.Type)
|
|
97
|
+
&& !(statement.get() instanceof Statements.Constant)
|
|
98
|
+
&& !(statement.get() instanceof Statements.TypeEnum)
|
|
99
|
+
&& !(statement.get() instanceof Statements.MethodImplementation)
|
|
100
|
+
&& !(statement.get() instanceof Statements.MethodDef)
|
|
101
|
+
&& statement.findFirstExpression(Expressions.InlineFS) === undefined) {
|
|
102
|
+
const message = "There is no data definition, NEEDED can be removed";
|
|
103
|
+
return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
containsNoHandler(statement, next) {
|
|
108
|
+
for (const t of statement.getPragmas()) {
|
|
109
|
+
if (t.getStr().toUpperCase() === "##NO_HANDLER") {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (next
|
|
114
|
+
&& next.get() instanceof _statement_1.Comment
|
|
115
|
+
&& next.concatTokens().toUpperCase().includes("#EC NO_HANDLER")) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.UnnecessaryPragma = UnnecessaryPragma;
|
|
122
|
+
//# sourceMappingURL=unnecessary_pragma.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.88.1",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://abaplint.org",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@microsoft/api-extractor": "^7.20.
|
|
48
|
+
"@microsoft/api-extractor": "^7.20.1",
|
|
49
49
|
"@types/chai": "^4.3.0",
|
|
50
50
|
"@types/mocha": "^9.1.0",
|
|
51
51
|
"@types/node": "^17.0.23",
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CheckNoHandlerPragma = exports.CheckNoHandlerPragmaConf = void 0;
|
|
4
|
-
const issue_1 = require("../issue");
|
|
5
|
-
const Statements = require("../abap/2_statements/statements");
|
|
6
|
-
const _abap_rule_1 = require("./_abap_rule");
|
|
7
|
-
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
8
|
-
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
9
|
-
const _irule_1 = require("./_irule");
|
|
10
|
-
class CheckNoHandlerPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
11
|
-
}
|
|
12
|
-
exports.CheckNoHandlerPragmaConf = CheckNoHandlerPragmaConf;
|
|
13
|
-
class CheckNoHandlerPragma extends _abap_rule_1.ABAPRule {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.conf = new CheckNoHandlerPragmaConf();
|
|
17
|
-
}
|
|
18
|
-
getMetadata() {
|
|
19
|
-
return {
|
|
20
|
-
key: "check_no_handler_pragma",
|
|
21
|
-
title: "Check if NO_HANDLER can be removed",
|
|
22
|
-
shortDescription: `Checks NO_HANDLER pragmas that can be removed`,
|
|
23
|
-
tags: [_irule_1.RuleTag.SingleFile],
|
|
24
|
-
badExample: `TRY.
|
|
25
|
-
...
|
|
26
|
-
CATCH zcx_abapgit_exception ##NO_HANDLER.
|
|
27
|
-
RETURN. " it has a handler
|
|
28
|
-
ENDTRY.`,
|
|
29
|
-
goodExample: `TRY.
|
|
30
|
-
...
|
|
31
|
-
CATCH zcx_abapgit_exception.
|
|
32
|
-
RETURN.
|
|
33
|
-
ENDTRY.`,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
getConfig() {
|
|
37
|
-
return this.conf;
|
|
38
|
-
}
|
|
39
|
-
setConfig(conf) {
|
|
40
|
-
this.conf = conf;
|
|
41
|
-
}
|
|
42
|
-
runParsed(file) {
|
|
43
|
-
const issues = [];
|
|
44
|
-
let noHandler = false;
|
|
45
|
-
const statements = file.getStatements();
|
|
46
|
-
for (let i = 0; i < statements.length; i++) {
|
|
47
|
-
const statement = statements[i];
|
|
48
|
-
if (statement.get() instanceof Statements.EndTry) {
|
|
49
|
-
noHandler = false;
|
|
50
|
-
}
|
|
51
|
-
else if (statement.get() instanceof _statement_1.Comment) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
else if (noHandler === true && !(statement.get() instanceof Statements.Catch)) {
|
|
55
|
-
const message = "NO_HANDLER pragma or pseudo comment can be removed";
|
|
56
|
-
const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity);
|
|
57
|
-
issues.push(issue);
|
|
58
|
-
noHandler = false;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
noHandler = this.containsNoHandler(statement, statements[i + 1]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return issues;
|
|
65
|
-
}
|
|
66
|
-
containsNoHandler(statement, next) {
|
|
67
|
-
for (const t of statement.getPragmas()) {
|
|
68
|
-
if (t.getStr().toUpperCase() === "##NO_HANDLER") {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (next
|
|
73
|
-
&& next.get() instanceof _statement_1.Comment
|
|
74
|
-
&& next.concatTokens().toUpperCase().includes("#EC NO_HANDLER")) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.CheckNoHandlerPragma = CheckNoHandlerPragma;
|
|
81
|
-
//# sourceMappingURL=check_no_handler_pragma.js.map
|