@abaplint/core 2.87.0 → 2.88.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.
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.87.0";
71
+ return "2.88.0";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -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
 
@@ -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("./check_no_handler_pragma"), exports);
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("./pragma_placement"), exports);
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);
@@ -1,23 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PragmaPlacement = exports.PragmaPlacementConf = void 0;
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
- class PragmaPlacementConf extends _basic_rule_config_1.BasicRuleConfig {
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.PragmaPlacementConf = PragmaPlacementConf;
11
- class PragmaPlacement extends _abap_rule_1.ABAPRule {
15
+ exports.PragmaStyleConf = PragmaStyleConf;
16
+ class PragmaStyle extends _abap_rule_1.ABAPRule {
12
17
  constructor() {
13
18
  super(...arguments);
14
- this.conf = new PragmaPlacementConf();
19
+ this.conf = new PragmaStyleConf();
15
20
  }
16
21
  getMetadata() {
17
22
  return {
18
- key: "pragma_placement",
19
- title: "Pragma Placement",
20
- shortDescription: `Place pragmas at end of statements`,
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.PragmaPlacement = PragmaPlacement;
56
- //# sourceMappingURL=pragma_placement.js.map
73
+ exports.PragmaStyle = PragmaStyle;
74
+ //# sourceMappingURL=pragma_style.js.map
@@ -49,7 +49,7 @@ class SlowParameterPassing {
49
49
  }
50
50
  const writes = this.listWritePositions(m, id);
51
51
  if (writes.length === 0) {
52
- const message = "Parameter passed by VALUE but not changed";
52
+ const message = "Parameter " + id.getName() + " passed by VALUE but not changed";
53
53
  issues.push(issue_1.Issue.atIdentifier(id, message, this.getMetadata().key, this.getConfig().severity));
54
54
  }
55
55
  }
@@ -0,0 +1,119 @@
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.MethodImplementation)
97
+ && !(statement.get() instanceof Statements.MethodDef)
98
+ && statement.findFirstExpression(Expressions.InlineFS) === undefined) {
99
+ const message = "There is no data definition, NEEDED can be removed";
100
+ return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
101
+ }
102
+ return [];
103
+ }
104
+ containsNoHandler(statement, next) {
105
+ for (const t of statement.getPragmas()) {
106
+ if (t.getStr().toUpperCase() === "##NO_HANDLER") {
107
+ return true;
108
+ }
109
+ }
110
+ if (next
111
+ && next.get() instanceof _statement_1.Comment
112
+ && next.concatTokens().toUpperCase().includes("#EC NO_HANDLER")) {
113
+ return true;
114
+ }
115
+ return false;
116
+ }
117
+ }
118
+ exports.UnnecessaryPragma = UnnecessaryPragma;
119
+ //# sourceMappingURL=unnecessary_pragma.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.87.0",
3
+ "version": "2.88.0",
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.0",
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