@abaplint/core 2.80.10 → 2.81.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.
@@ -10,9 +10,10 @@ class Move {
10
10
  const mov = (0, combi_1.verNot)(version_1.Version.Cloud, "MOVE");
11
11
  const move = (0, combi_1.seq)(mov, (0, combi_1.altPrio)((0, combi_1.seq)("EXACT", expressions_1.Source, "TO", expressions_1.Target), (0, combi_1.seq)(expressions_1.Source, (0, combi_1.altPrio)("?TO", "TO"), expressions_1.Target)));
12
12
  const calcAssign = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.WPlus), "="), (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WDash), "="), "/=", "*=", "&&="));
13
- const equals = (0, combi_1.altPrio)((0, combi_1.altPrio)("=", "?="), calcAssign);
13
+ const chained = (0, combi_1.seq)("=", (0, combi_1.star)((0, combi_1.seq)(expressions_1.Target, "=")));
14
+ const equals = (0, combi_1.altPrio)((0, combi_1.altPrio)(chained, "?="), calcAssign);
14
15
  // todo, move "?=" to CAST?
15
- const eq = (0, combi_1.seq)((0, combi_1.plus)((0, combi_1.seq)(expressions_1.Target, equals)), expressions_1.Source);
16
+ const eq = (0, combi_1.seq)(expressions_1.Target, equals, expressions_1.Source);
16
17
  return (0, combi_1.altPrio)(move, eq);
17
18
  }
18
19
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.80.10";
71
+ return "2.81.0";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -92,6 +92,7 @@ __exportStar(require("./msag_consistency"), exports);
92
92
  __exportStar(require("./names_no_dash"), exports);
93
93
  __exportStar(require("./nesting"), exports);
94
94
  __exportStar(require("./newline_between_methods"), exports);
95
+ __exportStar(require("./no_chained_assignment"), exports);
95
96
  __exportStar(require("./no_public_attributes"), exports);
96
97
  __exportStar(require("./no_yoda_conditions"), exports);
97
98
  __exportStar(require("./object_naming"), exports);
@@ -131,6 +132,7 @@ __exportStar(require("./type_form_parameters"), exports);
131
132
  __exportStar(require("./types_naming"), exports);
132
133
  __exportStar(require("./uncaught_exception"), exports);
133
134
  __exportStar(require("./unknown_types"), exports);
135
+ __exportStar(require("./unnecessary_chaining"), exports);
134
136
  __exportStar(require("./unreachable_code"), exports);
135
137
  __exportStar(require("./unsecure_fae"), exports);
