@abaplint/core 2.120.58 → 2.120.59

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.
@@ -162,6 +162,11 @@ class Source {
162
162
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
163
163
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
164
164
  }
165
+ if ((foundType === null || foundType === void 0 ? void 0 : foundType.isGeneric()) && bodyType !== undefined) {
166
+ this.addIfInferred(node, input, bodyType);
167
+ this.traverseRemainingChildren(children, input);
168
+ return bodyType;
169
+ }
165
170
  this.addIfInferred(node, input, foundType);
166
171
  this.traverseRemainingChildren(children, input);
167
172
  return foundType;
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.58";
78
+ return "2.120.59";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -191,6 +191,7 @@ __exportStar(require("./types_naming"), exports);
191
191
  __exportStar(require("./uncaught_exception"), exports);
192
192
  __exportStar(require("./unknown_types"), exports);
193
193
  __exportStar(require("./unnecessary_chaining"), exports);
194
+ __exportStar(require("./unnecessary_loop_guard"), exports);
194
195
  __exportStar(require("./unnecessary_pragma"), exports);
195
196
  __exportStar(require("./unnecessary_return"), exports);
196
197
  __exportStar(require("./unreachable_code"), exports);
@@ -203,6 +204,7 @@ __exportStar(require("./unused_variables"), exports);
203
204
  __exportStar(require("./use_bool_expression"), exports);
204
205
  __exportStar(require("./use_class_based_exceptions"), exports);
205
206
  __exportStar(require("./use_line_exists"), exports);
207
+ __exportStar(require("./use_message_class"), exports);
206
208
  __exportStar(require("./use_new"), exports);
207
209
  __exportStar(require("./when_others_last"), exports);
