@abaplint/core 2.101.35 → 2.102.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.
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.101.35";
68
+ return "2.102.0";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -19,7 +19,7 @@ class CloudTypes {
19
19
  key: "cloud_types",
20
20
  title: "Check cloud types",
21
21
  shortDescription: `Checks that the package does not contain any object types unsupported in cloud ABAP.`,
22
- tags: [_irule_1.RuleTag.SingleFile],
22
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax],
23
23
  };
24
24
  }
25
25
  getDescription(objectType) {
@@ -15,6 +15,7 @@ class FunctionModuleRecommendationsConf extends _basic_rule_config_1.BasicRuleCo
15
15
  */
16
16
  this.recommendations = [
17
17
  { name: "CALCULATE_HASH_FOR_RAW", replace: "use CL_ABAP_HMAC or CL_ABAP_MESSAGE_DIGEST" },
18
+ { name: "CCU_TIMESTAMP_DIFFERENCE", replace: "use CL_ABAP_TSTMP" },
18
19
  { name: "ECATT_CONV_XSTRING_TO_STRING", replace: "use CL_BINARY_CONVERT" },
19
20
  { name: "F4_FILENAME", replace: "use CL_GUI_FRONTEND_SERVICES" },
20
21
  { name: "FUNCTION_EXISTS", replace: "surround with try-catch CX_SY_DYN_CALL_ILLEGAL_METHOD instead" },
@@ -122,6 +122,7 @@ __exportStar(require("./pragma_style"), exports);
122
122
  __exportStar(require("./prefer_corresponding"), exports);
123
123
  __exportStar(require("./prefer_inline"), exports);
124
124
  __exportStar(require("./prefer_is_not"), exports);
125
+ __exportStar(require("./prefer_pragmas"), exports);
125
126
  __exportStar(require("./prefer_raise_exception_new"), exports);
126
127
  __exportStar(require("./prefer_returning_to_exporting"), exports);
127
128
  __exportStar(require("./prefer_xsdbool"), exports);
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreferPragmas = exports.PreferPragmasConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const _abap_rule_1 = require("./_abap_rule");
6
+ const _basic_rule_config_1 = require("./_basic_rule_config");
7
+ const _irule_1 = require("./_irule");
8
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
9
+ class PreferPragmasConf extends _basic_rule_config_1.BasicRuleConfig {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.check = [
13
+ {
14
+ pseudo: "#EC CI_SUBRC",
15
+ pragma: "SUBRC_OK",
16
+ },
17
+ {
18
+ pseudo: "#EC NEEDED",
19
+ pragma: "NEEDED",
20
+ },
21
+ {
22
+ pseudo: "#EC NOTEXT",
23
+ pragma: "NO_TEXT",
24
+ },
25
+ {
26
+ pseudo: "#EC NO_HANDLER",
27
+ pragma: "NO_HANDLER",
28
+ },
29
+ ];
30
+ }
31
+ }
32
+ exports.PreferPragmasConf = PreferPragmasConf;
33
+ class PreferPragmas extends _abap_rule_1.ABAPRule {
34
+ constructor() {
35
+ super(...arguments);
36
+ this.conf = new PreferPragmasConf();
37
+ }
38
+ getMetadata() {
39
+ return {
40
+ key: "prefer_pragmas",
41
+ title: "prefer pragmas over pseudo comments ",
42
+ shortDescription: `prefer pragmas over pseudo comments `,
43
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-pragmas-to-pseudo-comments`,
44
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
45
+ };
46
+ }
47
+ getConfig() {
48
+ return this.conf;
49
+ }
50
+ setConfig(conf) {
51
+ this.conf = conf;
52
+ }
53
+ runParsed(file) {
54
+ const issues = [];
55
+ const config = this.getConfig();
56
+ for (const statement of file.getStatements()) {
57
+ if (!(statement.get() instanceof _statement_1.Comment)) {
58
+ continue;
59
+ }
60
+ const concat = statement.concatTokens().toUpperCase();
61
+ if (concat.includes("#EC") === false) {
62
+ continue;
63
+ }
64
+ for (const check of config.check) {
65
+ if (concat.includes(check.pseudo.toUpperCase())) {
66
+ const message = `Prefer pragma ${check.pragma}`;
67
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.getConfig().severity));
68
+ }
69
+ }
70
+ }
71
+ return issues;
72
+ }
73
+ }
74
+ exports.PreferPragmas = PreferPragmas;
75
+ //# sourceMappingURL=prefer_pragmas.js.map
@@ -33,7 +33,9 @@ class UnnecessaryPragma extends _abap_rule_1.ABAPRule {
33
33
 
34
34
  * NO_TEXT without texts
35
35
 
36
- * SUBRC_OK where sy-subrc is checked`,
36
+ * SUBRC_OK where sy-subrc is checked
37
+
38
+ NO_HANDLER inside macros are not checked`,
37
39
  tags: [_irule_1.RuleTag.SingleFile],
38
40
  badExample: `TRY.
39
41
  ...
@@ -164,6 +166,7 @@ ENDIF.`,
164
166
  }
165
167
  if (next
166
168
  && next.get() instanceof _statement_1.Comment
169
+ && !(statement.get() instanceof _statement_1.MacroContent)
167
170
  && next.concatTokens().toUpperCase().includes("#EC NO_HANDLER")) {
168
171
  return true;
169
172
  }
@@ -10,7 +10,6 @@ const edit_helper_1 = require("../edit_helper");
10
10
  class UnnecessaryReturnConf extends _basic_rule_config_1.BasicRuleConfig {
11
11
  }
12
12
  exports.UnnecessaryReturnConf = UnnecessaryReturnConf;
13
- // todo: make this rule more intelligent, eg RETURN. ENDTRY. ENDMETHOD.
14
13
  class UnnecessaryReturn extends _abap_rule_1.ABAPRule {
15
14
  constructor() {
16
15
  super(...arguments);
@@ -44,17 +43,27 @@ ENDFORM.`,
44
43
  if (structure === undefined) {
45
44
  return [];
46
45
  }
46
+ const message = "Unnecessary RETURN";
47
47
  const statements = file.getStatements();
48
- for (let i = 0; i < statements.length - 1; i++) {
48
+ for (let i = 0; i < statements.length; i++) {
49
49
  const node = statements[i];
50
- const next = statements[i + 1];
51
- if (node.get() instanceof Statements.Return
52
- && (next.get() instanceof Statements.EndMethod
53
- || next.get() instanceof Statements.EndForm
54
- || next.get() instanceof Statements.EndFunction)) {
55
- const message = "Unnecessary RETURN";
56
- const fix = edit_helper_1.EditHelper.deleteStatement(file, node);
57
- issues.push(issue_1.Issue.atStatement(file, node, message, this.getMetadata().key, this.getConfig().severity, fix));
50
+ if (!(node.get() instanceof Statements.EndMethod
51
+ || node.get() instanceof Statements.EndForm
52
+ || node.get() instanceof Statements.EndFunction)) {
53
+ continue;
54
+ }
55
+ const prev = statements[i - 1];
56
+ if (prev && prev.get() instanceof Statements.Return) {
57
+ const fix = edit_helper_1.EditHelper.deleteStatement(file, prev);
58
+ issues.push(issue_1.Issue.atStatement(file, prev, message, this.getMetadata().key, this.getConfig().severity, fix));
59
+ }
60
+ const prevprev = statements[i - 2];
61
+ if (prev && prevprev
62
+ && prevprev.get() instanceof Statements.Return
63
+ && (prev.get() instanceof Statements.EndIf
64
+ || prev.get() instanceof Statements.EndTry)) {
65
+ const fix = edit_helper_1.EditHelper.deleteStatement(file, prevprev);
66
+ issues.push(issue_1.Issue.atStatement(file, prevprev, message, this.getMetadata().key, this.getConfig().severity, fix));
58
67
  }
59
68
  }
60
69
  return issues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.101.35",
3
+ "version": "2.102.0",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,10 +50,10 @@
50
50
  },
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
- "@microsoft/api-extractor": "^7.36.1",
53
+ "@microsoft/api-extractor": "^7.36.2",
54
54
  "@types/chai": "^4.3.5",
55
55
  "@types/mocha": "^10.0.1",
56
- "@types/node": "^20.4.1",
56
+ "@types/node": "^20.4.2",
57
57
  "chai": "^4.3.7",
58
58
  "eslint": "^8.44.0",
59
59
  "mocha": "^10.2.0",