136
138
  __exportStar(require("./unused_ddic"), exports);
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoChainedAssignment = exports.NoChainedAssignmentConf = void 0;
4
+ const Expressions = require("../abap/2_statements/expressions");
5
+ const Statements = require("../abap/2_statements/statements");
6
+ const issue_1 = require("../issue");
7
+ const _abap_rule_1 = require("./_abap_rule");
8
+ const _basic_rule_config_1 = require("./_basic_rule_config");
9
+ const _irule_1 = require("./_irule");
10
+ class NoChainedAssignmentConf extends _basic_rule_config_1.BasicRuleConfig {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.onlyConstants = false;
14
+ }
15
+ }
16
+ exports.NoChainedAssignmentConf = NoChainedAssignmentConf;
17
+ class NoChainedAssignment extends _abap_rule_1.ABAPRule {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.conf = new NoChainedAssignmentConf();
21
+ }
22
+ getMetadata() {
23
+ return {
24
+ key: "no_chained_assignment",
25
+ title: "No chained assignment",
26
+ shortDescription: `Find chained assingments and reports issues`,
27
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-chain-assignments`,
28
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
29
+ badExample: `var1 = var2 = var3.`,
30
+ goodExample: `var2 = var3.
31
+ var1 = var3.`,
32
+ };
33
+ }
34
+ getConfig() {
35
+ return this.conf;
36
+ }
37
+ setConfig(conf) {
38
+ this.conf = conf;
39
+ }
40
+ runParsed(file) {
41
+ const issues = [];
42
+ for (const s of file.getStatements()) {
43
+ if (!(s.get() instanceof Statements.Move)) {
44
+ continue;
45
+ }
46
+ if (s.findDirectExpressions(Expressions.Target).length >= 2) {
47
+ const message = "No chained assignment";
48
+ const issue = issue_1.Issue.atStatement(file, s, message, this.getMetadata().key);
49
+ issues.push(issue);
50
+ }
51
+ }
52
+ return issues;
53
+ }
54
+ }
55
+ exports.NoChainedAssignment = NoChainedAssignment;
56
+ //# sourceMappingURL=no_chained_assignment.js.map
@@ -74,7 +74,7 @@ DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 10
74
74
  }
75
75
  ///////////////////////////
76
76
  analyzeScope(node, obj) {
77
- var _a;
77
+ var _a, _b;
78
78
  const ret = [];
79
79
  const vars = node.getData().vars;
80
80
  for (const name in vars) {
@@ -113,7 +113,8 @@ DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 10
113
113
  || statementType instanceof Statements.Catch
114
114
  || statementType instanceof Statements.ReadTable
115
115
  || statementType instanceof Statements.Loop)
116
- || ((_a = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _a === void 0 ? void 0 : _a.includes("?="))) {
116
+ || ((_a = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _a === void 0 ? void 0 : _a.includes("?="))
117
+ || ((_b = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _b === void 0 ? void 0 : _b.includes(" #("))) {
117
118
  continue;
118
119
  }
119
120
  const statement = edit_helper_1.EditHelper.findStatement(identifier.getToken(), file);
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnnecessaryChaining = exports.UnnecessaryChainingConf = 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
+ class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.onlyConstants = false;
12
+ }
13
+ }
14
+ exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
15
+ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.conf = new UnnecessaryChainingConf();
19
+ }
20
+ getMetadata() {
21
+ return {
22
+ key: "unnecessary_chaining",
23
+ title: "Unnecessary Chaining",
24
+ shortDescription: `Find unnecessary chaining, all statements are checked`,
25
+ extendedInformation: ``,
26
+ tags: [_irule_1.RuleTag.SingleFile],
27
+ badExample: `WRITE: bar.`,
28
+ goodExample: `WRITE bar.`,
29
+ };
30
+ }
31
+ getConfig() {
32
+ return this.conf;
33
+ }
34
+ setConfig(conf) {
35
+ this.conf = conf;
36
+ }
37
+ runParsed(file) {
38
+ var _a, _b;
39
+ const issues = [];
40
+ const statements = file.getStatements();
41
+ for (let i = 0; i < statements.length; i++) {
42
+ const colon = statements[i].getColon();
43
+ if (colon === undefined) {
44
+ continue;
45
+ }
46
+ const next = (_a = statements[i + 1]) === null || _a === void 0 ? void 0 : _a.getColon();
47
+ const prev = (_b = statements[i - 1]) === null || _b === void 0 ? void 0 : _b.getColon();
48
+ if (next !== undefined && colon.getStart().equals(next.getStart())) {
49
+ continue;
50
+ }
51
+ else if (prev !== undefined && colon.getStart().equals(prev.getStart())) {
52
+ continue;
53
+ }
54
+ const message = "Unnecessary chaining";
55
+ const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key);
56
+ issues.push(issue);
57
+ }
58
+ return issues;
59
+ }
60
+ }
61
+ exports.UnnecessaryChaining = UnnecessaryChaining;
62
+ //# sourceMappingURL=unnecessary_chaining.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.80.10",
3
+ "version": "2.81.0",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -13,6 +13,7 @@
13
13
  "test:parallel": "npm run compile && mocha --timeout 1000 --parallel --reporter dot",
14
14
  "coverage": "npm run compile && c8 mocha && c8 report --reporter=html",
15
15
  "schema": "node scripts/schema.js > scripts/schema.ts && ts-json-schema-generator --tsconfig tsconfig_schema.json --jsDoc extended --path scripts/schema.ts > scripts/schema.json && node scripts/schema_post.js",
16
+ "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
16
17
  "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public"
17
18
  },
18
19
  "mocha": {