208
210
  __exportStar(require("./whitespace_end"), exports);
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.UnnecessaryLoopGuard = exports.UnnecessaryLoopGuardConf = void 0;
37
+ const issue_1 = require("../issue");
38
+ const Expressions = __importStar(require("../abap/2_statements/expressions"));
39
+ const Statements = __importStar(require("../abap/2_statements/statements"));
40
+ const Structures = __importStar(require("../abap/3_structures/structures"));
41
+ const _abap_rule_1 = require("./_abap_rule");
42
+ const _basic_rule_config_1 = require("./_basic_rule_config");
43
+ const _irule_1 = require("./_irule");
44
+ const edit_helper_1 = require("../edit_helper");
45
+ class UnnecessaryLoopGuardConf extends _basic_rule_config_1.BasicRuleConfig {
46
+ }
47
+ exports.UnnecessaryLoopGuardConf = UnnecessaryLoopGuardConf;
48
+ class UnnecessaryLoopGuard extends _abap_rule_1.ABAPRule {
49
+ constructor() {
50
+ super(...arguments);
51
+ this.conf = new UnnecessaryLoopGuardConf();
52
+ }
53
+ getMetadata() {
54
+ return {
55
+ key: "unnecessary_loop_guard",
56
+ title: "Unnecessary loop guard",
57
+ shortDescription: `Detects unnecessary IS [NOT] INITIAL check before LOOP AT`,
58
+ extendedInformation: `LOOP AT iterates zero times on an empty table, so an IS [NOT] INITIAL guard is redundant.`,
59
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
60
+ badExample: `IF lt_data IS NOT INITIAL.
61
+ LOOP AT lt_data INTO DATA(ls_item).
62
+ WRITE ls_item-name.
63
+ ENDLOOP.
64
+ ENDIF.`,
65
+ goodExample: `LOOP AT lt_data INTO DATA(ls_item).
66
+ WRITE ls_item-name.
67
+ ENDLOOP.`,
68
+ };
69
+ }
70
+ getConfig() {
71
+ return this.conf;
72
+ }
73
+ setConfig(conf) {
74
+ this.conf = conf;
75
+ }
76
+ runParsed(file) {
77
+ const issues = [];
78
+ const stru = file.getStructure();
79
+ if (stru === undefined) {
80
+ return issues;
81
+ }
82
+ for (const ifStru of stru.findAllStructuresRecursive(Structures.If)) {
83
+ if (ifStru.findDirectStructures(Structures.ElseIf).length > 0
84
+ || ifStru.findDirectStructures(Structures.Else).length > 0) {
85
+ continue;
86
+ }
87
+ const ifStatement = ifStru.findDirectStatement(Statements.If);
88
+ if (ifStatement === undefined) {
89
+ continue;
90
+ }
91
+ const cond = ifStatement.findDirectExpression(Expressions.Cond);
92
+ if (cond === undefined) {
93
+ continue;
94
+ }
95
+ const compareNodes = cond.findDirectExpressions(Expressions.Compare);
96
+ if (compareNodes.length !== 1) {
97
+ continue;
98
+ }
99
+ const m = compareNodes[0].concatTokens().toUpperCase().match(/^(.+?)\s+IS\s+(?:NOT\s+)?INITIAL\s*$/);
100
+ if (!m) {
101
+ continue;
102
+ }
103
+ const tableName = m[1];
104
+ const bodyStructures = ifStru.findDirectStructures(Structures.Body);
105
+ if (bodyStructures.length !== 1) {
106
+ continue;
107
+ }
108
+ const normalStructures = bodyStructures[0].findDirectStructures(Structures.Normal);
109
+ if (normalStructures.length !== 1) {
110
+ continue;
111
+ }
112
+ const loopStructures = normalStructures[0].findDirectStructures(Structures.Loop);
113
+ if (loopStructures.length !== 1) {
114
+ continue;
115
+ }
116
+ const loopStatement = loopStructures[0].findDirectStatement(Statements.Loop);
117
+ if (loopStatement === undefined) {
118
+ continue;
119
+ }
120
+ const loopSource = loopStatement.findFirstExpression(Expressions.LoopSource);
121
+ if (loopSource === undefined) {
122
+ continue;
123
+ }
124
+ if (loopSource.concatTokens().toUpperCase() !== tableName) {
125
+ continue;
126
+ }
127
+ const endifStatement = ifStru.findDirectStatement(Statements.EndIf);
128
+ const fix = edit_helper_1.EditHelper.merge(edit_helper_1.EditHelper.deleteStatement(file, ifStatement), edit_helper_1.EditHelper.deleteStatement(file, endifStatement));
129
+ issues.push(issue_1.Issue.atStatement(file, ifStatement, "Unnecessary IS [NOT] INITIAL check before LOOP AT", this.getMetadata().key, this.conf.severity, fix));
130
+ }
131
+ return issues;
132
+ }
133
+ }
134
+ exports.UnnecessaryLoopGuard = UnnecessaryLoopGuard;
135
+ //# sourceMappingURL=unnecessary_loop_guard.js.map
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.UseMessageClass = exports.UseMessageClassConf = void 0;
37
+ const issue_1 = require("../issue");
38
+ const _abap_rule_1 = require("./_abap_rule");
39
+ const Expressions = __importStar(require("../abap/2_statements/expressions"));
40
+ const Statements = __importStar(require("../abap/2_statements/statements"));
41
+ const _basic_rule_config_1 = require("./_basic_rule_config");
42
+ const _irule_1 = require("./_irule");
43
+ class UseMessageClassConf extends _basic_rule_config_1.BasicRuleConfig {
44
+ }
45
+ exports.UseMessageClassConf = UseMessageClassConf;
46
+ class UseMessageClass extends _abap_rule_1.ABAPRule {
47
+ constructor() {
48
+ super(...arguments);
49
+ this.conf = new UseMessageClassConf();
50
+ }
51
+ getMetadata() {
52
+ return {
53
+ key: "use_message_class",
54
+ title: "Use message class",
55
+ shortDescription: `Define messages in SE91 instead of using inline text or variables`,
56
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
57
+ badExample: `MESSAGE 'Something went wrong' TYPE 'E'.`,
58
+ goodExample: `MESSAGE e001(bc_msg).`,
59
+ };
60
+ }
61
+ getConfig() {
62
+ return this.conf;
63
+ }
64
+ setConfig(conf) {
65
+ this.conf = conf;
66
+ }
67
+ runParsed(file, _obj) {
68
+ const structure = file.getStructure();
69
+ if (structure === undefined) {
70
+ return [];
71
+ }
72
+ const issues = [];
73
+ const key = this.getMetadata().key;
74
+ for (const statement of structure.findAllStatements(Statements.Message)) {
75
+ // The parser populates MessageSource only for the class-based forms (e001(bc_msg) or ID/TYPE/NUMBER).
76
+ // The text form (MESSAGE <source> TYPE <source>) uses MessageSourceSource directly with no MessageSource child.
77
+ // Absence of MessageSource is therefore a reliable discriminator between the two forms.
78
+ if (statement.findDirectExpression(Expressions.MessageSource) !== undefined) {
79
+ continue;
80
+ }
81
+ issues.push(issue_1.Issue.atStatement(file, statement, "Use a message class (SE91) instead of inline text or variable", key, this.conf.severity));
82
+ }
83
+ return issues;
84
+ }
85
+ }
86
+ exports.UseMessageClass = UseMessageClass;
87
+ //# sourceMappingURL=use_message_class.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.58",
3
+ "version": "2.120.59",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",