@abaplint/cli 2.120.107 → 2.120.109

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.
Files changed (2) hide show
  1. package/build/cli.js +2695 -428
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -26849,6 +26849,82 @@ exports.EML = EML;
26849
26849
 
26850
26850
  /***/ },
26851
26851
 
26852
+ /***/ "../core/build/src/abap/5_syntax/_key_compare.js"
26853
+ /*!*******************************************************!*\
26854
+ !*** ../core/build/src/abap/5_syntax/_key_compare.js ***!
26855
+ \*******************************************************/
26856
+ (__unused_webpack_module, exports, __webpack_require__) {
26857
+
26858
+ "use strict";
26859
+
26860
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26861
+ if (k2 === undefined) k2 = k;
26862
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26863
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26864
+ desc = { enumerable: true, get: function() { return m[k]; } };
26865
+ }
26866
+ Object.defineProperty(o, k2, desc);
26867
+ }) : (function(o, m, k, k2) {
26868
+ if (k2 === undefined) k2 = k;
26869
+ o[k2] = m[k];
26870
+ }));
26871
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26872
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26873
+ }) : function(o, v) {
26874
+ o["default"] = v;
26875
+ });
26876
+ var __importStar = (this && this.__importStar) || (function () {
26877
+ var ownKeys = function(o) {
26878
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26879
+ var ar = [];
26880
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26881
+ return ar;
26882
+ };
26883
+ return ownKeys(o);
26884
+ };
26885
+ return function (mod) {
26886
+ if (mod && mod.__esModule) return mod;
26887
+ var result = {};
26888
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
26889
+ __setModuleDefault(result, mod);
26890
+ return result;
26891
+ };
26892
+ })();
26893
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
26894
+ exports.hasKeyCompare = hasKeyCompare;
26895
+ const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
26896
+ const nodes_1 = __webpack_require__(/*! ../nodes */ "../core/build/src/abap/nodes/index.js");
26897
+ /** True if a conjunct of the WHERE condition reachable through AND only, ie. not under OR or NOT,
26898
+ * compares the key component with = or IS INITIAL. Without such a comparison of its first component,
26899
+ * a sorted key cannot be used to optimize the WHERE condition */
26900
+ function hasKeyCompare(cond, component) {
26901
+ if (cond.findDirectTokenByText("OR") !== undefined) {
26902
+ return false;
26903
+ }
26904
+ for (const child of cond.getChildren()) {
26905
+ if (child.get() instanceof Expressions.ComponentCompare && child instanceof nodes_1.ExpressionNode) {
26906
+ const concat = child.concatTokens().toUpperCase().replace(/\s+/g, " ");
26907
+ if (concat.startsWith(component + " = ")
26908
+ || concat.startsWith(component + " EQ ")
26909
+ || concat === component + " IS INITIAL") {
26910
+ return true;
26911
+ }
26912
+ }
26913
+ else if (child.get() instanceof Expressions.ComponentCondSub
26914
+ && child instanceof nodes_1.ExpressionNode
26915
+ && child.findDirectTokenByText("NOT") === undefined) {
26916
+ const sub = child.findDirectExpression(Expressions.ComponentCond);
26917
+ if (sub !== undefined && hasKeyCompare(sub, component)) {
26918
+ return true;
26919
+ }
26920
+ }
26921
+ }
26922
+ return false;
26923
+ }
26924
+ //# sourceMappingURL=_key_compare.js.map
26925
+
26926
+ /***/ },
26927
+
26852
26928
  /***/ "../core/build/src/abap/5_syntax/_loop_table_change.js"
26853
26929
  /*!*************************************************************!*\
26854
26930
  !*** ../core/build/src/abap/5_syntax/_loop_table_change.js ***!
@@ -44408,6 +44484,7 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/s
44408
44484
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
44409
44485
  class InsertInternal {
44410
44486
  runSyntax(node, input) {
44487
+ var _a;
44411
44488
  let targetType;
44412
44489
  const t = node.findDirectExpression(Expressions.Target);
44413
44490
  if (t) {
@@ -44470,6 +44547,13 @@ class InsertInternal {
44470
44547
  // yea, well, INSERT doesnt convert the values automatically, like everything else?
44471
44548
  error = true;
44472
44549
  }
44550
+ else if (sourceType instanceof basic_1.CharacterType
44551
+ && targetType instanceof basic_1.CharacterType
44552
+ && ((_a = sourceType.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true
44553
+ && sourceType.getLength() !== targetType.getLength()) {
44554
+ // character literal of different length than the row type
44555
+ error = true;
44556
+ }
44473
44557
  if (error === true) {
44474
44558
  const message = "Types not compatible";
44475
44559
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -44776,7 +44860,6 @@ var __importStar = (this && this.__importStar) || (function () {
44776
44860
  Object.defineProperty(exports, "__esModule", ({ value: true }));
44777
44861
  exports.Loop = void 0;
44778
44862
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
44779
- const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
44780
44863
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
44781
44864
  const target_1 = __webpack_require__(/*! ../expressions/target */ "../core/build/src/abap/5_syntax/expressions/target.js");
44782
44865
  const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
@@ -44788,6 +44871,7 @@ const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "../core/bui
44788
44871
  const loop_group_by_1 = __webpack_require__(/*! ../expressions/loop_group_by */ "../core/build/src/abap/5_syntax/expressions/loop_group_by.js");
44789
44872
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
44790
44873
  const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
44874
+ const _key_compare_1 = __webpack_require__(/*! ../_key_compare */ "../core/build/src/abap/5_syntax/_key_compare.js");
44791
44875
  class Loop {
44792
44876
  runSyntax(node, input) {
44793
44877
  var _a, _b;
@@ -44892,7 +44976,7 @@ class Loop {
44892
44976
  // the first component of a sorted secondary key must be compared with = or IS INITIAL
44893
44977
  // in a part of the condition joined by AND, otherwise the WHERE cannot be optimized
44894
44978
  const first = key.keyFields[0].toUpperCase();
44895
- if (this.hasKeyCompare(cond, first) === false) {
44979
+ if ((0, _key_compare_1.hasKeyCompare)(cond, first) === false) {
44896
44980
  const message = "Loop, WHERE cannot be optimized for secondary key " + name +
44897
44981
  ", key component " + first + " needs a comparison with = or IS INITIAL joined by AND";
44898
44982
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -44939,31 +45023,6 @@ class Loop {
44939
45023
  loop_group_by_1.LoopGroupBy.runSyntax(group, input);
44940
45024
  }
44941
45025
  }
44942
- // true if a conjunct reachable through AND only, ie. not under OR or NOT, compares the component with = or IS INITIAL
44943
- hasKeyCompare(cond, component) {
44944
- if (cond.findDirectTokenByText("OR") !== undefined) {
44945
- return false;
44946
- }
44947
- for (const child of cond.getChildren()) {
44948
- if (child.get() instanceof Expressions.ComponentCompare && child instanceof nodes_1.ExpressionNode) {
44949
- const concat = child.concatTokens().toUpperCase().replace(/\s+/g, " ");
44950
- if (concat.startsWith(component + " = ")
44951
- || concat.startsWith(component + " EQ ")
44952
- || concat === component + " IS INITIAL") {
44953
- return true;
44954
- }
44955
- }
44956
- else if (child.get() instanceof Expressions.ComponentCondSub
44957
- && child instanceof nodes_1.ExpressionNode
44958
- && child.findDirectTokenByText("NOT") === undefined) {
44959
- const sub = child.findDirectExpression(Expressions.ComponentCond);
44960
- if (sub !== undefined && this.hasKeyCompare(sub, component)) {
44961
- return true;
44962
- }
44963
- }
44964
- }
44965
- return false;
44966
- }
44967
45026
  }
44968
45027
  exports.Loop = Loop;
44969
45028
  //# sourceMappingURL=loop.js.map
@@ -55116,7 +55175,7 @@ class ClassDefinition extends _identifier_1.Identifier {
55116
55175
  this.events.push(new event_definition_1.EventDefinition(e, visibility_1.Visibility.Public, input)); // todo, all these are not Public
55117
55176
  }
55118
55177
  this.methodDefs = new method_definitions_1.MethodDefinitions(node, input);
55119
- input.scope.pop(node.getLastToken().getEnd());
55178
+ const scope = input.scope.pop(node.getLastToken().getEnd());
55120
55179
  const concat = def.concatTokens().toUpperCase();
55121
55180
  this.testing = concat.includes(" FOR TESTING");
55122
55181
  this.sharedMemory = concat.includes(" SHARED MEMORY ENABLED");
@@ -55138,6 +55197,7 @@ class ClassDefinition extends _identifier_1.Identifier {
55138
55197
  this.checkClassNameLength(input);
55139
55198
  this.checkMethodNameLength(input);
55140
55199
  this.checkClassConstructor(input);
55200
+ this.checkLocalTypesInPublicSections(input, node, scope.getTop());
55141
55201
  }
55142
55202
  getFriends() {
55143
55203
  return this.friends;
@@ -55192,6 +55252,56 @@ class ClassDefinition extends _identifier_1.Identifier {
55192
55252
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, this.getToken(), message));
55193
55253
  }
55194
55254
  }
55255
+ // the local types, classes and interfaces of a class pool can only be used in the PRIVATE SECTION of the global class
55256
+ checkLocalTypesInPublicSections(input, node, scope) {
55257
+ if (this.globalValue === false || input.filename.toLowerCase().endsWith(".clas.abap") === false) {
55258
+ return;
55259
+ }
55260
+ const prefix = input.filename.toLowerCase().replace(/abap$/, "");
55261
+ const isLocal = (filename) => {
55262
+ const lower = filename.toLowerCase();
55263
+ return lower.startsWith(prefix)
55264
+ && (lower.endsWith(".clas.locals_def.abap") || lower.endsWith(".clas.locals_imp.abap"));
55265
+ };
55266
+ const references = [];
55267
+ const collect = (n) => {
55268
+ for (const r of n.getData().references) {
55269
+ if ((r.referenceType === _reference_1.ReferenceType.TypeReference || r.referenceType === _reference_1.ReferenceType.ObjectOrientedReference)
55270
+ && r.position.getFilename() === input.filename
55271
+ && r.position.getName().includes("~") === false // lif~meth of an ALIASES, the INTERFACES statement is reported
55272
+ && r.resolved !== undefined
55273
+ && isLocal(r.resolved.getFilename())) {
55274
+ references.push(r);
55275
+ }
55276
+ }
55277
+ n.getChildren().forEach(collect);
55278
+ };
55279
+ collect(scope);
55280
+ if (references.length === 0) {
55281
+ return;
55282
+ }
55283
+ const sections = [
55284
+ { section: node.findDirectStructure(Structures.PublicSection), name: "PUBLIC" },
55285
+ ];
55286
+ // a FINAL class has no subclasses, so the PROTECTED SECTION is effectively private
55287
+ if (this.finalValue === false) {
55288
+ sections.push({ section: node.findDirectStructure(Structures.ProtectedSection), name: "PROTECTED" });
55289
+ }
55290
+ for (const { section, name } of sections) {
55291
+ for (const statement of (section === null || section === void 0 ? void 0 : section.findAllStatementNodes()) || []) {
55292
+ // compare with the tokens, the statements of a chain share the first tokens
55293
+ const tokens = statement.getTokens();
55294
+ const found = references
55295
+ .filter(r => tokens.some(t => t.getStart().equals(r.position.getStart())))
55296
+ .sort((a, b) => a.position.getStart().isBefore(b.position.getStart()) ? -1 : 1)[0];
55297
+ if (found !== undefined) {
55298
+ const message = "\"" + found.position.getName().toUpperCase() +
55299
+ "\" is local to the class pool and cannot be used in the " + name + " SECTION of the global class";
55300
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, found.position.getToken(), message));
55301
+ }
55302
+ }
55303
+ }
55304
+ }
55195
55305
  findSuper(def, input) {
55196
55306
  var _a;
55197
55307
  const token = (_a = def === null || def === void 0 ? void 0 : def.findDirectExpression(expressions_1.SuperClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
@@ -73888,7 +73998,7 @@ class Registry {
73888
73998
  }
73889
73999
  static abaplintVersion() {
73890
74000
  // magic, see build script "version.js"
73891
- return "2.120.107";
74001
+ return "2.120.109";
73892
74002
  }
73893
74003
  getDDICReferences() {
73894
74004
  return this.ddicReferences;
@@ -74476,6 +74586,7 @@ exports.isReferenceType = isReferenceType;
74476
74586
  exports.identicalTypes = identicalTypes;
74477
74587
  exports.simplePredicate = simplePredicate;
74478
74588
  exports.characterConstant = characterConstant;
74589
+ exports.textLiteral = textLiteral;
74479
74590
  exports.sameCharacters = sameCharacters;
74480
74591
  exports.isCondition = isCondition;
74481
74592
  exports.dataSource = dataSource;
@@ -81290,187 +81401,461 @@ exports.ChangingSortedLine = ChangingSortedLine;
81290
81401
 
81291
81402
  /***/ },
81292
81403
 
81293
- /***/ "../core/build/src/rules/check_abstract.js"
81294
- /*!*************************************************!*\
81295
- !*** ../core/build/src/rules/check_abstract.js ***!
81296
- \*************************************************/
81297
- (__unused_webpack_module, exports, __webpack_require__) {
81298
-
81299
- "use strict";
81300
-
81301
- Object.defineProperty(exports, "__esModule", ({ value: true }));
81302
- exports.CheckAbstract = exports.CheckAbstractConf = void 0;
81303
- const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
81304
- const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
81305
- const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
81306
- const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
81307
- class CheckAbstractConf extends _basic_rule_config_1.BasicRuleConfig {
81308
- }
81309
- exports.CheckAbstractConf = CheckAbstractConf;
81310
- var IssueType;
81311
- (function (IssueType) {
81312
- /** Abstract method defined in non-abstract class */
81313
- IssueType[IssueType["NotAbstractClass"] = 0] = "NotAbstractClass";
81314
- IssueType[IssueType["AbstractAndFinal"] = 1] = "AbstractAndFinal";
81315
- })(IssueType || (IssueType = {}));
81316
- class CheckAbstract extends _abap_rule_1.ABAPRule {
81317
- constructor() {
81318
- super(...arguments);
81319
- this.conf = new CheckAbstractConf();
81320
- }
81321
- getMetadata() {
81322
- return {
81323
- key: "check_abstract",
81324
- title: "Check abstract methods and classes",
81325
- shortDescription: `Checks abstract methods and classes:
81326
- - class defined as abstract and final,
81327
- - non-abstract class contains abstract methods`,
81328
- extendedInformation: `If a class defines only constants, use an interface instead`,
81329
- tags: [_irule_1.RuleTag.SingleFile],
81330
- };
81331
- }
81332
- getDescription(issueType, name) {
81333
- switch (issueType) {
81334
- case IssueType.AbstractAndFinal:
81335
- return "Classes should not be ABSTRACT and FINAL: " + name;
81336
- case IssueType.NotAbstractClass:
81337
- return "Abstract methods require abstract classes: " + name;
81338
- default:
81339
- return "";
81340
- }
81341
- }
81342
- getConfig() {
81343
- return this.conf;
81344
- }
81345
- setConfig(conf) {
81346
- this.conf = conf;
81347
- }
81348
- runParsed(file) {
81349
- const issues = [];
81350
- for (const classDef of file.getInfo().listClassDefinitions()) {
81351
- if (classDef.isAbstract === true) {
81352
- if (classDef.isFinal === true && classDef.isForTesting === false) {
81353
- issues.push(issue_1.Issue.atIdentifier(classDef.identifier, this.getDescription(IssueType.AbstractAndFinal, classDef.name), this.getMetadata().key, this.conf.severity));
81354
- }
81355
- continue;
81356
- }
81357
- for (const methodDef of classDef.methods) {
81358
- if (methodDef.isAbstract === true) {
81359
- issues.push(issue_1.Issue.atIdentifier(methodDef.identifier, this.getDescription(IssueType.NotAbstractClass, methodDef.name), this.getMetadata().key, this.conf.severity));
81360
- }
81361
- }
81362
- }
81363
- return issues;
81364
- }
81365
- }
81366
- exports.CheckAbstract = CheckAbstract;
81367
- //# sourceMappingURL=check_abstract.js.map
81368
-
81369
- /***/ },
81370
-
81371
- /***/ "../core/build/src/rules/check_comments.js"
81372
- /*!*************************************************!*\
81373
- !*** ../core/build/src/rules/check_comments.js ***!
81374
- \*************************************************/
81375
- (__unused_webpack_module, exports, __webpack_require__) {
81376
-
81377
- "use strict";
81378
-
81379
- Object.defineProperty(exports, "__esModule", ({ value: true }));
81380
- exports.CheckComments = exports.CheckCommentsConf = void 0;
81381
- const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
81382
- const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
81383
- const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
81384
- const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
81385
- const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
81386
- class CheckCommentsConf extends _basic_rule_config_1.BasicRuleConfig {
81387
- constructor() {
81388
- super(...arguments);
81389
- /** Allows the use of end-of-line comments. */
81390
- this.allowEndOfLine = false;
81391
- this.maxIssuesPerFile = 10;
81392
- }
81393
- }
81394
- exports.CheckCommentsConf = CheckCommentsConf;
81395
- var IssueType;
81396
- (function (IssueType) {
81397
- IssueType[IssueType["EndOfLine"] = 0] = "EndOfLine";
81398
- })(IssueType || (IssueType = {}));
81399
- class CheckComments extends _abap_rule_1.ABAPRule {
81400
- constructor() {
81401
- super(...arguments);
81402
- this.conf = new CheckCommentsConf();
81403
- }
81404
- getMetadata() {
81405
- return {
81406
- key: "check_comments",
81407
- title: "Check Comments",
81408
- shortDescription: `
81409
- Various checks for comment usage.`,
81410
- extendedInformation: `
81411
- Detects end of line comments. Comments starting with "#EC" or "##" are ignored
81412
-
81413
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#put-comments-before-the-statement-they-relate-to`,
81414
- tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
81415
- badExample: `WRITE 2. " descriptive comment`,
81416
- goodExample: `" descriptive comment\nWRITE 2.`,
81417
- };
81418
- }
81419
- getDescription(issueType) {
81420
- switch (issueType) {
81421
- case IssueType.EndOfLine: return `Do not use end of line comments - move comment to previous row instead`;
81422
- default: return "";
81423
- }
81424
- }
81425
- getConfig() {
81426
- return this.conf;
81427
- }
81428
- setConfig(conf) {
81429
- this.conf = conf;
81430
- }
81431
- runParsed(file) {
81432
- const issues = [];
81433
- const rows = file.getRawRows();
81434
- if (this.conf.allowEndOfLine === true) {
81435
- return [];
81436
- }
81437
- let max = this.getConfig().maxIssuesPerFile;
81438
- if (max === undefined || max < 1) {
81439
- max = 10;
81440
- }
81441
- const commentRows = [];
81442
- for (let i = 0; i < rows.length; i++) {
81443
- const row = rows[i];
81444
- if (row.trim().startsWith("*") || row.trim().startsWith(`"`)) {
81445
- commentRows.push(i);
81446
- }
81447
- }
81448
- const statements = file.getStatements();
81449
- for (let i = statements.length - 1; i >= 0; i--) {
81450
- const statement = statements[i];
81451
- if (statement.get() instanceof _statement_1.Comment && !commentRows.includes(statement.getStart().getRow() - 1)) {
81452
- if (statement.getFirstToken().getStr().startsWith(`"#EC`)
81453
- || statement.getFirstToken().getStr().startsWith(`"##`)) {
81454
- continue;
81455
- }
81456
- issues.push(issue_1.Issue.atStatement(file, statement, this.getDescription(IssueType.EndOfLine), this.getMetadata().key, this.conf.severity));
81457
- if (issues.length >= max) {
81458
- break;
81459
- }
81460
- }
81461
- }
81462
- return issues;
81463
- }
81464
- }
81465
- exports.CheckComments = CheckComments;
81466
- //# sourceMappingURL=check_comments.js.map
81467
-
81468
- /***/ },
81469
-
81470
- /***/ "../core/build/src/rules/check_ddic.js"
81471
- /*!*********************************************!*\
81472
- !*** ../core/build/src/rules/check_ddic.js ***!
81473
- \*********************************************/
81404
+ /***/ "../core/build/src/rules/character_field_literal_blanks.js"
81405
+ /*!*****************************************************************!*\
81406
+ !*** ../core/build/src/rules/character_field_literal_blanks.js ***!
81407
+ \*****************************************************************/
81408
+ (__unused_webpack_module, exports, __webpack_require__) {
81409
+
81410
+ "use strict";
81411
+
81412
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
81413
+ if (k2 === undefined) k2 = k;
81414
+ var desc = Object.getOwnPropertyDescriptor(m, k);
81415
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
81416
+ desc = { enumerable: true, get: function() { return m[k]; } };
81417
+ }
81418
+ Object.defineProperty(o, k2, desc);
81419
+ }) : (function(o, m, k, k2) {
81420
+ if (k2 === undefined) k2 = k;
81421
+ o[k2] = m[k];
81422
+ }));
81423
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
81424
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
81425
+ }) : function(o, v) {
81426
+ o["default"] = v;
81427
+ });
81428
+ var __importStar = (this && this.__importStar) || (function () {
81429
+ var ownKeys = function(o) {
81430
+ ownKeys = Object.getOwnPropertyNames || function (o) {
81431
+ var ar = [];
81432
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
81433
+ return ar;
81434
+ };
81435
+ return ownKeys(o);
81436
+ };
81437
+ return function (mod) {
81438
+ if (mod && mod.__esModule) return mod;
81439
+ var result = {};
81440
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
81441
+ __setModuleDefault(result, mod);
81442
+ return result;
81443
+ };
81444
+ })();
81445
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
81446
+ exports.CharacterFieldLiteralBlanks = exports.CharacterFieldLiteralBlanksConf = void 0;
81447
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
81448
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
81449
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
81450
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
81451
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
81452
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
81453
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
81454
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
81455
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
81456
+ class CharacterFieldLiteralBlanksConf extends _basic_rule_config_1.BasicRuleConfig {
81457
+ constructor() {
81458
+ super(...arguments);
81459
+ this.severity = severity_1.Severity.Warning;
81460
+ /** Report a FIND or REPLACE search pattern that is a character field literal containing only blanks, or space,
81461
+ * the pattern is empty: ALL OCCURRENCES raises an exception, FIRST OCCURRENCE matches before the first character */
81462
+ this.searchPattern = true;
81463
+ /** Report a character field literal ending with a blank as an operand of &&, of CONCATENATE without
81464
+ * RESPECTING BLANKS, or as an embedded expression in a string template, the trailing blanks are dropped */
81465
+ this.concatenation = true;
81466
+ }
81467
+ }
81468
+ exports.CharacterFieldLiteralBlanksConf = CharacterFieldLiteralBlanksConf;
81469
+ class CharacterFieldLiteralBlanks extends _abap_rule_1.ABAPRule {
81470
+ constructor() {
81471
+ super(...arguments);
81472
+ this.conf = new CharacterFieldLiteralBlanksConf();
81473
+ }
81474
+ getMetadata() {
81475
+ return {
81476
+ key: "character_field_literal_blanks",
81477
+ title: "Ignored blanks in character field literals",
81478
+ shortDescription: `Reports character field literals ('...') whose blanks are ignored where the code relies on them`,
81479
+ extendedInformation: `A character field literal '...' (called text field literal in the ABAP
81480
+ documentation) has type c, and trailing blanks of type c operands are ignored in many positions.
81481
+ A text string literal \`...\` has type string and keeps them.
81482
+
81483
+ Option searchPattern: a FIND or REPLACE search pattern (SUBSTRING, character mode) that is a character field
81484
+ literal containing only blanks, '' or space. The pattern is empty: FIND/REPLACE ALL OCCURRENCES raises
81485
+ CX_SY_FIND_INFINITE_LOOP/CX_SY_REPLACE_INFINITE_LOOP, the first occurrence is found before the first character.
81486
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapfind_pattern.htm
81487
+
81488
+ Option concatenation: a character field literal ending with a blank as an operand of &&, as an operand of
81489
+ CONCATENATE without RESPECTING BLANKS, or as the whole embedded expression of a string template without
81490
+ formatting options. The trailing blanks are dropped, 'Hello ' && name gives "HelloJohn". space is reported
81491
+ the same way.
81492
+ https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenstring_operators.htm
81493
+
81494
+ The quick fix replaces the literal with a text string literal with the same content.
81495
+
81496
+ Not reported: text string literals, CONCATENATE ... RESPECTING BLANKS, the separator of SEPARATED BY
81497
+ (its trailing blanks are kept), the literal operator &, literals with a text symbol, PCRE and REGEX
81498
+ patterns, byte mode, comparisons and parameters.`,
81499
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
81500
+ badExample: `REPLACE ALL OCCURRENCES OF ' ' IN lv_text WITH ''.
81501
+ lv_text = 'Hello ' && lv_name.`,
81502
+ goodExample: `REPLACE ALL OCCURRENCES OF \` \` IN lv_text WITH ''.
81503
+ lv_text = \`Hello \` && lv_name.`,
81504
+ };
81505
+ }
81506
+ getConfig() {
81507
+ return this.conf;
81508
+ }
81509
+ setConfig(conf) {
81510
+ this.conf = conf;
81511
+ }
81512
+ runParsed(file) {
81513
+ const issues = [];
81514
+ for (const statement of file.getStatements()) {
81515
+ if (this.conf.searchPattern === true) {
81516
+ const issue = this.checkSearchPattern(file, statement);
81517
+ if (issue !== undefined) {
81518
+ issues.push(issue);
81519
+ }
81520
+ }
81521
+ if (this.conf.concatenation === true) {
81522
+ issues.push(...this.checkConcatenation(file, statement));
81523
+ }
81524
+ }
81525
+ return issues;
81526
+ }
81527
+ ////////////////
81528
+ checkSearchPattern(file, statement) {
81529
+ const s = statement.get();
81530
+ const isFind = s instanceof Statements.Find;
81531
+ if ((isFind === false && !(s instanceof Statements.Replace))
81532
+ || statement.findDirectTokenByText("IN") === undefined
81533
+ || statement.findDirectTokenByText("BYTE") !== undefined) {
81534
+ return undefined;
81535
+ }
81536
+ const pattern = this.findPattern(statement);
81537
+ if (pattern === undefined || pattern.getChildren().length !== 1) {
81538
+ return undefined;
81539
+ }
81540
+ const token = this.blankOperand(pattern);
81541
+ if (token === undefined || this.content(token).trim() !== "") {
81542
+ return undefined;
81543
+ }
81544
+ const name = isFind ? "FIND" : "REPLACE";
81545
+ const table = statement.findDirectTokenByText("TABLE") !== undefined;
81546
+ let effect = "it is found before the first character";
81547
+ if (statement.findDirectTokenByText("ALL") !== undefined) {
81548
+ effect = isFind && table
81549
+ ? "FIND ALL OCCURRENCES IN TABLE with an empty pattern is not possible"
81550
+ : `${name} ALL OCCURRENCES raises CX_SY_${name}_INFINITE_LOOP`;
81551
+ }
81552
+ const message = `Search pattern ${token.getStr()} is empty, blanks of character field literals are ignored, ${effect}`;
81553
+ return issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity, this.buildFix(file, token));
81554
+ }
81555
+ /** the substring pattern of FIND or REPLACE, undefined for PCRE and REGEX and for REPLACE SECTION */
81556
+ findPattern(statement) {
81557
+ const children = statement.getChildren();
81558
+ for (let i = 1; i < children.length; i++) {
81559
+ const child = children[i];
81560
+ if (child instanceof nodes_1.TokenNode && child.concatTokens().toUpperCase() === "IN") {
81561
+ return undefined;
81562
+ }
81563
+ else if (!(child instanceof nodes_1.ExpressionNode) || !(child.get() instanceof Expressions.Source)) {
81564
+ continue;
81565
+ }
81566
+ const before = children[i - 1];
81567
+ if (before instanceof nodes_1.ExpressionNode && before.get() instanceof Expressions.FindType) {
81568
+ return before.concatTokens().toUpperCase() === "SUBSTRING" ? child : undefined;
81569
+ }
81570
+ else if (before instanceof nodes_1.TokenNode && CharacterFieldLiteralBlanks.beforePattern.has(before.concatTokens().toUpperCase())) {
81571
+ return child;
81572
+ }
81573
+ }
81574
+ return undefined;
81575
+ }
81576
+ checkConcatenation(file, statement) {
81577
+ const operands = [];
81578
+ const sources = statement.findAllExpressionsRecursive(Expressions.Source);
81579
+ // left operands of &&
81580
+ for (const source of sources) {
81581
+ if (source.findDirectTokenByText("&&") !== undefined) {
81582
+ operands.push(source);
81583
+ }
81584
+ }
81585
+ // right operands of && and &&=
81586
+ for (const node of [statement, ...sources]) {
81587
+ const children = node.getChildren();
81588
+ for (let i = 1; i < children.length; i++) {
81589
+ const before = children[i - 1].concatTokens();
81590
+ const child = children[i];
81591
+ if ((before === "&&" || before === "&&=")
81592
+ && child instanceof nodes_1.ExpressionNode
81593
+ && child.get() instanceof Expressions.Source) {
81594
+ operands.push(child);
81595
+ }
81596
+ }
81597
+ }
81598
+ // embedded expressions without formatting options
81599
+ for (const embedded of statement.findAllExpressionsRecursive(Expressions.StringTemplateSource)) {
81600
+ const source = embedded.findDirectExpression(Expressions.Source);
81601
+ if (source !== undefined
81602
+ && source.getChildren().length === 1
81603
+ && embedded.findDirectExpression(Expressions.StringTemplateFormatting) === undefined) {
81604
+ operands.push(source);
81605
+ }
81606
+ }
81607
+ // CONCATENATE without RESPECTING BLANKS, the separator keeps its blanks
81608
+ if (statement.get() instanceof Statements.Concatenate
81609
+ && statement.findDirectTokenByText("RESPECTING") === undefined
81610
+ && statement.findDirectTokenByText("BYTE") === undefined) {
81611
+ for (const child of statement.getChildren()) {
81612
+ if (child instanceof nodes_1.TokenNode && child.concatTokens().toUpperCase() === "INTO") {
81613
+ break;
81614
+ }
81615
+ else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.SimpleSource3) {
81616
+ operands.push(child);
81617
+ }
81618
+ }
81619
+ }
81620
+ const issues = [];
81621
+ const reported = new Set();
81622
+ for (const operand of operands) {
81623
+ const token = this.blankOperand(operand);
81624
+ if (token === undefined || reported.has(token)) {
81625
+ continue;
81626
+ }
81627
+ const content = this.content(token);
81628
+ if (content === "" || content.endsWith(" ") === false) {
81629
+ continue;
81630
+ }
81631
+ reported.add(token);
81632
+ const message = token.getStr().startsWith("'")
81633
+ ? `Trailing blanks of ${token.getStr()} are ignored here, use a text string literal`
81634
+ : `${token.getStr()} is ignored here, use \` \``;
81635
+ issues.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity, this.buildFix(file, token)));
81636
+ }
81637
+ return issues;
81638
+ }
81639
+ /** the token of a character field literal or of space at the start of the operand */
81640
+ blankOperand(operand) {
81641
+ var _a;
81642
+ const first = operand.getChildren()[0];
81643
+ if (!(first instanceof nodes_1.ExpressionNode)) {
81644
+ return undefined;
81645
+ }
81646
+ if (first.get() instanceof Expressions.Constant) {
81647
+ const str = (_a = first.findDirectExpression(Expressions.ConstantString)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
81648
+ return (str === null || str === void 0 ? void 0 : str.getStr().startsWith("'")) ? str : undefined;
81649
+ }
81650
+ else if (first.get() instanceof Expressions.FieldChain && first.concatTokens().toUpperCase() === "SPACE") {
81651
+ return first.getFirstToken();
81652
+ }
81653
+ return undefined;
81654
+ }
81655
+ /** the value of a character field literal, " " for space */
81656
+ content(token) {
81657
+ const str = token.getStr();
81658
+ if (str.startsWith("'") === false) {
81659
+ return " ";
81660
+ }
81661
+ return str.substring(1, str.length - 1).replace(/''/g, "'");
81662
+ }
81663
+ buildFix(file, token) {
81664
+ const content = this.content(token);
81665
+ if (content === "") {
81666
+ return undefined;
81667
+ }
81668
+ return edit_helper_1.EditHelper.replaceToken(file, token, "`" + content.replace(/`/g, "``") + "`");
81669
+ }
81670
+ }
81671
+ exports.CharacterFieldLiteralBlanks = CharacterFieldLiteralBlanks;
81672
+ // tokens directly before the pattern of FIND and REPLACE, when no FindType is given
81673
+ CharacterFieldLiteralBlanks.beforePattern = new Set(["FIND", "REPLACE", "OF", "OCCURRENCE", "OCCURRENCES", "OCCURENCE", "OCCURENCES"]);
81674
+ //# sourceMappingURL=character_field_literal_blanks.js.map
81675
+
81676
+ /***/ },
81677
+
81678
+ /***/ "../core/build/src/rules/check_abstract.js"
81679
+ /*!*************************************************!*\
81680
+ !*** ../core/build/src/rules/check_abstract.js ***!
81681
+ \*************************************************/
81682
+ (__unused_webpack_module, exports, __webpack_require__) {
81683
+
81684
+ "use strict";
81685
+
81686
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
81687
+ exports.CheckAbstract = exports.CheckAbstractConf = void 0;
81688
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
81689
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
81690
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
81691
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
81692
+ class CheckAbstractConf extends _basic_rule_config_1.BasicRuleConfig {
81693
+ }
81694
+ exports.CheckAbstractConf = CheckAbstractConf;
81695
+ var IssueType;
81696
+ (function (IssueType) {
81697
+ /** Abstract method defined in non-abstract class */
81698
+ IssueType[IssueType["NotAbstractClass"] = 0] = "NotAbstractClass";
81699
+ IssueType[IssueType["AbstractAndFinal"] = 1] = "AbstractAndFinal";
81700
+ })(IssueType || (IssueType = {}));
81701
+ class CheckAbstract extends _abap_rule_1.ABAPRule {
81702
+ constructor() {
81703
+ super(...arguments);
81704
+ this.conf = new CheckAbstractConf();
81705
+ }
81706
+ getMetadata() {
81707
+ return {
81708
+ key: "check_abstract",
81709
+ title: "Check abstract methods and classes",
81710
+ shortDescription: `Checks abstract methods and classes:
81711
+ - class defined as abstract and final,
81712
+ - non-abstract class contains abstract methods`,
81713
+ extendedInformation: `If a class defines only constants, use an interface instead`,
81714
+ tags: [_irule_1.RuleTag.SingleFile],
81715
+ };
81716
+ }
81717
+ getDescription(issueType, name) {
81718
+ switch (issueType) {
81719
+ case IssueType.AbstractAndFinal:
81720
+ return "Classes should not be ABSTRACT and FINAL: " + name;
81721
+ case IssueType.NotAbstractClass:
81722
+ return "Abstract methods require abstract classes: " + name;
81723
+ default:
81724
+ return "";
81725
+ }
81726
+ }
81727
+ getConfig() {
81728
+ return this.conf;
81729
+ }
81730
+ setConfig(conf) {
81731
+ this.conf = conf;
81732
+ }
81733
+ runParsed(file) {
81734
+ const issues = [];
81735
+ for (const classDef of file.getInfo().listClassDefinitions()) {
81736
+ if (classDef.isAbstract === true) {
81737
+ if (classDef.isFinal === true && classDef.isForTesting === false) {
81738
+ issues.push(issue_1.Issue.atIdentifier(classDef.identifier, this.getDescription(IssueType.AbstractAndFinal, classDef.name), this.getMetadata().key, this.conf.severity));
81739
+ }
81740
+ continue;
81741
+ }
81742
+ for (const methodDef of classDef.methods) {
81743
+ if (methodDef.isAbstract === true) {
81744
+ issues.push(issue_1.Issue.atIdentifier(methodDef.identifier, this.getDescription(IssueType.NotAbstractClass, methodDef.name), this.getMetadata().key, this.conf.severity));
81745
+ }
81746
+ }
81747
+ }
81748
+ return issues;
81749
+ }
81750
+ }
81751
+ exports.CheckAbstract = CheckAbstract;
81752
+ //# sourceMappingURL=check_abstract.js.map
81753
+
81754
+ /***/ },
81755
+
81756
+ /***/ "../core/build/src/rules/check_comments.js"
81757
+ /*!*************************************************!*\
81758
+ !*** ../core/build/src/rules/check_comments.js ***!
81759
+ \*************************************************/
81760
+ (__unused_webpack_module, exports, __webpack_require__) {
81761
+
81762
+ "use strict";
81763
+
81764
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
81765
+ exports.CheckComments = exports.CheckCommentsConf = void 0;
81766
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
81767
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
81768
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
81769
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
81770
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
81771
+ class CheckCommentsConf extends _basic_rule_config_1.BasicRuleConfig {
81772
+ constructor() {
81773
+ super(...arguments);
81774
+ /** Allows the use of end-of-line comments. */
81775
+ this.allowEndOfLine = false;
81776
+ this.maxIssuesPerFile = 10;
81777
+ }
81778
+ }
81779
+ exports.CheckCommentsConf = CheckCommentsConf;
81780
+ var IssueType;
81781
+ (function (IssueType) {
81782
+ IssueType[IssueType["EndOfLine"] = 0] = "EndOfLine";
81783
+ })(IssueType || (IssueType = {}));
81784
+ class CheckComments extends _abap_rule_1.ABAPRule {
81785
+ constructor() {
81786
+ super(...arguments);
81787
+ this.conf = new CheckCommentsConf();
81788
+ }
81789
+ getMetadata() {
81790
+ return {
81791
+ key: "check_comments",
81792
+ title: "Check Comments",
81793
+ shortDescription: `
81794
+ Various checks for comment usage.`,
81795
+ extendedInformation: `
81796
+ Detects end of line comments. Comments starting with "#EC" or "##" are ignored
81797
+
81798
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#put-comments-before-the-statement-they-relate-to`,
81799
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
81800
+ badExample: `WRITE 2. " descriptive comment`,
81801
+ goodExample: `" descriptive comment\nWRITE 2.`,
81802
+ };
81803
+ }
81804
+ getDescription(issueType) {
81805
+ switch (issueType) {
81806
+ case IssueType.EndOfLine: return `Do not use end of line comments - move comment to previous row instead`;
81807
+ default: return "";
81808
+ }
81809
+ }
81810
+ getConfig() {
81811
+ return this.conf;
81812
+ }
81813
+ setConfig(conf) {
81814
+ this.conf = conf;
81815
+ }
81816
+ runParsed(file) {
81817
+ const issues = [];
81818
+ const rows = file.getRawRows();
81819
+ if (this.conf.allowEndOfLine === true) {
81820
+ return [];
81821
+ }
81822
+ let max = this.getConfig().maxIssuesPerFile;
81823
+ if (max === undefined || max < 1) {
81824
+ max = 10;
81825
+ }
81826
+ const commentRows = [];
81827
+ for (let i = 0; i < rows.length; i++) {
81828
+ const row = rows[i];
81829
+ if (row.trim().startsWith("*") || row.trim().startsWith(`"`)) {
81830
+ commentRows.push(i);
81831
+ }
81832
+ }
81833
+ const statements = file.getStatements();
81834
+ for (let i = statements.length - 1; i >= 0; i--) {
81835
+ const statement = statements[i];
81836
+ if (statement.get() instanceof _statement_1.Comment && !commentRows.includes(statement.getStart().getRow() - 1)) {
81837
+ if (statement.getFirstToken().getStr().startsWith(`"#EC`)
81838
+ || statement.getFirstToken().getStr().startsWith(`"##`)) {
81839
+ continue;
81840
+ }
81841
+ issues.push(issue_1.Issue.atStatement(file, statement, this.getDescription(IssueType.EndOfLine), this.getMetadata().key, this.conf.severity));
81842
+ if (issues.length >= max) {
81843
+ break;
81844
+ }
81845
+ }
81846
+ }
81847
+ return issues;
81848
+ }
81849
+ }
81850
+ exports.CheckComments = CheckComments;
81851
+ //# sourceMappingURL=check_comments.js.map
81852
+
81853
+ /***/ },
81854
+
81855
+ /***/ "../core/build/src/rules/check_ddic.js"
81856
+ /*!*********************************************!*\
81857
+ !*** ../core/build/src/rules/check_ddic.js ***!
81858
+ \*********************************************/
81474
81859
  (__unused_webpack_module, exports, __webpack_require__) {
81475
81860
 
81476
81861
  "use strict";
@@ -83543,11 +83928,20 @@ var __importStar = (this && this.__importStar) || (function () {
83543
83928
  Object.defineProperty(exports, "__esModule", ({ value: true }));
83544
83929
  exports.ConstantCondition = exports.ConstantConditionConf = void 0;
83545
83930
  const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
83931
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
83932
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
83546
83933
  const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
83934
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
83935
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
83547
83936
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
83548
83937
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
83549
83938
  const _procedure_analysis_1 = __webpack_require__(/*! ./_procedure_analysis */ "../core/build/src/rules/_procedure_analysis.js");
83550
83939
  class ConstantConditionConf extends _basic_rule_config_1.BasicRuleConfig {
83940
+ constructor() {
83941
+ super(...arguments);
83942
+ /** Report x <> a OR x <> b, always true, and x = a AND x = b, always false, for different character values a and b */
83943
+ this.exclusiveValues = true;
83944
+ }
83551
83945
  }
83552
83946
  exports.ConstantConditionConf = ConstantConditionConf;
83553
83947
  class ConstantCondition {
@@ -83558,7 +83952,8 @@ class ConstantCondition {
83558
83952
  return {
83559
83953
  key: "constant_condition",
83560
83954
  title: "Constant condition",
83561
- shortDescription: `Finds IF and ELSEIF conditions on local variables whose value is known`,
83955
+ shortDescription: `Finds IF and ELSEIF conditions on local variables whose value is known, and conditions that compare
83956
+ a field with two different values and are always true or always false`,
83562
83957
  extendedInformation: `Reports two cases, for local variables of a METHOD, FORM or FUNCTION.
83563
83958
 
83564
83959
  1. DATA(c) = <constant>. where the constant is a character literal like 'X', or a character constant like
@@ -83577,15 +83972,31 @@ an ELSEIF branch that is always taken turns into ELSE. Nothing is reported if a
83577
83972
  data that is used outside of it.
83578
83973
 
83579
83974
  Objects with syntax errors, macros or unknown statements are skipped, as are procedures with dynamic code,
83580
- INCLUDE, test seams, enhancements or native SQL. No release requirement.`,
83975
+ INCLUDE, test seams, enhancements or native SQL. No release requirement.
83976
+
83977
+ Option exclusiveValues: reports x <> a OR x <> b, which is always true, and x = a AND x = b, which is always
83978
+ false, in any condition of a METHOD, FORM or FUNCTION, also with dynamic code. Also with NE and EQ, with NOT,
83979
+ with the operands swapped, and with more conditions joined by the same operator. x is a data object of type c,
83980
+ generic c or string, without calls, offsets or table expressions. a and b are character literals or character
83981
+ constants, also components of constant structures of a class or interface, with different values. Usually one
83982
+ of the operators or one of the values is wrong, there is no quick fix.
83983
+ Not reported: conditions that mix AND and OR or contain a call, values that are not known, like constants of
83984
+ classes outside the registry, other types of x, which can convert different values to the same one, ASSERT,
83985
+ and SQL conditions, where a NULL value makes both comparisons unknown.`,
83581
83986
  tags: [_irule_1.RuleTag.Quickfix],
83582
83987
  badExample: `DATA(lv_active) = abap_true.
83583
83988
  IF lv_active = abap_true.
83584
83989
  run( ).
83585
83990
  ELSE.
83586
83991
  skip( ).
83992
+ ENDIF.
83993
+ IF lv_kind <> 'N' OR lv_kind <> 'P'.
83994
+ skip( ).
83995
+ ENDIF.`,
83996
+ goodExample: `run( ).
83997
+ IF lv_kind <> 'N' AND lv_kind <> 'P'.
83998
+ skip( ).
83587
83999
  ENDIF.`,
83588
- goodExample: `run( ).`,
83589
84000
  };
83590
84001
  }
83591
84002
  getConfig() {
@@ -83605,6 +84016,9 @@ ENDIF.`,
83605
84016
  }
83606
84017
  const issues = [];
83607
84018
  for (const procedure of analysis.procedures) {
84019
+ if (this.conf.exclusiveValues) {
84020
+ issues.push(...this.exclusiveValues(procedure));
84021
+ }
83608
84022
  if (procedure.supported === false) {
83609
84023
  continue;
83610
84024
  }
@@ -83706,6 +84120,175 @@ ENDIF.`,
83706
84120
  return source.countTokens() === 1 && source.findDirectExpression(Expressions.FieldChain) !== undefined
83707
84121
  && source.getFirstToken().getStart().equals(read.token.getStart());
83708
84122
  }
84123
+ /** x <> a OR x <> b, x = a AND x = b */
84124
+ exclusiveValues(procedure) {
84125
+ const issues = [];
84126
+ for (const statement of procedure.statements) {
84127
+ if (statement.get() instanceof Statements.Assert) {
84128
+ continue;
84129
+ }
84130
+ for (const cond of statement.findAllExpressionsRecursive(Expressions.Cond)) {
84131
+ const operators = cond.getChildren().filter(c => c instanceof nodes_1.TokenNode).map(c => c.getFirstToken().getStr().toUpperCase());
84132
+ const operator = operators[0];
84133
+ if ((operator !== "OR" && operator !== "AND") || operators.some(o => o !== operator) || this.hasCall(cond)) {
84134
+ continue;
84135
+ }
84136
+ const seen = [];
84137
+ for (const child of cond.getChildren()) {
84138
+ const comparison = child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Compare
84139
+ ? this.valueComparison(procedure, child) : undefined;
84140
+ if (comparison === undefined || comparison.equal !== (operator === "AND")) {
84141
+ continue;
84142
+ }
84143
+ const other = seen.find(s => s.subject === comparison.subject && !(0, _procedure_analysis_1.sameCharacters)(s.value, comparison.value));
84144
+ if (other !== undefined) {
84145
+ const message = "Condition is always " + (operator === "OR" ? "true" : "false") + ", "
84146
+ + this.subjectText(comparison) + " cannot be both "
84147
+ + other.constant.concatTokens() + " and " + comparison.constant.concatTokens();
84148
+ issues.push(issue_1.Issue.atRange(procedure.file, other.compare.getFirstToken().getStart(), comparison.compare.getLastToken().getEnd(), message, this.getMetadata().key, this.conf.severity));
84149
+ break;
84150
+ }
84151
+ seen.push(comparison);
84152
+ }
84153
+ }
84154
+ }
84155
+ return issues;
84156
+ }
84157
+ hasCall(node) {
84158
+ return node.findFirstExpression(Expressions.MethodCall) !== undefined
84159
+ || node.findFirstExpression(Expressions.MethodCallChain) !== undefined
84160
+ || node.findFirstExpression(Expressions.NewObject) !== undefined;
84161
+ }
84162
+ /** x = a, x <> a, a = x, NOT x = a etc, x character-like and a a known character value */
84163
+ valueComparison(procedure, compare) {
84164
+ const children = compare.getChildren();
84165
+ const negated = children[0] instanceof nodes_1.TokenNode && children[0].getFirstToken().getStr().toUpperCase() === "NOT";
84166
+ const rest = children.slice(negated ? 1 : 0);
84167
+ if (rest.length !== 3 || !(rest[0] instanceof nodes_1.ExpressionNode) || !(rest[2] instanceof nodes_1.ExpressionNode)
84168
+ || !(rest[1].get() instanceof Expressions.CompareOperator)) {
84169
+ return undefined;
84170
+ }
84171
+ const operator = rest[1].concatTokens().toUpperCase().replace(/ /g, "");
84172
+ let equal;
84173
+ if (operator === "=" || operator === "EQ") {
84174
+ equal = true;
84175
+ }
84176
+ else if (operator === "<>" || operator === "><" || operator === "NE") {
84177
+ equal = false;
84178
+ }
84179
+ else {
84180
+ return undefined;
84181
+ }
84182
+ for (const [subject, constant] of [[rest[0], rest[2]], [rest[2], rest[0]]]) {
84183
+ const value = this.constantValue(procedure, constant);
84184
+ const type = value === undefined ? undefined : this.subjectType(procedure, subject);
84185
+ if (value !== undefined
84186
+ && (type instanceof basic_1.CharacterType || type instanceof basic_1.CGenericType || type instanceof basic_1.StringType)) {
84187
+ const text = subject.getTokens().map(t => t.getStr().toUpperCase()).join(" ");
84188
+ return { subject: text, value, equal: equal !== negated, compare, constant };
84189
+ }
84190
+ }
84191
+ return undefined;
84192
+ }
84193
+ subjectText(comparison) {
84194
+ var _a;
84195
+ var _b;
84196
+ return (_b = (_a = comparison.compare.getChildren().find(c => c instanceof nodes_1.ExpressionNode && c !== comparison.constant
84197
+ && c.get() instanceof Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens()) !== null && _b !== void 0 ? _b : comparison.subject;
84198
+ }
84199
+ /** type of a field, field symbol, attribute or component chain, without calls, offsets or table expressions */
84200
+ subjectType(procedure, source) {
84201
+ var _a;
84202
+ var _b;
84203
+ const chain = source.getChildren().length === 1 ? source.findDirectExpression(Expressions.FieldChain) : undefined;
84204
+ const children = (_b = chain === null || chain === void 0 ? void 0 : chain.getChildren()) !== null && _b !== void 0 ? _b : [];
84205
+ let identifier;
84206
+ let next;
84207
+ if (children[0] instanceof nodes_1.ExpressionNode
84208
+ && (children[0].get() instanceof Expressions.SourceField || children[0].get() instanceof Expressions.SourceFieldSymbol)) {
84209
+ identifier = procedure.identifierAt(children[0].getFirstToken());
84210
+ next = 1;
84211
+ }
84212
+ else if (children[0] instanceof nodes_1.ExpressionNode && children[0].get() instanceof Expressions.ClassName
84213
+ && ((_a = children[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "=>" && children[2] instanceof nodes_1.ExpressionNode) {
84214
+ identifier = procedure.identifierAt(children[2].getFirstToken());
84215
+ next = 3;
84216
+ }
84217
+ else {
84218
+ return undefined;
84219
+ }
84220
+ let type = identifier instanceof _typed_identifier_1.TypedIdentifier ? identifier.getType() : undefined;
84221
+ for (let i = next; i < children.length; i += 2) {
84222
+ const separator = children[i];
84223
+ const name = children[i + 1];
84224
+ if (!(separator instanceof nodes_1.TokenNode) || !(name instanceof nodes_1.ExpressionNode) || type === undefined) {
84225
+ return undefined;
84226
+ }
84227
+ else if (separator.getFirstToken().getStr() === "->" && name.get() instanceof Expressions.AttributeName) {
84228
+ const attribute = procedure.identifierAt(name.getFirstToken());
84229
+ type = attribute instanceof _typed_identifier_1.TypedIdentifier ? attribute.getType() : undefined;
84230
+ }
84231
+ else if (separator.getFirstToken().getStr() === "-" && name.get() instanceof Expressions.ComponentName
84232
+ && type instanceof basic_1.StructureType) {
84233
+ type = type.getComponentByName(name.getFirstToken().getStr());
84234
+ }
84235
+ else {
84236
+ return undefined;
84237
+ }
84238
+ }
84239
+ return type;
84240
+ }
84241
+ /** value of a character literal, a character constant or a character component of a constant structure */
84242
+ constantValue(procedure, source) {
84243
+ var _a;
84244
+ var _b;
84245
+ if (source.findDirectExpression(Expressions.Constant) !== undefined) {
84246
+ return (0, _procedure_analysis_1.characterConstant)(procedure, source);
84247
+ }
84248
+ const chain = source.getChildren().length === 1 ? source.findDirectExpression(Expressions.FieldChain) : undefined;
84249
+ const children = (_b = chain === null || chain === void 0 ? void 0 : chain.getChildren()) !== null && _b !== void 0 ? _b : [];
84250
+ let identifier;
84251
+ let next;
84252
+ if (children[0] instanceof nodes_1.ExpressionNode && children[0].get() instanceof Expressions.SourceField) {
84253
+ identifier = procedure.identifierAt(children[0].getFirstToken());
84254
+ next = 1;
84255
+ }
84256
+ else if (children[0] instanceof nodes_1.ExpressionNode && children[0].get() instanceof Expressions.ClassName
84257
+ && ((_a = children[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "=>" && children[2] instanceof nodes_1.ExpressionNode
84258
+ && children[2].get() instanceof Expressions.AttributeName) {
84259
+ identifier = procedure.identifierAt(children[2].getFirstToken());
84260
+ next = 3;
84261
+ }
84262
+ else {
84263
+ return undefined;
84264
+ }
84265
+ if (!(identifier instanceof _typed_identifier_1.TypedIdentifier) || !(0, _procedure_analysis_1.isImmutable)(identifier)) {
84266
+ return undefined;
84267
+ }
84268
+ let type = identifier.getType();
84269
+ let value = identifier.getValue();
84270
+ if (children.length === next + 2) {
84271
+ const name = children[next + 1];
84272
+ if (children[next].getFirstToken().getStr() !== "-" || !(name instanceof nodes_1.ExpressionNode)
84273
+ || !(name.get() instanceof Expressions.ComponentName) || !(type instanceof basic_1.StructureType)
84274
+ || typeof value !== "object") {
84275
+ return undefined;
84276
+ }
84277
+ const component = name.getFirstToken().getStr().toLowerCase();
84278
+ type = type.getComponentByName(component);
84279
+ const key = Object.keys(value).find(k => k.toLowerCase() === component);
84280
+ value = key === undefined ? undefined : value[key];
84281
+ }
84282
+ else if (children.length !== next) {
84283
+ return undefined;
84284
+ }
84285
+ const text = typeof value === "string" ? (0, _procedure_analysis_1.textLiteral)(value) : undefined;
84286
+ if (!(type instanceof basic_1.CharacterType) || text === undefined) {
84287
+ return undefined;
84288
+ }
84289
+ // the value is cut to the length of the constant
84290
+ return text.substring(0, type.getLength());
84291
+ }
83709
84292
  }
83710
84293
  exports.ConstantCondition = ConstantCondition;
83711
84294
  //# sourceMappingURL=constant_condition.js.map
@@ -90667,6 +91250,210 @@ exports.Exporting = Exporting;
90667
91250
 
90668
91251
  /***/ },
90669
91252
 
91253
+ /***/ "../core/build/src/rules/field_symbol_never_assigned.js"
91254
+ /*!**************************************************************!*\
91255
+ !*** ../core/build/src/rules/field_symbol_never_assigned.js ***!
91256
+ \**************************************************************/
91257
+ (__unused_webpack_module, exports, __webpack_require__) {
91258
+
91259
+ "use strict";
91260
+
91261
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
91262
+ if (k2 === undefined) k2 = k;
91263
+ var desc = Object.getOwnPropertyDescriptor(m, k);
91264
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
91265
+ desc = { enumerable: true, get: function() { return m[k]; } };
91266
+ }
91267
+ Object.defineProperty(o, k2, desc);
91268
+ }) : (function(o, m, k, k2) {
91269
+ if (k2 === undefined) k2 = k;
91270
+ o[k2] = m[k];
91271
+ }));
91272
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
91273
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
91274
+ }) : function(o, v) {
91275
+ o["default"] = v;
91276
+ });
91277
+ var __importStar = (this && this.__importStar) || (function () {
91278
+ var ownKeys = function(o) {
91279
+ ownKeys = Object.getOwnPropertyNames || function (o) {
91280
+ var ar = [];
91281
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
91282
+ return ar;
91283
+ };
91284
+ return ownKeys(o);
91285
+ };
91286
+ return function (mod) {
91287
+ if (mod && mod.__esModule) return mod;
91288
+ var result = {};
91289
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
91290
+ __setModuleDefault(result, mod);
91291
+ return result;
91292
+ };
91293
+ })();
91294
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
91295
+ exports.FieldSymbolNeverAssigned = exports.FieldSymbolNeverAssignedConf = void 0;
91296
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
91297
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
91298
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
91299
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
91300
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
91301
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
91302
+ const token_node_1 = __webpack_require__(/*! ../abap/nodes/token_node */ "../core/build/src/abap/nodes/token_node.js");
91303
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
91304
+ class FieldSymbolNeverAssignedConf extends _basic_rule_config_1.BasicRuleConfig {
91305
+ }
91306
+ exports.FieldSymbolNeverAssignedConf = FieldSymbolNeverAssignedConf;
91307
+ class FieldSymbolNeverAssigned extends _abap_rule_1.ABAPRule {
91308
+ constructor() {
91309
+ super(...arguments);
91310
+ this.conf = new FieldSymbolNeverAssignedConf();
91311
+ }
91312
+ getMetadata() {
91313
+ return {
91314
+ key: "field_symbol_never_assigned",
91315
+ title: "Field symbol never assigned",
91316
+ shortDescription: `Reports a local field symbol that is used, but never assigned in its method, form or function module`,
91317
+ extendedInformation: `A field symbol declared with FIELD-SYMBOLS in a method, form or function module can only be
91318
+ assigned in that procedure. If no ASSIGN ... TO <fs> or ... ASSIGNING <fs> of it exists there,
91319
+ reading or writing it raises the runtime error GETWA_NOT_ASSIGNED. This is typically a copy-paste
91320
+ error, where a statement uses a field symbol other than the one assigned before it.
91321
+
91322
+ Assignments are ASSIGN, ASSIGN LOCAL COPY, and ASSIGNING of LOOP, READ TABLE, INSERT, APPEND,
91323
+ MODIFY and COLLECT, anywhere in the procedure. The order of the statements is not checked.
91324
+
91325
+ Not reported: field symbols only used in IS [NOT] ASSIGNED or UNASSIGN, field symbols declared
91326
+ with DEFAULT, inline declarations, global field symbols, and procedures that contain a macro
91327
+ call, an INCLUDE or a statement that cannot be parsed.`,
91328
+ tags: [_irule_1.RuleTag.SingleFile],
91329
+ badExample: `FIELD-SYMBOLS <type> TYPE ty_type.
91330
+ FIELD-SYMBOLS <attr> TYPE ty_attr.
91331
+ LOOP AT types ASSIGNING <type>.
91332
+ CLEAR <attr>-author.
91333
+ ENDLOOP.`,
91334
+ goodExample: `FIELD-SYMBOLS <type> TYPE ty_type.
91335
+ LOOP AT types ASSIGNING <type>.
91336
+ CLEAR <type>-author.
91337
+ ENDLOOP.`,
91338
+ };
91339
+ }
91340
+ getConfig() {
91341
+ return this.conf;
91342
+ }
91343
+ setConfig(conf) {
91344
+ this.conf = conf;
91345
+ }
91346
+ runParsed(file) {
91347
+ const issues = [];
91348
+ const statements = file.getStatements();
91349
+ let start = undefined;
91350
+ for (let i = 0; i < statements.length; i++) {
91351
+ const s = statements[i].get();
91352
+ if (s instanceof Statements.MethodImplementation
91353
+ || s instanceof Statements.Form
91354
+ || s instanceof Statements.FunctionModule) {
91355
+ start = i;
91356
+ }
91357
+ else if (start !== undefined
91358
+ && (s instanceof Statements.EndMethod
91359
+ || s instanceof Statements.EndForm
91360
+ || s instanceof Statements.EndFunction)) {
91361
+ issues.push(...this.checkProcedure(file, statements.slice(start, i + 1)));
91362
+ start = undefined;
91363
+ }
91364
+ }
91365
+ return issues;
91366
+ }
91367
+ ////////////////
91368
+ checkProcedure(file, statements) {
91369
+ var _a;
91370
+ const declared = new Map();
91371
+ const assigned = new Set();
91372
+ const used = new Map();
91373
+ for (const statement of statements) {
91374
+ const s = statement.get();
91375
+ if (s instanceof _statement_1.Unknown
91376
+ || s instanceof _statement_1.MacroCall
91377
+ || s instanceof Statements.Include) {
91378
+ return [];
91379
+ }
91380
+ else if (s instanceof Statements.FieldSymbol) {
91381
+ const name = (_a = statement.findDirectExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens();
91382
+ if (name !== undefined && statement.findDirectTokenByText("DEFAULT") === undefined) {
91383
+ declared.set(name.toUpperCase(), name);
91384
+ }
91385
+ continue;
91386
+ }
91387
+ else if (s instanceof Statements.Unassign) {
91388
+ continue;
91389
+ }
91390
+ this.walk(statement, assigned, used);
91391
+ }
91392
+ const issues = [];
91393
+ const procedure = this.procedureName(statements[0]);
91394
+ for (const [upper, name] of declared) {
91395
+ const token = used.get(upper);
91396
+ if (token === undefined || assigned.has(upper)) {
91397
+ continue;
91398
+ }
91399
+ const message = `Field symbol ${name} is never assigned in this ${procedure}`;
91400
+ issues.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
91401
+ }
91402
+ return issues;
91403
+ }
91404
+ /** collects the assigned field symbols, and the first use of each other field symbol */
91405
+ walk(node, assigned, used) {
91406
+ var _a;
91407
+ for (const child of node.getChildren()) {
91408
+ if (child instanceof token_node_1.TokenNode) {
91409
+ continue;
91410
+ }
91411
+ const e = child.get();
91412
+ if (e instanceof Expressions.FSTarget
91413
+ || e instanceof Expressions.InlineFS
91414
+ || (e instanceof Expressions.TargetFieldSymbol && this.isBinding(node))) {
91415
+ const name = (_a = child.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens();
91416
+ if (name !== undefined) {
91417
+ assigned.add(name.toUpperCase());
91418
+ }
91419
+ }
91420
+ else if (e instanceof Expressions.Compare && child.findDirectTokenByText("ASSIGNED") !== undefined) {
91421
+ continue;
91422
+ }
91423
+ else if (e instanceof Expressions.FieldSymbol) {
91424
+ const upper = child.concatTokens().toUpperCase();
91425
+ if (used.has(upper) === false) {
91426
+ used.set(upper, child.getFirstToken());
91427
+ }
91428
+ }
91429
+ else {
91430
+ this.walk(child, assigned, used);
91431
+ }
91432
+ }
91433
+ }
91434
+ /** TargetFieldSymbol directly in these binds the field symbol, elsewhere it is a write to the assigned data */
91435
+ isBinding(parent) {
91436
+ const p = parent.get();
91437
+ return p instanceof Statements.AssignLocalCopy
91438
+ || p instanceof Expressions.For
91439
+ || p instanceof Expressions.InlineLoopDefinition;
91440
+ }
91441
+ procedureName(statement) {
91442
+ const s = statement.get();
91443
+ if (s instanceof Statements.Form) {
91444
+ return "form";
91445
+ }
91446
+ else if (s instanceof Statements.FunctionModule) {
91447
+ return "function module";
91448
+ }
91449
+ return "method";
91450
+ }
91451
+ }
91452
+ exports.FieldSymbolNeverAssigned = FieldSymbolNeverAssigned;
91453
+ //# sourceMappingURL=field_symbol_never_assigned.js.map
91454
+
91455
+ /***/ },
91456
+
90670
91457
  /***/ "../core/build/src/rules/final_newline.js"
90671
91458
  /*!************************************************!*\
90672
91459
  !*** ../core/build/src/rules/final_newline.js ***!
@@ -92312,6 +93099,11 @@ class Conditions {
92312
93099
  }
92313
93100
  }
92314
93101
  class IdenticalConditionsConf extends _basic_rule_config_1.BasicRuleConfig {
93102
+ constructor() {
93103
+ super(...arguments);
93104
+ /** Report a comparison of an operand with itself, like a = a or a <> a */
93105
+ this.selfComparison = true;
93106
+ }
92315
93107
  }
92316
93108
  exports.IdenticalConditionsConf = IdenticalConditionsConf;
92317
93109
  class IdenticalConditions extends _abap_rule_1.ABAPRule {
@@ -92326,19 +93118,30 @@ class IdenticalConditions extends _abap_rule_1.ABAPRule {
92326
93118
  shortDescription: `Find identical conditions in IF + CASE + WHILE etc
92327
93119
 
92328
93120
  Prerequsites: code is pretty printed with identical cAsE`,
93121
+ extendedInformation: `Option selfComparison: reports a comparison with =, <>, <, >, <= or >= (and EQ, NE, LT, GT, LE, GE)
93122
+ whose two operands are the same data object, like a = a or ls_new-id <> ls_new-id. The comparison is always true or
93123
+ always false, usually one side should be another field.
93124
+
93125
+ Only operands that are data objects are compared: fields, components, attributes, field symbols, dereferences,
93126
+ offset/length and table expressions without calls. Not reported: method calls and built-in functions, which can
93127
+ return different values, literals like 1 = 1, ASSERT, and SQL conditions.`,
92329
93128
  tags: [_irule_1.RuleTag.SingleFile],
92330
93129
  badExample: `IF foo = bar OR 1 = a OR foo = bar.
92331
93130
  ENDIF.
92332
93131
  CASE bar.
92333
93132
  WHEN '1'.
92334
93133
  WHEN 'A' OR '1'.
92335
- ENDCASE.`,
93134
+ ENDCASE.
93135
+ IF ls_new-id = ls_new-id.
93136
+ ENDIF.`,
92336
93137
  goodExample: `IF foo = bar OR 1 = a.
92337
93138
  ENDIF.
92338
93139
  CASE bar.
92339
93140
  WHEN '1'.
92340
93141
  WHEN 'A'.
92341
- ENDCASE.`,
93142
+ ENDCASE.
93143
+ IF ls_new-id = ls_old-id.
93144
+ ENDIF.`,
92342
93145
  };
92343
93146
  }
92344
93147
  getConfig() {
@@ -92362,9 +93165,67 @@ ENDCASE.`,
92362
93165
  for (const i of structure.findAllExpressions(Expressions.Cond)) {
92363
93166
  issues = issues.concat(this.analyzeCond(file, i));
92364
93167
  }
93168
+ if (this.conf.selfComparison) {
93169
+ issues = issues.concat(this.analyzeSelfComparison(file));
93170
+ }
92365
93171
  return issues;
92366
93172
  }
92367
93173
  ////////////////
93174
+ analyzeSelfComparison(file) {
93175
+ const issues = [];
93176
+ for (const statement of file.getStatements()) {
93177
+ if (statement.get() instanceof Statements.Assert) {
93178
+ continue;
93179
+ }
93180
+ for (const compare of statement.findAllExpressionsRecursive(Expressions.Compare)) {
93181
+ const children = compare.getChildren();
93182
+ const negated = children[0] instanceof nodes_1.TokenNode && children[0].getFirstToken().getStr().toUpperCase() === "NOT";
93183
+ const rest = children.slice(negated ? 1 : 0);
93184
+ if (rest.length !== 3
93185
+ || !(rest[0] instanceof nodes_1.ExpressionNode) || !(rest[0].get() instanceof Expressions.Source)
93186
+ || !(rest[1] instanceof nodes_1.ExpressionNode) || !(rest[1].get() instanceof Expressions.CompareOperator)
93187
+ || !(rest[2] instanceof nodes_1.ExpressionNode) || !(rest[2].get() instanceof Expressions.Source)) {
93188
+ continue;
93189
+ }
93190
+ const operator = rest[1].concatTokens().toUpperCase().replace(/ /g, "");
93191
+ const value = this.selfValue(operator);
93192
+ const left = this.dataObject(rest[0]);
93193
+ if (value === undefined || left === undefined || left !== this.dataObject(rest[2])) {
93194
+ continue;
93195
+ }
93196
+ const result = value !== negated ? "true" : "false";
93197
+ const message = "Comparison is always " + result + ", " + rest[0].concatTokens() + " is compared with itself";
93198
+ issues.push(issue_1.Issue.atRange(file, compare.getFirstToken().getStart(), compare.getLastToken().getEnd(), message, this.getMetadata().key, this.conf.severity));
93199
+ }
93200
+ }
93201
+ return issues;
93202
+ }
93203
+ /** result of comparing a value with itself, undefined for operators like CO or CP */
93204
+ selfValue(operator) {
93205
+ if (["=", "EQ", "<=", "=<", "LE", ">=", "=>", "GE"].includes(operator)) {
93206
+ return true;
93207
+ }
93208
+ else if (["<>", "><", "NE", "<", "LT", ">", "GT"].includes(operator)) {
93209
+ return false;
93210
+ }
93211
+ return undefined;
93212
+ }
93213
+ /** the text of an operand that is a data object without calls, names in upper case, literals as they are */
93214
+ dataObject(source) {
93215
+ const children = source.getChildren();
93216
+ if (!(children[0] instanceof nodes_1.ExpressionNode) || !(children[0].get() instanceof Expressions.FieldChain)
93217
+ || (children.length === 2 && !(children[1].get() instanceof Expressions.Dereference))
93218
+ || children.length > 2
93219
+ || source.findFirstExpression(Expressions.MethodCall) !== undefined
93220
+ || source.findFirstExpression(Expressions.MethodCallChain) !== undefined
93221
+ || source.findFirstExpression(Expressions.NewObject) !== undefined) {
93222
+ return undefined;
93223
+ }
93224
+ return source.getTokens().map(t => {
93225
+ const str = t.getStr();
93226
+ return str.startsWith("'") || str.startsWith("`") || str.startsWith("|") || str.startsWith("}") ? str : str.toUpperCase();
93227
+ }).join(" ");
93228
+ }
92368
93229
  analyzeCond(file, node) {
92369
93230
  const conditions = new Conditions();
92370
93231
  let operator = "";
@@ -93990,6 +94851,7 @@ __exportStar(__webpack_require__(/*! ./cds_parser_error */ "../core/build/src/ru
93990
94851
  __exportStar(__webpack_require__(/*! ./chain_mainly_declarations */ "../core/build/src/rules/chain_mainly_declarations.js"), exports);
93991
94852
  __exportStar(__webpack_require__(/*! ./change_if_to_case */ "../core/build/src/rules/change_if_to_case.js"), exports);
93992
94853
  __exportStar(__webpack_require__(/*! ./changing_sorted_line */ "../core/build/src/rules/changing_sorted_line.js"), exports);
94854
+ __exportStar(__webpack_require__(/*! ./character_field_literal_blanks */ "../core/build/src/rules/character_field_literal_blanks.js"), exports);
93993
94855
  __exportStar(__webpack_require__(/*! ./check_abstract */ "../core/build/src/rules/check_abstract.js"), exports);
93994
94856
  __exportStar(__webpack_require__(/*! ./check_comments */ "../core/build/src/rules/check_comments.js"), exports);
93995
94857
  __exportStar(__webpack_require__(/*! ./check_ddic */ "../core/build/src/rules/check_ddic.js"), exports);
@@ -94031,6 +94893,7 @@ __exportStar(__webpack_require__(/*! ./else_after_all_returns */ "../core/build/
94031
94893
  __exportStar(__webpack_require__(/*! ./exit_or_check */ "../core/build/src/rules/exit_or_check.js"), exports);
94032
94894
  __exportStar(__webpack_require__(/*! ./expand_macros */ "../core/build/src/rules/expand_macros.js"), exports);
94033
94895
  __exportStar(__webpack_require__(/*! ./exporting */ "../core/build/src/rules/exporting.js"), exports);
94896
+ __exportStar(__webpack_require__(/*! ./field_symbol_never_assigned */ "../core/build/src/rules/field_symbol_never_assigned.js"), exports);
94034
94897
  __exportStar(__webpack_require__(/*! ./final_newline */ "../core/build/src/rules/final_newline.js"), exports);
94035
94898
  __exportStar(__webpack_require__(/*! ./fm_global_parameters_obsolete */ "../core/build/src/rules/fm_global_parameters_obsolete.js"), exports);
94036
94899
  __exportStar(__webpack_require__(/*! ./forbidden_identifier */ "../core/build/src/rules/forbidden_identifier.js"), exports);
@@ -94056,6 +94919,7 @@ __exportStar(__webpack_require__(/*! ./in_statement_indentation */ "../core/buil
94056
94919
  __exportStar(__webpack_require__(/*! ./indentation */ "../core/build/src/rules/indentation.js"), exports);
94057
94920
  __exportStar(__webpack_require__(/*! ./index_completely_contained */ "../core/build/src/rules/index_completely_contained.js"), exports);
94058
94921
  __exportStar(__webpack_require__(/*! ./inline_data_old_versions */ "../core/build/src/rules/inline_data_old_versions.js"), exports);
94922
+ __exportStar(__webpack_require__(/*! ./inline_generic_source */ "../core/build/src/rules/inline_generic_source.js"), exports);
94059
94923
  __exportStar(__webpack_require__(/*! ./inline_packed_computation */ "../core/build/src/rules/inline_packed_computation.js"), exports);
94060
94924
  __exportStar(__webpack_require__(/*! ./intf_referencing_clas */ "../core/build/src/rules/intf_referencing_clas.js"), exports);
94061
94925
  __exportStar(__webpack_require__(/*! ./invalid_table_index */ "../core/build/src/rules/invalid_table_index.js"), exports);
@@ -94069,6 +94933,7 @@ __exportStar(__webpack_require__(/*! ./line_only_punc */ "../core/build/src/rule
94069
94933
  __exportStar(__webpack_require__(/*! ./local_class_naming */ "../core/build/src/rules/local_class_naming.js"), exports);
94070
94934
  __exportStar(__webpack_require__(/*! ./local_testclass_consistency */ "../core/build/src/rules/local_testclass_consistency.js"), exports);
94071
94935
  __exportStar(__webpack_require__(/*! ./local_variable_names */ "../core/build/src/rules/local_variable_names.js"), exports);
94936
+ __exportStar(__webpack_require__(/*! ./loop_target_misuse */ "../core/build/src/rules/loop_target_misuse.js"), exports);
94072
94937
  __exportStar(__webpack_require__(/*! ./macro_naming */ "../core/build/src/rules/macro_naming.js"), exports);
94073
94938
  __exportStar(__webpack_require__(/*! ./main_file_contents */ "../core/build/src/rules/main_file_contents.js"), exports);
94074
94939
  __exportStar(__webpack_require__(/*! ./many_parentheses */ "../core/build/src/rules/many_parentheses.js"), exports);
@@ -94137,6 +95002,7 @@ __exportStar(__webpack_require__(/*! ./select_single_full_key */ "../core/build/
94137
95002
  __exportStar(__webpack_require__(/*! ./selection_screen_naming */ "../core/build/src/rules/selection_screen_naming.js"), exports);
94138
95003
  __exportStar(__webpack_require__(/*! ./selection_screen_texts_missing */ "../core/build/src/rules/selection_screen_texts_missing.js"), exports);
94139
95004
  __exportStar(__webpack_require__(/*! ./sequential_blank */ "../core/build/src/rules/sequential_blank.js"), exports);
95005
+ __exportStar(__webpack_require__(/*! ./sequential_read_sorted */ "../core/build/src/rules/sequential_read_sorted.js"), exports);
94140
95006
  __exportStar(__webpack_require__(/*! ./short_case */ "../core/build/src/rules/short_case.js"), exports);
94141
95007
  __exportStar(__webpack_require__(/*! ./sicf_consistency */ "../core/build/src/rules/sicf_consistency.js"), exports);
94142
95008
  __exportStar(__webpack_require__(/*! ./single_use_expression_temp */ "../core/build/src/rules/single_use_expression_temp.js"), exports);
@@ -94147,6 +95013,7 @@ __exportStar(__webpack_require__(/*! ./space_before_colon */ "../core/build/src/
94147
95013
  __exportStar(__webpack_require__(/*! ./space_before_dot */ "../core/build/src/rules/space_before_dot.js"), exports);
94148
95014
  __exportStar(__webpack_require__(/*! ./sql_escape_host_variables */ "../core/build/src/rules/sql_escape_host_variables.js"), exports);
94149
95015
  __exportStar(__webpack_require__(/*! ./sql_value_conversion */ "../core/build/src/rules/sql_value_conversion.js"), exports);
95016
+ __exportStar(__webpack_require__(/*! ./stale_subrc */ "../core/build/src/rules/stale_subrc.js"), exports);
94150
95017
  __exportStar(__webpack_require__(/*! ./start_at_tab */ "../core/build/src/rules/start_at_tab.js"), exports);
94151
95018
  __exportStar(__webpack_require__(/*! ./static_call_via_instance */ "../core/build/src/rules/static_call_via_instance.js"), exports);
94152
95019
  __exportStar(__webpack_require__(/*! ./strict_sql */ "../core/build/src/rules/strict_sql.js"), exports);
@@ -94162,6 +95029,7 @@ __exportStar(__webpack_require__(/*! ./try_without_catch */ "../core/build/src/r
94162
95029
  __exportStar(__webpack_require__(/*! ./type_form_parameters */ "../core/build/src/rules/type_form_parameters.js"), exports);
94163
95030
  __exportStar(__webpack_require__(/*! ./types_naming */ "../core/build/src/rules/types_naming.js"), exports);
94164
95031
  __exportStar(__webpack_require__(/*! ./uncaught_exception */ "../core/build/src/rules/uncaught_exception.js"), exports);
95032
+ __exportStar(__webpack_require__(/*! ./unit_test_assertions */ "../core/build/src/rules/unit_test_assertions.js"), exports);
94165
95033
  __exportStar(__webpack_require__(/*! ./unknown_types */ "../core/build/src/rules/unknown_types.js"), exports);
94166
95034
  __exportStar(__webpack_require__(/*! ./unnecessary_chaining */ "../core/build/src/rules/unnecessary_chaining.js"), exports);
94167
95035
  __exportStar(__webpack_require__(/*! ./unnecessary_copy */ "../core/build/src/rules/unnecessary_copy.js"), exports);
@@ -94375,6 +95243,186 @@ exports.InlineDataOldVersions = InlineDataOldVersions;
94375
95243
 
94376
95244
  /***/ },
94377
95245
 
95246
+ /***/ "../core/build/src/rules/inline_generic_source.js"
95247
+ /*!********************************************************!*\
95248
+ !*** ../core/build/src/rules/inline_generic_source.js ***!
95249
+ \********************************************************/
95250
+ (__unused_webpack_module, exports, __webpack_require__) {
95251
+
95252
+ "use strict";
95253
+
95254
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
95255
+ if (k2 === undefined) k2 = k;
95256
+ var desc = Object.getOwnPropertyDescriptor(m, k);
95257
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
95258
+ desc = { enumerable: true, get: function() { return m[k]; } };
95259
+ }
95260
+ Object.defineProperty(o, k2, desc);
95261
+ }) : (function(o, m, k, k2) {
95262
+ if (k2 === undefined) k2 = k;
95263
+ o[k2] = m[k];
95264
+ }));
95265
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
95266
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
95267
+ }) : function(o, v) {
95268
+ o["default"] = v;
95269
+ });
95270
+ var __importStar = (this && this.__importStar) || (function () {
95271
+ var ownKeys = function(o) {
95272
+ ownKeys = Object.getOwnPropertyNames || function (o) {
95273
+ var ar = [];
95274
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
95275
+ return ar;
95276
+ };
95277
+ return ownKeys(o);
95278
+ };
95279
+ return function (mod) {
95280
+ if (mod && mod.__esModule) return mod;
95281
+ var result = {};
95282
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
95283
+ __setModuleDefault(result, mod);
95284
+ return result;
95285
+ };
95286
+ })();
95287
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
95288
+ exports.InlineGenericSource = exports.InlineGenericSourceConf = void 0;
95289
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
95290
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
95291
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
95292
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
95293
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
95294
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
95295
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
95296
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
95297
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
95298
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
95299
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
95300
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
95301
+ class InlineGenericSourceConf extends _basic_rule_config_1.BasicRuleConfig {
95302
+ }
95303
+ exports.InlineGenericSourceConf = InlineGenericSourceConf;
95304
+ class InlineGenericSource {
95305
+ constructor() {
95306
+ this.conf = new InlineGenericSourceConf();
95307
+ }
95308
+ getMetadata() {
95309
+ return {
95310
+ key: "inline_generic_source",
95311
+ title: "Inline declaration from a generically typed source",
95312
+ shortDescription: `Finds inline declarations whose value is a generically typed parameter or field symbol`,
95313
+ extendedInformation: `DATA( ) or FINAL( ) takes the type of the source. When the source is a parameter or
95314
+ field symbol with a generic type, the type is fixed when the program is compiled: string for clike and
95315
+ csequence, xstring for xsequence. The syntax check warns "The fixed type STRING is used for the generic
95316
+ type CLIKE".
95317
+
95318
+ Reported for DATA(var) = source and FINAL(var) = source when the source is just the parameter or field
95319
+ symbol. Most other generic types cannot be made concrete, that is a syntax error which check_syntax reports.
95320
+
95321
+ Declare the variable with a type, or name the type with CONV.
95322
+
95323
+ The pragma ##TYPE, which hides the syntax check warning, also hides this issue.
95324
+
95325
+ prefer_inline does not suggest inline declarations for generic sources, this rule reports the ones
95326
+ that exist.
95327
+
95328
+ https://help.sap.com/doc/abapdocu_758_index_htm/7.58/en-US/abapmove.htm`,
95329
+ tags: [_irule_1.RuleTag.Quickfix],
95330
+ pragma: "##TYPE",
95331
+ badExample: `METHOD m. " IMPORTING iv TYPE clike
95332
+ DATA(lv) = iv.
95333
+ ENDMETHOD.`,
95334
+ goodExample: `METHOD m. " IMPORTING iv TYPE clike
95335
+ DATA(lv) = CONV string( iv ).
95336
+ ENDMETHOD.`,
95337
+ };
95338
+ }
95339
+ getConfig() {
95340
+ return this.conf;
95341
+ }
95342
+ setConfig(conf) {
95343
+ this.conf = conf;
95344
+ }
95345
+ initialize(reg) {
95346
+ this.reg = reg;
95347
+ return this;
95348
+ }
95349
+ run(obj) {
95350
+ var _a, _b, _c;
95351
+ if (!(obj instanceof _abap_object_1.ABAPObject)) {
95352
+ return [];
95353
+ }
95354
+ const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
95355
+ if (syntax.issues.length > 0) {
95356
+ return [];
95357
+ }
95358
+ const issues = [];
95359
+ for (const file of obj.getABAPFiles()) {
95360
+ for (const statement of file.getStatements()) {
95361
+ if (!(statement.get() instanceof Statements.Move)
95362
+ || statement.getPragmas().some(p => p.getStr().toUpperCase() === this.getMetadata().pragma)) {
95363
+ continue;
95364
+ }
95365
+ const inline = (_a = statement.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.InlineData);
95366
+ const name = (_b = inline === null || inline === void 0 ? void 0 : inline.findDirectExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
95367
+ const operand = this.singleOperand(statement.findDirectExpression(Expressions.Source));
95368
+ if (name === undefined || operand === undefined) {
95369
+ continue;
95370
+ }
95371
+ const scope = syntax.spaghetti.lookupPosition(name.getStart(), file.getFilename());
95372
+ const resolved = (_c = scope === null || scope === void 0 ? void 0 : scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.DataReadReference
95373
+ && reference.position.getStart().equals(operand.getFirstToken().getStart()))) === null || _c === void 0 ? void 0 : _c.resolved;
95374
+ if (!(resolved instanceof _typed_identifier_1.TypedIdentifier)) {
95375
+ continue;
95376
+ }
95377
+ const fixed = this.fixedType(resolved.getType());
95378
+ if (fixed === undefined) {
95379
+ continue;
95380
+ }
95381
+ const message = `The fixed type ${fixed.fixed} is used for the generic type ${fixed.generic} of "${operand.concatTokens()}", ` +
95382
+ `declare "${name.getStr()}" with a type or use CONV`;
95383
+ const replacement = `CONV ${fixed.conv}( ${operand.concatTokens()} )`;
95384
+ const fix = edit_helper_1.EditHelper.replaceRange(file, operand.getFirstToken().getStart(), operand.getLastToken().getEnd(), replacement);
95385
+ issues.push(issue_1.Issue.atToken(file, name, message, this.getMetadata().key, this.conf.severity, fix));
95386
+ }
95387
+ }
95388
+ return issues;
95389
+ }
95390
+ /** The source when it is a single field or field symbol, without components, offset/length or dereference */
95391
+ singleOperand(source) {
95392
+ if (source === undefined || source.getChildren().length !== 1) {
95393
+ return undefined;
95394
+ }
95395
+ const chain = source.findDirectExpression(Expressions.FieldChain);
95396
+ if (chain === undefined || chain.getChildren().length !== 1) {
95397
+ return undefined;
95398
+ }
95399
+ const first = chain.getFirstChild();
95400
+ if (first instanceof nodes_1.ExpressionNode
95401
+ && (first.get() instanceof Expressions.SourceField || first.get() instanceof Expressions.SourceFieldSymbol)) {
95402
+ return chain;
95403
+ }
95404
+ return undefined;
95405
+ }
95406
+ /** The type the system uses for a generic type in an inline declaration, undefined if the type is not generic,
95407
+ * or is a generic type that check_syntax does not make concrete */
95408
+ fixedType(type) {
95409
+ if (type instanceof basic_1.CLikeType) {
95410
+ return { generic: "CLIKE", fixed: "STRING", conv: "string" };
95411
+ }
95412
+ else if (type instanceof basic_1.CSequenceType) {
95413
+ return { generic: "CSEQUENCE", fixed: "STRING", conv: "string" };
95414
+ }
95415
+ else if (type instanceof basic_1.XSequenceType) {
95416
+ return { generic: "XSEQUENCE", fixed: "XSTRING", conv: "xstring" };
95417
+ }
95418
+ return undefined;
95419
+ }
95420
+ }
95421
+ exports.InlineGenericSource = InlineGenericSource;
95422
+ //# sourceMappingURL=inline_generic_source.js.map
95423
+
95424
+ /***/ },
95425
+
94378
95426
  /***/ "../core/build/src/rules/inline_packed_computation.js"
94379
95427
  /*!************************************************************!*\
94380
95428
  !*** ../core/build/src/rules/inline_packed_computation.js ***!
@@ -96344,6 +97392,317 @@ exports.LocalVariableNames = LocalVariableNames;
96344
97392
 
96345
97393
  /***/ },
96346
97394
 
97395
+ /***/ "../core/build/src/rules/loop_target_misuse.js"
97396
+ /*!*****************************************************!*\
97397
+ !*** ../core/build/src/rules/loop_target_misuse.js ***!
97398
+ \*****************************************************/
97399
+ (__unused_webpack_module, exports, __webpack_require__) {
97400
+
97401
+ "use strict";
97402
+
97403
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
97404
+ if (k2 === undefined) k2 = k;
97405
+ var desc = Object.getOwnPropertyDescriptor(m, k);
97406
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
97407
+ desc = { enumerable: true, get: function() { return m[k]; } };
97408
+ }
97409
+ Object.defineProperty(o, k2, desc);
97410
+ }) : (function(o, m, k, k2) {
97411
+ if (k2 === undefined) k2 = k;
97412
+ o[k2] = m[k];
97413
+ }));
97414
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
97415
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
97416
+ }) : function(o, v) {
97417
+ o["default"] = v;
97418
+ });
97419
+ var __importStar = (this && this.__importStar) || (function () {
97420
+ var ownKeys = function(o) {
97421
+ ownKeys = Object.getOwnPropertyNames || function (o) {
97422
+ var ar = [];
97423
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
97424
+ return ar;
97425
+ };
97426
+ return ownKeys(o);
97427
+ };
97428
+ return function (mod) {
97429
+ if (mod && mod.__esModule) return mod;
97430
+ var result = {};
97431
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
97432
+ __setModuleDefault(result, mod);
97433
+ return result;
97434
+ };
97435
+ })();
97436
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
97437
+ exports.LoopTargetMisuse = exports.LoopTargetMisuseConf = void 0;
97438
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
97439
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
97440
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
97441
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
97442
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
97443
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
97444
+ class LoopTargetMisuseConf extends _basic_rule_config_1.BasicRuleConfig {
97445
+ constructor() {
97446
+ super(...arguments);
97447
+ /** Report a LOOP inside a LOOP with the same target, when the outer loop body uses the target after the inner ENDLOOP */
97448
+ this.nestedLoop = true;
97449
+ /** Report LOOP AT ... INTO <fs> and READ TABLE ... INTO <fs> when the local field symbol is only bound by ASSIGNING,
97450
+ * so the statement overwrites a table row */
97451
+ this.intoFieldSymbol = true;
97452
+ }
97453
+ }
97454
+ exports.LoopTargetMisuseConf = LoopTargetMisuseConf;
97455
+ class LoopTargetMisuse extends _abap_rule_1.ABAPRule {
97456
+ constructor() {
97457
+ super(...arguments);
97458
+ this.conf = new LoopTargetMisuseConf();
97459
+ }
97460
+ getMetadata() {
97461
+ return {
97462
+ key: "loop_target_misuse",
97463
+ title: "LOOP and READ TABLE targets used wrongly",
97464
+ shortDescription: `Reports a nested LOOP that reuses the target of the enclosing LOOP, and INTO <fs> where ASSIGNING was meant`,
97465
+ extendedInformation: `Option nestedLoop: a LOOP inside a LOOP with the same INTO, REFERENCE INTO or ASSIGNING target.
97466
+ After the inner ENDLOOP, the target holds the last row of the inner table, not the row of the
97467
+ outer loop. Reported when the outer loop body uses the target after the inner ENDLOOP, before
97468
+ it is assigned again.
97469
+ Not reported: a target of a loop that has already ended, a target that is not a plain variable
97470
+ or field symbol, an enclosing LOOP with GROUP BY, and a target the outer loop body does not use
97471
+ after the inner loop.
97472
+
97473
+ Option intoFieldSymbol: LOOP AT ... INTO <fs> or READ TABLE ... INTO <fs>. INTO copies the row
97474
+ into the data object the field symbol points to. When <fs> was bound by ASSIGNING, that data
97475
+ object is a row of a table, and the statement overwrites it. ASSIGNING was meant.
97476
+ Reported only for a field symbol declared in the method, form or function module, and only when
97477
+ no ASSIGN and no STRUCTURE ... DEFAULT binds it there, so it can only point to a table row.`,
97478
+ tags: [_irule_1.RuleTag.SingleFile],
97479
+ badExample: `LOOP AT lt_header INTO ls_row.
97480
+ LOOP AT lt_items INTO ls_row WHERE parent = ls_row-id.
97481
+ lv_sum = lv_sum + ls_row-amount.
97482
+ ENDLOOP.
97483
+ ls_row-amount = lv_sum.
97484
+ APPEND ls_row TO lt_result.
97485
+ ENDLOOP.
97486
+
97487
+ LOOP AT lt_a ASSIGNING <ls_a>.
97488
+ ENDLOOP.
97489
+ READ TABLE lt_a INTO <ls_a> INDEX 1.`,
97490
+ goodExample: `LOOP AT lt_header INTO ls_row.
97491
+ LOOP AT lt_items INTO ls_item WHERE parent = ls_row-id.
97492
+ lv_sum = lv_sum + ls_item-amount.
97493
+ ENDLOOP.
97494
+ ls_row-amount = lv_sum.
97495
+ APPEND ls_row TO lt_result.
97496
+ ENDLOOP.
97497
+
97498
+ LOOP AT lt_a ASSIGNING <ls_a>.
97499
+ ENDLOOP.
97500
+ READ TABLE lt_a ASSIGNING <ls_a> INDEX 1.`,
97501
+ };
97502
+ }
97503
+ getConfig() {
97504
+ return this.conf;
97505
+ }
97506
+ setConfig(conf) {
97507
+ this.conf = conf;
97508
+ }
97509
+ runParsed(file) {
97510
+ const issues = [];
97511
+ const statements = file.getStatements();
97512
+ if (this.conf.nestedLoop !== false) {
97513
+ issues.push(...this.checkNestedLoop(file, statements));
97514
+ }
97515
+ if (this.conf.intoFieldSymbol !== false) {
97516
+ issues.push(...this.checkIntoFieldSymbol(file, statements));
97517
+ }
97518
+ return issues;
97519
+ }
97520
+ ////////////////
97521
+ checkNestedLoop(file, statements) {
97522
+ const issues = [];
97523
+ // one entry per open LOOP, key undefined when the LOOP has no target to compare
97524
+ let open = [];
97525
+ for (let i = 0; i < statements.length; i++) {
97526
+ const statement = statements[i];
97527
+ const s = statement.get();
97528
+ if (this.isBlockBoundary(statement)) {
97529
+ open = [];
97530
+ }
97531
+ else if (s instanceof Statements.EndLoop) {
97532
+ open.pop();
97533
+ }
97534
+ else if (s instanceof Statements.Loop) {
97535
+ const node = this.loopTarget(statement);
97536
+ const target = node ? this.targetName(node) : undefined;
97537
+ // INTO <fs> inside LOOP ... ASSIGNING <fs> is left to the option intoFieldSymbol
97538
+ const key = target === undefined ? undefined : ((node === null || node === void 0 ? void 0 : node.get()) instanceof Expressions.Target ? "INTO " : "ASSIGNING ") + target;
97539
+ const outer = key === undefined ? undefined : [...open].reverse().find(o => o.key === key);
97540
+ if (node !== undefined && target !== undefined && outer !== undefined) {
97541
+ const innerEnd = this.findEndLoop(statements, i);
97542
+ const outerEnd = this.findEndLoop(statements, outer.index);
97543
+ if (innerEnd !== undefined && outerEnd !== undefined && this.usedBetween(statements, innerEnd + 1, outerEnd, target)) {
97544
+ const name = node.concatTokens();
97545
+ const message = `Inner LOOP reuses ${name}, the target of the enclosing LOOP, `
97546
+ + `which is used after the inner ENDLOOP and then holds a row of the inner table`;
97547
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
97548
+ }
97549
+ }
97550
+ const grouped = statement.findDirectExpression(Expressions.LoopGroupBy) !== undefined;
97551
+ open.push({ index: i, key: grouped ? undefined : key });
97552
+ }
97553
+ }
97554
+ return issues;
97555
+ }
97556
+ /** the Target or FSTarget after INTO, REFERENCE INTO or ASSIGNING of a LOOP */
97557
+ loopTarget(statement) {
97558
+ const target = statement.findDirectExpression(Expressions.LoopTarget);
97559
+ return (target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.Target)) || (target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.FSTarget));
97560
+ }
97561
+ /** upper case name of a Target or FSTarget that is a plain variable or field symbol, also declared inline */
97562
+ targetName(node) {
97563
+ var _a, _b;
97564
+ const inline = ((_a = node.findDirectExpression(Expressions.InlineData)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.TargetField))
97565
+ || ((_b = node.findDirectExpression(Expressions.InlineFS)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.TargetFieldSymbol));
97566
+ const tokens = (inline || node).getAllTokens();
97567
+ return tokens.length === 1 ? tokens[0].getStr().toUpperCase() : undefined;
97568
+ }
97569
+ /** index of the ENDLOOP that closes the LOOP at the index */
97570
+ findEndLoop(statements, index) {
97571
+ let depth = 0;
97572
+ for (let i = index + 1; i < statements.length && this.isBlockBoundary(statements[i]) === false; i++) {
97573
+ const s = statements[i].get();
97574
+ if (s instanceof Statements.Loop) {
97575
+ depth++;
97576
+ }
97577
+ else if (s instanceof Statements.EndLoop) {
97578
+ if (depth === 0) {
97579
+ return i;
97580
+ }
97581
+ depth--;
97582
+ }
97583
+ }
97584
+ return undefined;
97585
+ }
97586
+ /** true when a statement in [from, to) uses the variable before a statement assigns all of it */
97587
+ usedBetween(statements, from, to, name) {
97588
+ for (let i = from; i < to; i++) {
97589
+ const statement = statements[i];
97590
+ const s = statement.get();
97591
+ if (s instanceof Statements.Data || s instanceof Statements.FieldSymbol) {
97592
+ continue;
97593
+ }
97594
+ const whole = new Set();
97595
+ for (const t of [...statement.findAllExpressions(Expressions.Target), ...statement.findAllExpressions(Expressions.FSTarget)]) {
97596
+ if (this.targetName(t) === name) {
97597
+ t.getAllTokens().forEach(token => whole.add(token));
97598
+ }
97599
+ }
97600
+ const tokens = statement.getTokens();
97601
+ for (let j = 0; j < tokens.length; j++) {
97602
+ const previous = j > 0 ? tokens[j - 1].getStr() : "";
97603
+ if (tokens[j].getStr().toUpperCase() === name
97604
+ && whole.has(tokens[j]) === false
97605
+ && ["-", "->", "=>", "~"].includes(previous) === false) {
97606
+ return s instanceof Statements.Unassign ? false : true;
97607
+ }
97608
+ }
97609
+ if (whole.size > 0) {
97610
+ return false;
97611
+ }
97612
+ }
97613
+ return false;
97614
+ }
97615
+ checkIntoFieldSymbol(file, statements) {
97616
+ const issues = [];
97617
+ for (let i = 0; i < statements.length; i++) {
97618
+ const statement = statements[i];
97619
+ const s = statement.get();
97620
+ if (!(s instanceof Statements.Loop) && !(s instanceof Statements.ReadTable)) {
97621
+ continue;
97622
+ }
97623
+ const target = statement.findDirectExpression(Expressions.LoopTarget)
97624
+ || statement.findDirectExpression(Expressions.ReadTableTarget);
97625
+ const into = target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.Target);
97626
+ const fs = into === null || into === void 0 ? void 0 : into.findDirectExpression(Expressions.TargetFieldSymbol);
97627
+ if (into === undefined || fs === undefined || fs.concatTokens() !== into.concatTokens()) {
97628
+ continue;
97629
+ }
97630
+ const name = fs.concatTokens().toUpperCase();
97631
+ if (this.onlyBoundToRows(statements, i, name) === false) {
97632
+ continue;
97633
+ }
97634
+ const what = s instanceof Statements.Loop ? "LOOP AT" : "READ TABLE";
97635
+ const message = `${what} ... INTO ${fs.concatTokens()} overwrites the row the field symbol points to, use ASSIGNING`;
97636
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
97637
+ }
97638
+ return issues;
97639
+ }
97640
+ /** true when the field symbol is declared in the block around the statement and every binding of it
97641
+ * in that block is an ASSIGNING, so it can only point to a table row */
97642
+ onlyBoundToRows(statements, index, name) {
97643
+ var _a;
97644
+ let start = index;
97645
+ while (start > 0 && this.isBlockBoundary(statements[start]) === false) {
97646
+ start--;
97647
+ }
97648
+ if (this.startsBlock(statements[start]) === false) {
97649
+ return false;
97650
+ }
97651
+ let declared = false;
97652
+ let assigning = false;
97653
+ for (let i = start + 1; i < statements.length && this.endsBlock(statements[i]) === false; i++) {
97654
+ const statement = statements[i];
97655
+ if (statement.get() instanceof Statements.FieldSymbol) {
97656
+ if (((_a = statement.findDirectExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === name) {
97657
+ if (statement.findDirectTokenByText("DEFAULT") !== undefined) {
97658
+ return false;
97659
+ }
97660
+ declared = true;
97661
+ }
97662
+ continue;
97663
+ }
97664
+ for (const fsTarget of statement.findAllExpressions(Expressions.FSTarget)) {
97665
+ if (this.fsName(fsTarget) !== name) {
97666
+ continue;
97667
+ }
97668
+ if (statement.get() instanceof Statements.Assign) {
97669
+ return false;
97670
+ }
97671
+ assigning = true;
97672
+ if (fsTarget.findDirectExpression(Expressions.InlineFS) !== undefined) {
97673
+ declared = true;
97674
+ }
97675
+ }
97676
+ }
97677
+ return declared && assigning;
97678
+ }
97679
+ fsName(fsTarget) {
97680
+ var _a;
97681
+ return (_a = fsTarget.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
97682
+ }
97683
+ isBlockBoundary(statement) {
97684
+ return this.startsBlock(statement) || this.endsBlock(statement);
97685
+ }
97686
+ startsBlock(statement) {
97687
+ const s = statement.get();
97688
+ return s instanceof Statements.MethodImplementation
97689
+ || s instanceof Statements.Form
97690
+ || s instanceof Statements.FunctionModule
97691
+ || s instanceof Statements.Module;
97692
+ }
97693
+ endsBlock(statement) {
97694
+ const s = statement.get();
97695
+ return s instanceof Statements.EndMethod
97696
+ || s instanceof Statements.EndForm
97697
+ || s instanceof Statements.EndFunction
97698
+ || s instanceof Statements.EndModule;
97699
+ }
97700
+ }
97701
+ exports.LoopTargetMisuse = LoopTargetMisuse;
97702
+ //# sourceMappingURL=loop_target_misuse.js.map
97703
+
97704
+ /***/ },
97705
+
96347
97706
  /***/ "../core/build/src/rules/macro_naming.js"
96348
97707
  /*!***********************************************!*\
96349
97708
  !*** ../core/build/src/rules/macro_naming.js ***!
@@ -105279,6 +106638,12 @@ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_i
105279
106638
  const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
105280
106639
  const version_1 = __webpack_require__(/*! ../version */ "../core/build/src/version.js");
105281
106640
  class RedundantConversionConf extends _basic_rule_config_1.BasicRuleConfig {
106641
+ constructor() {
106642
+ super(...arguments);
106643
+ /** Also report a CONV that is the whole right-hand side of an assignment whose target already has the
106644
+ * conversion type, e.g. "count = CONV i( text )." with count TYPE i, the assignment converts by itself */
106645
+ this.assignmentTarget = true;
106646
+ }
105282
106647
  }
105283
106648
  exports.RedundantConversionConf = RedundantConversionConf;
105284
106649
  class RedundantConversion {
@@ -105291,7 +106656,12 @@ class RedundantConversion {
105291
106656
  title: "Redundant Conversion",
105292
106657
  shortDescription: `Find redundant CONV expressions`,
105293
106658
  extendedInformation: `Reports CONV expressions whose operand already has the conversion's target type,
105294
- including the result of a built-in function with a fixed result type, like to_upper( ) or strlen( ).`,
106659
+ including the result of a built-in function with a fixed result type, like to_upper( ) or strlen( ).
106660
+
106661
+ With option assignmentTarget, also reports a CONV that is the whole right-hand side of an assignment
106662
+ whose target already has the conversion's type, "count = CONV i( text )." with count TYPE i, the
106663
+ assignment converts by itself. Not reported for inline declarations, enumerated types, LET, and operands
106664
+ with a generic type.`,
105295
106665
  tags: [_irule_1.RuleTag.Quickfix],
105296
106666
  badExample: `DATA text TYPE string.
105297
106667
  text = CONV string( text ).`,
@@ -105351,7 +106721,11 @@ text = text.`,
105351
106721
  }
105352
106722
  const operandHasSameType = operandType !== undefined && this.sameType(target.getType(), operandType);
105353
106723
  const arithmeticHasSameContext = this.arithmeticUsesSameTargetType(source, bodySource, file, scope, target.getType());
105354
- if (operandHasSameType === false && arithmeticHasSameContext === false) {
106724
+ const assignmentHasSameType = this.conf.assignmentTarget !== false
106725
+ && this.assignmentTargetHasSameType(source, file, scope, target.getType());
106726
+ if (operandHasSameType === false
106727
+ && arithmeticHasSameContext === false
106728
+ && assignmentHasSameType === false) {
105355
106729
  continue;
105356
106730
  }
105357
106731
  const closingParen = source.getDirectTokens().find(token => token.getStr() === ")" && token.getStart().isAfter(bodySource.getLastToken().getStart()));
@@ -105386,6 +106760,88 @@ text = text.`,
105386
106760
  return assignmentTarget instanceof _typed_identifier_1.TypedIdentifier
105387
106761
  && this.sameType(conversionType, assignmentTarget.getType());
105388
106762
  }
106763
+ /** "target = CONV i( text )." where target has the conversion type, the assignment converts the same way */
106764
+ assignmentTargetHasSameType(conversion, file, scope, conversionType) {
106765
+ var _a;
106766
+ // CONV converts the base type to an enumerated type, a plain assignment does not compile
106767
+ if (conversionType instanceof basic_1.EnumType) {
106768
+ return false;
106769
+ }
106770
+ const body = conversion.findDirectExpression(Expressions.ConvBody);
106771
+ if (body === undefined
106772
+ || body.findDirectExpression(Expressions.Let) !== undefined
106773
+ // "CONV type ( body )" without a trailing operator
106774
+ || conversion.getChildren().length !== 5) {
106775
+ return false;
106776
+ }
106777
+ // "target = CONV ...", not "+=", "?=", "a = b = CONV ..." or MOVE
106778
+ const statement = file.getStatements().find(candidate => candidate.includesToken(conversion.getFirstToken()));
106779
+ const children = (_a = statement === null || statement === void 0 ? void 0 : statement.getChildren()) !== null && _a !== void 0 ? _a : [];
106780
+ const target = children[0];
106781
+ if (!((statement === null || statement === void 0 ? void 0 : statement.get()) instanceof Statements.Move)
106782
+ || children.length !== 4
106783
+ || !(target instanceof nodes_1.ExpressionNode)
106784
+ || !(target.get() instanceof Expressions.Target)
106785
+ || children[1].concatTokens() !== "="
106786
+ || children[2] !== conversion) {
106787
+ return false;
106788
+ }
106789
+ // a generic operand gets its type from the CONV, also "ref->*" with ref TYPE REF TO data
106790
+ const bodyStart = body.getFirstToken().getStart();
106791
+ const bodyEnd = body.getLastToken().getEnd();
106792
+ const genericOperand = scope.getData().references.some(reference => {
106793
+ if (reference.referenceType !== _reference_1.ReferenceType.DataReadReference
106794
+ || reference.position.getFilename() !== file.getFilename()
106795
+ || reference.position.getStart().isBetween(bodyStart, bodyEnd) === false
106796
+ || !(reference.resolved instanceof _typed_identifier_1.TypedIdentifier)) {
106797
+ return false;
106798
+ }
106799
+ const type = reference.resolved.getType();
106800
+ return type.isGeneric() || (type instanceof basic_1.DataReference && type.getType().isGeneric());
106801
+ });
106802
+ if (genericOperand === true) {
106803
+ return false;
106804
+ }
106805
+ const targetType = this.targetType(target, scope);
106806
+ return targetType !== undefined && this.sameType(conversionType, targetType);
106807
+ }
106808
+ /** Type of a variable, field symbol, attribute or structure component, undefined for anything else */
106809
+ targetType(target, scope) {
106810
+ var _a;
106811
+ let type;
106812
+ for (const child of target.getChildren()) {
106813
+ if (child instanceof nodes_1.TokenNode) {
106814
+ if (["-", "->", "=>"].includes(child.getFirstToken().getStr()) === false) {
106815
+ return undefined;
106816
+ }
106817
+ }
106818
+ else if (child.get() instanceof Expressions.TargetField
106819
+ || child.get() instanceof Expressions.TargetFieldSymbol
106820
+ || child.get() instanceof Expressions.AttributeName) {
106821
+ const resolved = (_a = scope.getData().references.find(reference => (reference.referenceType === _reference_1.ReferenceType.DataWriteReference
106822
+ || reference.referenceType === _reference_1.ReferenceType.DataReadReference)
106823
+ && reference.position.getStart().equals(child.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
106824
+ if (!(resolved instanceof _typed_identifier_1.TypedIdentifier)) {
106825
+ return undefined;
106826
+ }
106827
+ type = resolved.getType();
106828
+ }
106829
+ else if (child.get() instanceof Expressions.ComponentName) {
106830
+ if (type instanceof basic_1.TableType) {
106831
+ type = type.getRowType();
106832
+ }
106833
+ if (!(type instanceof basic_1.StructureType)) {
106834
+ return undefined;
106835
+ }
106836
+ type = type.getComponentByName(child.concatTokens());
106837
+ }
106838
+ else if (!(child.get() instanceof Expressions.ClassName)) {
106839
+ // inline declarations, dereferences, table expressions, offsets and lengths
106840
+ return undefined;
106841
+ }
106842
+ }
106843
+ return type;
106844
+ }
105389
106845
  sourceType(source, scope) {
105390
106846
  let context;
105391
106847
  // boolc( <condition> ) is not a MethodCallChain, xsdbool( ) has the same shape but is not reported
@@ -106783,6 +108239,334 @@ exports.SequentialBlank = SequentialBlank;
106783
108239
 
106784
108240
  /***/ },
106785
108241
 
108242
+ /***/ "../core/build/src/rules/sequential_read_sorted.js"
108243
+ /*!*********************************************************!*\
108244
+ !*** ../core/build/src/rules/sequential_read_sorted.js ***!
108245
+ \*********************************************************/
108246
+ (__unused_webpack_module, exports, __webpack_require__) {
108247
+
108248
+ "use strict";
108249
+
108250
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
108251
+ if (k2 === undefined) k2 = k;
108252
+ var desc = Object.getOwnPropertyDescriptor(m, k);
108253
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
108254
+ desc = { enumerable: true, get: function() { return m[k]; } };
108255
+ }
108256
+ Object.defineProperty(o, k2, desc);
108257
+ }) : (function(o, m, k, k2) {
108258
+ if (k2 === undefined) k2 = k;
108259
+ o[k2] = m[k];
108260
+ }));
108261
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
108262
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
108263
+ }) : function(o, v) {
108264
+ o["default"] = v;
108265
+ });
108266
+ var __importStar = (this && this.__importStar) || (function () {
108267
+ var ownKeys = function(o) {
108268
+ ownKeys = Object.getOwnPropertyNames || function (o) {
108269
+ var ar = [];
108270
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
108271
+ return ar;
108272
+ };
108273
+ return ownKeys(o);
108274
+ };
108275
+ return function (mod) {
108276
+ if (mod && mod.__esModule) return mod;
108277
+ var result = {};
108278
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
108279
+ __setModuleDefault(result, mod);
108280
+ return result;
108281
+ };
108282
+ })();
108283
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
108284
+ exports.SequentialReadSorted = exports.SequentialReadSortedConf = void 0;
108285
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
108286
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
108287
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
108288
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
108289
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
108290
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
108291
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
108292
+ const _key_compare_1 = __webpack_require__(/*! ../abap/5_syntax/_key_compare */ "../core/build/src/abap/5_syntax/_key_compare.js");
108293
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
108294
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
108295
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
108296
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
108297
+ const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
108298
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
108299
+ class SequentialReadSortedConf extends _basic_rule_config_1.BasicRuleConfig {
108300
+ constructor() {
108301
+ super(...arguments);
108302
+ this.severity = severity_1.Severity.Warning;
108303
+ }
108304
+ }
108305
+ exports.SequentialReadSortedConf = SequentialReadSortedConf;
108306
+ class SequentialReadSorted {
108307
+ constructor() {
108308
+ this.conf = new SequentialReadSortedConf();
108309
+ }
108310
+ getMetadata() {
108311
+ return {
108312
+ key: "sequential_read_sorted",
108313
+ title: "Sequential read on a sorted table",
108314
+ shortDescription: `A WHERE condition or a free key on a sorted table that does not use the primary key`,
108315
+ extendedInformation: `A sorted table is read with a binary search only when the condition fixes an initial part of
108316
+ its key. When the first key component is not compared with = or EQ (or IS INITIAL) in a part of the condition joined
108317
+ by AND, every line is read, like on a standard table. The SAP check "Low Performance Operations on Internal Tables"
108318
+ reports this as "Possible sequential read on a sorted table".
108319
+
108320
+ Checked: LOOP AT ... WHERE, DELETE ... WHERE, MODIFY ... WHERE, READ TABLE ... WITH KEY and table expressions
108321
+ itab[ comp = ... ], on a table whose type is statically known as SORTED with explicit key components, using the
108322
+ primary key.
108323
+
108324
+ Not checked: standard, hashed, generic and unknown table types, tables with a default key, a dynamic WHERE or
108325
+ dynamic components, WITH TABLE KEY, a named key (USING KEY, KEY ... COMPONENTS) other than primary_key,
108326
+ READ TABLE ... BINARY SEARCH and access by index, including LOOP AT and DELETE with FROM or TO.
108327
+
108328
+ Fix: compare the first key component with =, change the key or the table type, or add a secondary key.
108329
+ If the sequential read is intended, add the pseudo comment "#EC CI_SORTSEQ to the statement.`,
108330
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Performance],
108331
+ pseudoComment: "EC CI_SORTSEQ",
108332
+ badExample: `DATA lt_nodes TYPE SORTED TABLE OF ty_node WITH UNIQUE KEY path name.
108333
+ LOOP AT lt_nodes INTO ls_node WHERE name = lv_name.
108334
+ ENDLOOP.
108335
+ DELETE lt_nodes WHERE path CP lv_pattern.`,
108336
+ goodExample: `DATA lt_nodes TYPE SORTED TABLE OF ty_node WITH UNIQUE KEY path name.
108337
+ LOOP AT lt_nodes INTO ls_node WHERE path = lv_path AND name = lv_name.
108338
+ ENDLOOP.
108339
+ DELETE lt_nodes WHERE path CP lv_pattern. "#EC CI_SORTSEQ`,
108340
+ };
108341
+ }
108342
+ getConfig() {
108343
+ return this.conf;
108344
+ }
108345
+ initialize(reg) {
108346
+ this.reg = reg;
108347
+ return this;
108348
+ }
108349
+ setConfig(conf) {
108350
+ this.conf = conf;
108351
+ }
108352
+ run(obj) {
108353
+ if (!(obj instanceof _abap_object_1.ABAPObject) || obj.getType() === "INTF") {
108354
+ return [];
108355
+ }
108356
+ const issues = [];
108357
+ let spaghetti = undefined;
108358
+ for (const file of obj.getABAPFiles()) {
108359
+ const statements = file.getStatements();
108360
+ const pseudoRows = this.findPseudoCommentRows(statements);
108361
+ for (const statement of statements) {
108362
+ const get = statement.get();
108363
+ if (get instanceof _statement_1.Comment) {
108364
+ continue;
108365
+ }
108366
+ const isWhere = get instanceof Statements.Loop
108367
+ || get instanceof Statements.DeleteInternal
108368
+ || get instanceof Statements.ModifyInternal;
108369
+ const isRead = get instanceof Statements.ReadTable;
108370
+ if (isWhere === false
108371
+ && isRead === false
108372
+ && statement.findFirstExpression(Expressions.TableExpression) === undefined) {
108373
+ continue;
108374
+ }
108375
+ if (this.hasPseudoComment(statement, pseudoRows)) {
108376
+ continue;
108377
+ }
108378
+ if (spaghetti === undefined) {
108379
+ spaghetti = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti;
108380
+ }
108381
+ if (isWhere === true) {
108382
+ this.checkWhere(statement, spaghetti, file, issues);
108383
+ }
108384
+ else if (isRead === true) {
108385
+ this.checkReadTable(statement, spaghetti, file, issues);
108386
+ }
108387
+ this.checkTableExpressions(statement, statement, spaghetti, file, issues);
108388
+ }
108389
+ }
108390
+ return issues;
108391
+ }
108392
+ ////////////////
108393
+ findPseudoCommentRows(statements) {
108394
+ const rows = new Set();
108395
+ for (const s of statements) {
108396
+ if (s.get() instanceof _statement_1.Comment && s.concatTokens().toUpperCase().includes(this.getMetadata().pseudoComment + "")) {
108397
+ rows.add(s.getStart().getRow());
108398
+ }
108399
+ }
108400
+ return rows;
108401
+ }
108402
+ /** the pseudo comment is accepted on any row of the statement */
108403
+ hasPseudoComment(statement, pseudoRows) {
108404
+ for (let row = statement.getStart().getRow(); row <= statement.getEnd().getRow(); row++) {
108405
+ if (pseudoRows.has(row)) {
108406
+ return true;
108407
+ }
108408
+ }
108409
+ return false;
108410
+ }
108411
+ /** LOOP AT, DELETE and MODIFY with a static WHERE condition */
108412
+ checkWhere(statement, spaghetti, file, issues) {
108413
+ var _a;
108414
+ const cond = statement.findDirectExpression(Expressions.ComponentCond);
108415
+ if (cond === undefined || this.usesPrimaryKey(statement) === false) {
108416
+ return;
108417
+ }
108418
+ let table;
108419
+ if (statement.get() instanceof Statements.Loop) {
108420
+ table = (_a = statement.findDirectExpression(Expressions.LoopSource)) === null || _a === void 0 ? void 0 : _a.getFirstChild();
108421
+ }
108422
+ else {
108423
+ table = statement.findDirectExpression(Expressions.Target);
108424
+ }
108425
+ if (table === undefined) {
108426
+ return;
108427
+ }
108428
+ if (!(statement.get() instanceof Statements.ModifyInternal)
108429
+ && (statement.findDirectTokenByText("FROM") !== undefined || statement.findDirectTokenByText("TO") !== undefined)) {
108430
+ // an index range
108431
+ return;
108432
+ }
108433
+ const first = this.firstKeyComponent(this.findType(table, spaghetti, file));
108434
+ if (first !== undefined && (0, _key_compare_1.hasKeyCompare)(cond, first) === false) {
108435
+ this.report(statement, table.concatTokens(), first, file, issues);
108436
+ }
108437
+ }
108438
+ checkReadTable(statement, spaghetti, file, issues) {
108439
+ var _a;
108440
+ if (statement.findTokenSequencePosition("WITH", "KEY") === undefined
108441
+ || statement.findDirectTokenByText("COMPONENTS") !== undefined
108442
+ || statement.findDirectTokenByText("BINARY") !== undefined) {
108443
+ return;
108444
+ }
108445
+ const compare = statement.findDirectExpression(Expressions.ComponentCompareSimple);
108446
+ const table = (_a = statement.findDirectExpression(Expressions.SimpleSource2)) !== null && _a !== void 0 ? _a : statement.findDirectExpression(Expressions.Source);
108447
+ if (compare === undefined || table === undefined) {
108448
+ return;
108449
+ }
108450
+ const first = this.firstKeyComponent(this.findType(table, spaghetti, file));
108451
+ if (first !== undefined && this.hasFreeKeyComponent(compare, first) === false) {
108452
+ this.report(statement, table.concatTokens(), first, file, issues);
108453
+ }
108454
+ }
108455
+ /** table expressions with a free key, itab[ comp = ... ], anywhere in the statement */
108456
+ checkTableExpressions(node, statement, spaghetti, file, issues) {
108457
+ var _a;
108458
+ const children = node.getChildren();
108459
+ for (let i = 0; i < children.length; i++) {
108460
+ const child = children[i];
108461
+ if (child instanceof nodes_1.TokenNode) {
108462
+ continue;
108463
+ }
108464
+ if (child.get() instanceof Expressions.TableExpression
108465
+ && child instanceof nodes_1.ExpressionNode
108466
+ && (node.get() instanceof Expressions.FieldChain || node.get() instanceof Expressions.Target)
108467
+ && ((_a = child.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.ComponentChainSimple) {
108468
+ // a free key, not an index and not a named key: KEY name [COMPONENTS]
108469
+ const first = this.firstKeyComponent(this.findChainType(children.slice(0, i), spaghetti, file));
108470
+ if (first !== undefined && this.hasFreeKeyComponent(child, first) === false) {
108471
+ const name = children.slice(0, i).map(c => c.concatTokens()).join("");
108472
+ this.report(statement, name, first, file, issues);
108473
+ }
108474
+ }
108475
+ this.checkTableExpressions(child, statement, spaghetti, file, issues);
108476
+ }
108477
+ }
108478
+ report(statement, name, first, file, issues) {
108479
+ const message = `Sequential read on sorted table ${name}, the first key component ${first} is not compared with =, ` +
108480
+ `add it to the condition or "#EC CI_SORTSEQ`;
108481
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
108482
+ }
108483
+ /** false if USING KEY names a key other than the primary key, or a dynamic one */
108484
+ usesPrimaryKey(statement) {
108485
+ if (statement.findDirectTokenByText("USING") === undefined) {
108486
+ return true;
108487
+ }
108488
+ const keyName = statement.findExpressionAfterToken("KEY");
108489
+ return (keyName === null || keyName === void 0 ? void 0 : keyName.get()) instanceof Expressions.SimpleName && keyName.concatTokens().toUpperCase() === "PRIMARY_KEY";
108490
+ }
108491
+ /** true if a free key, ComponentCompareSimple or the fields of a TableExpression, specifies the component;
108492
+ * also true when a component is dynamic, as it cannot be decided */
108493
+ hasFreeKeyComponent(node, component) {
108494
+ if (node.findDirectExpression(Expressions.Dynamic) !== undefined) {
108495
+ return true;
108496
+ }
108497
+ return node.findDirectExpressions(Expressions.ComponentChainSimple)
108498
+ .some(c => c.concatTokens().toUpperCase().replace(/\s+/g, "") === component);
108499
+ }
108500
+ /** The first component of the primary key of a sorted table with explicit key components, else undefined */
108501
+ firstKeyComponent(type) {
108502
+ var _a, _b;
108503
+ if (!(type instanceof basic_1.TableType)
108504
+ || type.getAccessType() !== basic_1.TableAccessType.sorted
108505
+ || type.getOptions().keyType !== basic_1.TableKeyType.user
108506
+ || type.isGeneric()) {
108507
+ return undefined;
108508
+ }
108509
+ return (_b = (_a = type.getOptions().primaryKey) === null || _a === void 0 ? void 0 : _a.keyFields[0]) === null || _b === void 0 ? void 0 : _b.toUpperCase();
108510
+ }
108511
+ findType(node, spaghetti, file) {
108512
+ if (!(node.get() instanceof Expressions.Target)) {
108513
+ const chain = node.getChildren().length === 1 ? node.findDirectExpression(Expressions.FieldChain) : undefined;
108514
+ if (chain === undefined) {
108515
+ return undefined;
108516
+ }
108517
+ node = chain;
108518
+ }
108519
+ return this.findChainType(node.getChildren(), spaghetti, file);
108520
+ }
108521
+ /** The type of a chain of names, components, attributes, dereferences and table expressions, else undefined */
108522
+ findChainType(children, spaghetti, file) {
108523
+ var _a;
108524
+ let type = undefined;
108525
+ for (const child of children) {
108526
+ const get = child.get();
108527
+ if (get instanceof Expressions.SourceField
108528
+ || get instanceof Expressions.SourceFieldSymbol
108529
+ || get instanceof Expressions.TargetField
108530
+ || get instanceof Expressions.TargetFieldSymbol
108531
+ || get instanceof Expressions.AttributeName) {
108532
+ type = (_a = this.findReference(child.getFirstToken().getStart(), spaghetti, file)) === null || _a === void 0 ? void 0 : _a.getType();
108533
+ }
108534
+ else if (get instanceof Expressions.ComponentName) {
108535
+ type = type instanceof basic_1.StructureType ? type.getComponentByName(child.concatTokens()) : undefined;
108536
+ }
108537
+ else if (get instanceof Expressions.Dereference) {
108538
+ type = type instanceof basic_1.DataReference ? type.getType() : undefined;
108539
+ }
108540
+ else if (get instanceof Expressions.TableExpression) {
108541
+ type = type instanceof basic_1.TableType ? type.getRowType() : undefined;
108542
+ }
108543
+ else if (get instanceof Expressions.ClassName || get instanceof tokens_1.StaticArrow) {
108544
+ continue;
108545
+ }
108546
+ else if (!(get instanceof tokens_1.Dash) && !(get instanceof tokens_1.InstanceArrow)) {
108547
+ return undefined;
108548
+ }
108549
+ if (type === undefined) {
108550
+ return undefined;
108551
+ }
108552
+ }
108553
+ return type;
108554
+ }
108555
+ findReference(start, spaghetti, file) {
108556
+ const scope = spaghetti.lookupPosition(start, file.getFilename());
108557
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
108558
+ if (r.position.getStart().equals(start) && r.resolved instanceof _typed_identifier_1.TypedIdentifier) {
108559
+ return r.resolved;
108560
+ }
108561
+ }
108562
+ return undefined;
108563
+ }
108564
+ }
108565
+ exports.SequentialReadSorted = SequentialReadSorted;
108566
+ //# sourceMappingURL=sequential_read_sorted.js.map
108567
+
108568
+ /***/ },
108569
+
106786
108570
  /***/ "../core/build/src/rules/short_case.js"
106787
108571
  /*!*********************************************!*\
106788
108572
  !*** ../core/build/src/rules/short_case.js ***!
@@ -108573,6 +110357,192 @@ exports.SQLValueConversion = SQLValueConversion;
108573
110357
 
108574
110358
  /***/ },
108575
110359
 
110360
+ /***/ "../core/build/src/rules/stale_subrc.js"
110361
+ /*!**********************************************!*\
110362
+ !*** ../core/build/src/rules/stale_subrc.js ***!
110363
+ \**********************************************/
110364
+ (__unused_webpack_module, exports, __webpack_require__) {
110365
+
110366
+ "use strict";
110367
+
110368
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
110369
+ if (k2 === undefined) k2 = k;
110370
+ var desc = Object.getOwnPropertyDescriptor(m, k);
110371
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
110372
+ desc = { enumerable: true, get: function() { return m[k]; } };
110373
+ }
110374
+ Object.defineProperty(o, k2, desc);
110375
+ }) : (function(o, m, k, k2) {
110376
+ if (k2 === undefined) k2 = k;
110377
+ o[k2] = m[k];
110378
+ }));
110379
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
110380
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
110381
+ }) : function(o, v) {
110382
+ o["default"] = v;
110383
+ });
110384
+ var __importStar = (this && this.__importStar) || (function () {
110385
+ var ownKeys = function(o) {
110386
+ ownKeys = Object.getOwnPropertyNames || function (o) {
110387
+ var ar = [];
110388
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
110389
+ return ar;
110390
+ };
110391
+ return ownKeys(o);
110392
+ };
110393
+ return function (mod) {
110394
+ if (mod && mod.__esModule) return mod;
110395
+ var result = {};
110396
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
110397
+ __setModuleDefault(result, mod);
110398
+ return result;
110399
+ };
110400
+ })();
110401
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
110402
+ exports.StaleSubrc = exports.StaleSubrcConf = void 0;
110403
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
110404
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
110405
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
110406
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
110407
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
110408
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
110409
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
110410
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
110411
+ const _builtin_1 = __webpack_require__(/*! ../abap/5_syntax/_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
110412
+ class StaleSubrcConf extends _basic_rule_config_1.BasicRuleConfig {
110413
+ constructor() {
110414
+ super(...arguments);
110415
+ this.severity = severity_1.Severity.Warning;
110416
+ }
110417
+ }
110418
+ exports.StaleSubrcConf = StaleSubrcConf;
110419
+ class StaleSubrc extends _abap_rule_1.ABAPRule {
110420
+ constructor() {
110421
+ super(...arguments);
110422
+ this.conf = new StaleSubrcConf();
110423
+ }
110424
+ getMetadata() {
110425
+ return {
110426
+ key: "stale_subrc",
110427
+ title: "sy-subrc checked after a method call",
110428
+ shortDescription: `Reports IF, CHECK, ASSERT or CASE on sy-subrc directly after a method call without EXCEPTIONS`,
110429
+ extendedInformation: `A method call without EXCEPTIONS does not set sy-subrc. After the call, sy-subrc holds whatever
110430
+ the last statement inside the method set, so the check depends on the method's implementation
110431
+ and breaks silently when the method changes.
110432
+
110433
+ Check the result of the method instead, eg. a returning parameter or an exception, or move the
110434
+ check directly after the statement that sets sy-subrc.
110435
+
110436
+ Reported: the statement directly before the check is a method call, CALL METHOD, or an
110437
+ assignment with a method call or NEW in its source.
110438
+
110439
+ Not reported: a call with EXCEPTIONS or EXCEPTION-TABLE, an assignment that only calls built-in
110440
+ functions like lines( ), and any other statement before the check, eg. CALL FUNCTION or
110441
+ CREATE OBJECT, a check that is the first statement of a block, or a check after ENDIF.
110442
+ An assignment or CLEAR without a call does not change sy-subrc, so a check after it still
110443
+ reads the statement before it, which is not reported either.
110444
+ See also check_subrc and subrc_after_assign.`,
110445
+ tags: [_irule_1.RuleTag.SingleFile],
110446
+ badExample: `lv_parent = read_parent( ).
110447
+ IF sy-subrc = 0.
110448
+ WRITE lv_parent.
110449
+ ENDIF.`,
110450
+ goodExample: `lv_parent = read_parent( ).
110451
+ IF lv_parent IS NOT INITIAL.
110452
+ WRITE lv_parent.
110453
+ ENDIF.`,
110454
+ };
110455
+ }
110456
+ getConfig() {
110457
+ return this.conf;
110458
+ }
110459
+ setConfig(conf) {
110460
+ this.conf = conf;
110461
+ }
110462
+ runParsed(file) {
110463
+ const issues = [];
110464
+ const statements = file.getStatements();
110465
+ for (let i = 0; i < statements.length; i++) {
110466
+ const statement = statements[i];
110467
+ if (this.isSubrcCheck(statement) === false) {
110468
+ continue;
110469
+ }
110470
+ const previous = this.previousStatement(i, statements);
110471
+ if (previous === undefined || this.isCallWithoutExceptions(previous) === false) {
110472
+ continue;
110473
+ }
110474
+ const message = "sy-subrc checked after a method call without EXCEPTIONS, the call does not set sy-subrc";
110475
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
110476
+ }
110477
+ return issues;
110478
+ }
110479
+ ////////////////
110480
+ isSubrcCheck(statement) {
110481
+ const s = statement.get();
110482
+ if (!(s instanceof Statements.If
110483
+ || s instanceof Statements.Check
110484
+ || s instanceof Statements.Assert
110485
+ || s instanceof Statements.Case)) {
110486
+ return false;
110487
+ }
110488
+ return this.readsSubrc(statement);
110489
+ }
110490
+ readsSubrc(statement) {
110491
+ for (const field of statement.findAllExpressions(Expressions.FieldChain)) {
110492
+ if (field.concatTokens().toUpperCase() === "SY-SUBRC") {
110493
+ return true;
110494
+ }
110495
+ }
110496
+ return false;
110497
+ }
110498
+ /** the statement directly before, skipping comments */
110499
+ previousStatement(index, statements) {
110500
+ for (let i = index - 1; i >= 0; i--) {
110501
+ if (statements[i].get() instanceof _statement_1.Comment) {
110502
+ continue;
110503
+ }
110504
+ return statements[i];
110505
+ }
110506
+ return undefined;
110507
+ }
110508
+ /** a standalone method call, or an assignment with a method call or NEW in its source */
110509
+ isCallWithoutExceptions(statement) {
110510
+ const s = statement.get();
110511
+ if (s instanceof Statements.Call) {
110512
+ return this.hasClassicExceptions(statement) === false;
110513
+ }
110514
+ else if (!(s instanceof Statements.Move) || this.hasClassicExceptions(statement) === true) {
110515
+ return false;
110516
+ }
110517
+ if (statement.findFirstExpression(Expressions.NewObject) !== undefined) {
110518
+ return true;
110519
+ }
110520
+ const tokens = statement.getTokens();
110521
+ for (const call of statement.findAllExpressions(Expressions.MethodCall)) {
110522
+ const name = call.getFirstToken();
110523
+ const index = tokens.indexOf(name);
110524
+ const before = index > 0 ? tokens[index - 1].getStr() : "";
110525
+ if (before === "->" || before === "=>" || _builtin_1.BuiltIn.methods[name.getStr().toUpperCase()] === undefined) {
110526
+ return true;
110527
+ }
110528
+ }
110529
+ return false;
110530
+ }
110531
+ hasClassicExceptions(statement) {
110532
+ for (const token of statement.getTokens()) {
110533
+ const str = token.getStr().toUpperCase();
110534
+ if (str === "EXCEPTIONS" || str === "EXCEPTION-TABLE") {
110535
+ return true;
110536
+ }
110537
+ }
110538
+ return false;
110539
+ }
110540
+ }
110541
+ exports.StaleSubrc = StaleSubrc;
110542
+ //# sourceMappingURL=stale_subrc.js.map
110543
+
110544
+ /***/ },
110545
+
108576
110546
  /***/ "../core/build/src/rules/start_at_tab.js"
108577
110547
  /*!***********************************************!*\
108578
110548
  !*** ../core/build/src/rules/start_at_tab.js ***!
@@ -110320,271 +112290,544 @@ var __importStar = (this && this.__importStar) || (function () {
110320
112290
  };
110321
112291
  })();
110322
112292
  Object.defineProperty(exports, "__esModule", ({ value: true }));
110323
- exports.UncaughtException = exports.UncaughtExceptionConf = void 0;
110324
- const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
110325
- const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
110326
- const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
112293
+ exports.UncaughtException = exports.UncaughtExceptionConf = void 0;
112294
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
112295
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
112296
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
112297
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
112298
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
112299
+ const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
112300
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
112301
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
112302
+ const objects_1 = __webpack_require__(/*! ../objects */ "../core/build/src/objects/index.js");
112303
+ const ddic_1 = __webpack_require__(/*! ../ddic */ "../core/build/src/ddic.js");
112304
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
112305
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
112306
+ const types_1 = __webpack_require__(/*! ../abap/types */ "../core/build/src/abap/types/index.js");
112307
+ class UncaughtExceptionConf extends _basic_rule_config_1.BasicRuleConfig {
112308
+ constructor() {
112309
+ super(...arguments);
112310
+ this.reportDynamic = false;
112311
+ this.reportNoCheck = false;
112312
+ }
112313
+ }
112314
+ exports.UncaughtExceptionConf = UncaughtExceptionConf;
112315
+ class UncaughtException extends _abap_rule_1.ABAPRule {
112316
+ constructor() {
112317
+ super(...arguments);
112318
+ this.conf = new UncaughtExceptionConf();
112319
+ this.issues = [];
112320
+ }
112321
+ getMetadata() {
112322
+ return {
112323
+ key: "uncaught_exception",
112324
+ title: "Uncaught Exception",
112325
+ shortDescription: `Checks for uncaught static exception`,
112326
+ extendedInformation: `Does not report any issues if the code contains syntax errors`,
112327
+ tags: [_irule_1.RuleTag.Syntax],
112328
+ };
112329
+ }
112330
+ getConfig() {
112331
+ return this.conf;
112332
+ }
112333
+ initialize(reg) {
112334
+ super.initialize(reg);
112335
+ this.findGlobalExceptions();
112336
+ return this;
112337
+ }
112338
+ setConfig(conf) {
112339
+ this.conf = conf;
112340
+ }
112341
+ runParsed(file, obj) {
112342
+ if (obj.getType() === "INTF") { // nothing can be raised in interfaces
112343
+ return [];
112344
+ }
112345
+ if (obj instanceof objects_1.Program && obj.isInclude() === true) {
112346
+ return [];
112347
+ }
112348
+ const stru = file.getStructure();
112349
+ if (stru === undefined) {
112350
+ return [];
112351
+ }
112352
+ this.findLocalExceptions(obj);
112353
+ this.syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
112354
+ if (this.syntax.issues.length > 0) {
112355
+ return [];
112356
+ }
112357
+ this.issues = [];
112358
+ this.sinked = undefined;
112359
+ for (const c of stru.getChildren()) {
112360
+ this.traverse(c, file);
112361
+ }
112362
+ return this.issues;
112363
+ }
112364
+ traverse(n, file) {
112365
+ var _a, _b, _c, _d, _e;
112366
+ const get = n.get();
112367
+ if (get instanceof Structures.ClassDefinition
112368
+ || get instanceof Structures.Interface) {
112369
+ return; // to optimize performance
112370
+ }
112371
+ if (n instanceof nodes_1.StructureNode) {
112372
+ if (get instanceof Structures.Try) {
112373
+ // note that TRY-CATCH might be arbitrarily nested
112374
+ const previous = this.sinked ? this.sinked.slice() : undefined;
112375
+ this.addFromTryStructure(n);
112376
+ for (const c of ((_a = n.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.getChildren()) || []) {
112377
+ this.traverse(c, file);
112378
+ }
112379
+ this.sinked = previous;
112380
+ for (const catchStructure of n.findDirectStructures(Structures.Catch)) {
112381
+ for (const c of catchStructure.getChildren()) {
112382
+ this.traverse(c, file);
112383
+ }
112384
+ }
112385
+ for (const c of ((_b = n.findDirectStructure(Structures.Cleanup)) === null || _b === void 0 ? void 0 : _b.getChildren()) || []) {
112386
+ this.traverse(c, file);
112387
+ }
112388
+ }
112389
+ else {
112390
+ for (const c of n.getChildren()) {
112391
+ this.traverse(c, file);
112392
+ }
112393
+ }
112394
+ }
112395
+ else if (n instanceof nodes_1.StatementNode) {
112396
+ if (get instanceof Statements.MethodImplementation) {
112397
+ this.setSinkedFromMethod(n, file);
112398
+ }
112399
+ else if (get instanceof Statements.EndMethod) {
112400
+ this.sinked = undefined; // back to top level
112401
+ }
112402
+ else if (get instanceof Statements.Form) {
112403
+ this.sinked = [];
112404
+ const raising = n.findDirectExpression(Expressions.FormRaising);
112405
+ for (const c of (raising === null || raising === void 0 ? void 0 : raising.findAllExpressions(Expressions.ClassName)) || []) {
112406
+ this.sinked.push(c.concatTokens().toUpperCase());
112407
+ }
112408
+ }
112409
+ else if (get instanceof Statements.EndForm) {
112410
+ this.sinked = undefined; // back to top level
112411
+ }
112412
+ else if (get instanceof Statements.Raise) {
112413
+ let name = undefined;
112414
+ const concat = n.concatTokens().toUpperCase();
112415
+ if (concat.startsWith("RAISE EXCEPTION TYPE ")) {
112416
+ name = (_c = n.findFirstExpression(Expressions.ClassName)) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase();
112417
+ }
112418
+ else if (concat.startsWith("RAISE EXCEPTION NEW ")) {
112419
+ name = (_e = (_d = n.findFirstExpression(Expressions.NewObject)) === null || _d === void 0 ? void 0 : _d.findFirstExpression(Expressions.TypeNameOrInfer)) === null || _e === void 0 ? void 0 : _e.getFirstToken().getStr().toUpperCase();
112420
+ // todo: else its a normal Source, infer the type from it
112421
+ }
112422
+ this.check(name, n, file);
112423
+ }
112424
+ else if (get instanceof Statements.Perform) {
112425
+ // todo, PERFORM, or is this not statically checked?
112426
+ }
112427
+ else {
112428
+ this.checkForMethodCalls(n, file);
112429
+ }
112430
+ }
112431
+ }
112432
+ ////////////////////////////////
112433
+ check(name, n, file) {
112434
+ if (this.isSinked(name) === false) {
112435
+ const issue = issue_1.Issue.atStatement(file, n, "Uncaught exception " + name, this.getMetadata().key, this.getConfig().severity);
112436
+ this.issues.push(issue);
112437
+ }
112438
+ }
112439
+ checkForMethodCalls(n, file) {
112440
+ const start = n.getFirstToken().getStart();
112441
+ const end = n.getLastToken().getEnd();
112442
+ const scope = this.syntax.spaghetti.lookupPosition(start, file.getFilename());
112443
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
112444
+ if (r.referenceType === _reference_1.ReferenceType.MethodReference
112445
+ && r.position.getStart().isAfter(start)
112446
+ && r.position.getEnd().isBefore(end)
112447
+ && r.resolved instanceof types_1.MethodDefinition) {
112448
+ for (const name of r.resolved.getRaising()) {
112449
+ this.check(name, n, file);
112450
+ }
112451
+ }
112452
+ else if (r.referenceType === _reference_1.ReferenceType.ConstructorReference
112453
+ && r.position.getStart().isAfter(start)
112454
+ && r.position.getEnd().isBefore(end)
112455
+ && r.resolved instanceof types_1.ClassDefinition) {
112456
+ const method = this.findConstructor(r.resolved, scope);
112457
+ for (const name of (method === null || method === void 0 ? void 0 : method.getRaising()) || []) {
112458
+ this.check(name, n, file);
112459
+ }
112460
+ }
112461
+ }
112462
+ }
112463
+ findConstructor(def, scope) {
112464
+ for (const method of def.getMethodDefinitions().getAll()) {
112465
+ if (method instanceof types_1.MethodDefinition && method.getName().toUpperCase() === "CONSTRUCTOR") {
112466
+ return method;
112467
+ }
112468
+ }
112469
+ const sup = def.getSuperClass();
112470
+ if (sup === undefined) {
112471
+ return undefined;
112472
+ }
112473
+ const superDefinition = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(sup);
112474
+ return superDefinition ? this.findConstructor(superDefinition, scope) : undefined;
112475
+ }
112476
+ addFromTryStructure(s) {
112477
+ if (this.sinked === undefined) {
112478
+ return;
112479
+ }
112480
+ for (const structure of s.findDirectStructures(Structures.Catch)) {
112481
+ const c = structure.findDirectStatement(Statements.Catch);
112482
+ if (c === undefined) {
112483
+ continue;
112484
+ }
112485
+ for (const cn of c.findDirectExpressions(Expressions.ClassName)) {
112486
+ this.sinked.push(cn.concatTokens());
112487
+ }
112488
+ }
112489
+ }
112490
+ setSinkedFromMethod(s, file) {
112491
+ this.sinked = [];
112492
+ const scope = this.syntax.spaghetti.lookupPosition(s.getLastToken().getEnd(), file.getFilename());
112493
+ let def = undefined;
112494
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
112495
+ // there should be only one, so the first is okay
112496
+ if (r.referenceType === _reference_1.ReferenceType.MethodImplementationReference
112497
+ && r.resolved instanceof types_1.MethodDefinition) {
112498
+ def = r.resolved;
112499
+ break;
112500
+ }
112501
+ }
112502
+ if (def === undefined) {
112503
+ return; // this should not occur, so just report everything as errors
112504
+ }
112505
+ def.getRaising().forEach(r => { var _a; return (_a = this.sinked) === null || _a === void 0 ? void 0 : _a.push(r); });
112506
+ }
112507
+ isSinked(name) {
112508
+ if (this.sinked === undefined || name === undefined) {
112509
+ return true;
112510
+ }
112511
+ const sup = this.globalExceptions[name.toUpperCase()];
112512
+ if (sup === "CX_DYNAMIC_CHECK" && this.getConfig().reportDynamic !== true) {
112513
+ return true;
112514
+ }
112515
+ if (sup === "CX_NO_CHECK" && this.getConfig().reportNoCheck !== true) {
112516
+ return true;
112517
+ }
112518
+ const lsup = this.localExceptions[name.toUpperCase()];
112519
+ if (lsup === "CX_DYNAMIC_CHECK" && this.getConfig().reportDynamic !== true) {
112520
+ return true;
112521
+ }
112522
+ if (lsup === "CX_NO_CHECK" && this.getConfig().reportNoCheck !== true) {
112523
+ return true;
112524
+ }
112525
+ return this.sinked.some(a => a.toUpperCase() === name.toUpperCase())
112526
+ || (sup !== undefined && this.isSinked(sup) === true)
112527
+ || (lsup !== undefined && this.isSinked(lsup) === true);
112528
+ }
112529
+ findGlobalExceptions() {
112530
+ var _a, _b;
112531
+ this.globalExceptions = {};
112532
+ const ddic = new ddic_1.DDIC(this.reg);
112533
+ for (const o of this.reg.getObjects()) {
112534
+ if (!(o instanceof objects_1.Class)) {
112535
+ continue;
112536
+ }
112537
+ const def = (_a = o.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getInfo().getClassDefinitionByName(o.getName());
112538
+ if (def === undefined || ddic.isException(def, o) === false) {
112539
+ continue;
112540
+ }
112541
+ this.globalExceptions[o.getName().toUpperCase()] = (_b = def.superClassName) === null || _b === void 0 ? void 0 : _b.toUpperCase();
112542
+ }
112543
+ }
112544
+ findLocalExceptions(obj) {
112545
+ var _a;
112546
+ this.localExceptions = {};
112547
+ for (const file of obj.getABAPFiles()) {
112548
+ for (const def of file.getInfo().listClassDefinitions()) {
112549
+ if (def.isLocal === true && def.superClassName !== undefined) {
112550
+ this.localExceptions[def.name.toUpperCase()] = (_a = def.superClassName) === null || _a === void 0 ? void 0 : _a.toUpperCase();
112551
+ }
112552
+ }
112553
+ }
112554
+ }
112555
+ }
112556
+ exports.UncaughtException = UncaughtException;
112557
+ //# sourceMappingURL=uncaught_exception.js.map
112558
+
112559
+ /***/ },
112560
+
112561
+ /***/ "../core/build/src/rules/unit_test_assertions.js"
112562
+ /*!*******************************************************!*\
112563
+ !*** ../core/build/src/rules/unit_test_assertions.js ***!
112564
+ \*******************************************************/
112565
+ (__unused_webpack_module, exports, __webpack_require__) {
112566
+
112567
+ "use strict";
112568
+
112569
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
112570
+ if (k2 === undefined) k2 = k;
112571
+ var desc = Object.getOwnPropertyDescriptor(m, k);
112572
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
112573
+ desc = { enumerable: true, get: function() { return m[k]; } };
112574
+ }
112575
+ Object.defineProperty(o, k2, desc);
112576
+ }) : (function(o, m, k, k2) {
112577
+ if (k2 === undefined) k2 = k;
112578
+ o[k2] = m[k];
112579
+ }));
112580
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
112581
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
112582
+ }) : function(o, v) {
112583
+ o["default"] = v;
112584
+ });
112585
+ var __importStar = (this && this.__importStar) || (function () {
112586
+ var ownKeys = function(o) {
112587
+ ownKeys = Object.getOwnPropertyNames || function (o) {
112588
+ var ar = [];
112589
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
112590
+ return ar;
112591
+ };
112592
+ return ownKeys(o);
112593
+ };
112594
+ return function (mod) {
112595
+ if (mod && mod.__esModule) return mod;
112596
+ var result = {};
112597
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
112598
+ __setModuleDefault(result, mod);
112599
+ return result;
112600
+ };
112601
+ })();
112602
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
112603
+ exports.UnitTestAssertions = exports.UnitTestAssertionsConf = void 0;
110327
112604
  const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
110328
112605
  const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
110329
112606
  const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
110330
- const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
110331
- const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
110332
- const objects_1 = __webpack_require__(/*! ../objects */ "../core/build/src/objects/index.js");
110333
- const ddic_1 = __webpack_require__(/*! ../ddic */ "../core/build/src/ddic.js");
110334
- const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
110335
- const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
110336
- const types_1 = __webpack_require__(/*! ../abap/types */ "../core/build/src/abap/types/index.js");
110337
- class UncaughtExceptionConf extends _basic_rule_config_1.BasicRuleConfig {
112607
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
112608
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
112609
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
112610
+ const Tokens = __importStar(__webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js"));
112611
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
112612
+ class UnitTestAssertionsConf extends _basic_rule_config_1.BasicRuleConfig {
110338
112613
  constructor() {
110339
112614
  super(...arguments);
110340
- this.reportDynamic = false;
110341
- this.reportNoCheck = false;
112615
+ this.severity = severity_1.Severity.Warning;
112616
+ /** Report assertions that cannot fail: assert_equals or assert_equals_float with the same operand for act and exp,
112617
+ * assert_true with abap_true or 'X', assert_false with abap_false, space or ' ' */
112618
+ this.cannotFail = true;
112619
+ /** Report the ASSERT statement in FOR TESTING classes */
112620
+ this.assertStatement = true;
110342
112621
  }
110343
112622
  }
110344
- exports.UncaughtExceptionConf = UncaughtExceptionConf;
110345
- class UncaughtException extends _abap_rule_1.ABAPRule {
112623
+ exports.UnitTestAssertionsConf = UnitTestAssertionsConf;
112624
+ const ASSERT_CLASSES = ["CL_ABAP_UNIT_ASSERT", "CL_AUNIT_ASSERT"];
112625
+ class UnitTestAssertions extends _abap_rule_1.ABAPRule {
110346
112626
  constructor() {
110347
112627
  super(...arguments);
110348
- this.conf = new UncaughtExceptionConf();
110349
- this.issues = [];
112628
+ this.conf = new UnitTestAssertionsConf();
110350
112629
  }
110351
112630
  getMetadata() {
110352
112631
  return {
110353
- key: "uncaught_exception",
110354
- title: "Uncaught Exception",
110355
- shortDescription: `Checks for uncaught static exception`,
110356
- extendedInformation: `Does not report any issues if the code contains syntax errors`,
110357
- tags: [_irule_1.RuleTag.Syntax],
112632
+ key: "unit_test_assertions",
112633
+ title: "Unit test assertions",
112634
+ shortDescription: `Reports unit test assertions that cannot fail, and the ASSERT statement in FOR TESTING classes`,
112635
+ extendedInformation: `Only code in FOR TESTING classes is checked. Each check has its own option.
112636
+
112637
+ cannotFail: an assertion of cl_abap_unit_assert or cl_aunit_assert that passes whatever the code under test does.
112638
+ assert_equals and assert_equals_float with the same operand for act and exp, assert_true with abap_true or 'X',
112639
+ assert_false with abap_false, space or ' '. Not reported: operands that contain a method call or NEW, as two calls
112640
+ can return different values; two different literals or constants; assertions that always fail.
112641
+
112642
+ assertStatement: the ASSERT statement. A failing ASSERT ends in the runtime error ASSERTION_FAILED, so the test
112643
+ run shows a short dump instead of a failed test with act, exp and a message. Use cl_abap_unit_assert instead.
112644
+ Not reported: ASSERT in classes that are not FOR TESTING.`,
112645
+ tags: [],
112646
+ badExample: `CLASS ltcl_test DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
112647
+ PRIVATE SECTION.
112648
+ DATA mt_rows TYPE string_table.
112649
+ METHODS test FOR TESTING.
112650
+ ENDCLASS.
112651
+
112652
+ CLASS ltcl_test IMPLEMENTATION.
112653
+ METHOD test.
112654
+ DATA(lv_count) = lines( mt_rows ).
112655
+ cl_abap_unit_assert=>assert_equals( act = lv_count exp = lv_count ).
112656
+ cl_abap_unit_assert=>assert_true( abap_true ).
112657
+ ASSERT lv_count = 2.
112658
+ ENDMETHOD.
112659
+ ENDCLASS.`,
112660
+ goodExample: `CLASS ltcl_test DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
112661
+ PRIVATE SECTION.
112662
+ DATA mt_rows TYPE string_table.
112663
+ METHODS test FOR TESTING.
112664
+ ENDCLASS.
112665
+
112666
+ CLASS ltcl_test IMPLEMENTATION.
112667
+ METHOD test.
112668
+ DATA(lv_count) = lines( mt_rows ).
112669
+ cl_abap_unit_assert=>assert_equals( act = lv_count exp = 2 ).
112670
+ cl_abap_unit_assert=>assert_true( xsdbool( lv_count > 0 ) ).
112671
+ ENDMETHOD.
112672
+ ENDCLASS.`,
110358
112673
  };
110359
112674
  }
110360
112675
  getConfig() {
110361
112676
  return this.conf;
110362
112677
  }
110363
- initialize(reg) {
110364
- super.initialize(reg);
110365
- this.findGlobalExceptions();
110366
- return this;
110367
- }
110368
112678
  setConfig(conf) {
110369
112679
  this.conf = conf;
110370
112680
  }
110371
112681
  runParsed(file, obj) {
110372
- if (obj.getType() === "INTF") { // nothing can be raised in interfaces
110373
- return [];
110374
- }
110375
- if (obj instanceof objects_1.Program && obj.isInclude() === true) {
110376
- return [];
110377
- }
110378
- const stru = file.getStructure();
110379
- if (stru === undefined) {
112682
+ var _a, _b;
112683
+ const issues = [];
112684
+ const structure = file.getStructure();
112685
+ if (structure === undefined) {
110380
112686
  return [];
110381
112687
  }
110382
- this.findLocalExceptions(obj);
110383
- this.syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
110384
- if (this.syntax.issues.length > 0) {
112688
+ const testClasses = this.testClassNames(obj);
112689
+ if (testClasses.size === 0) {
110385
112690
  return [];
110386
112691
  }
110387
- this.issues = [];
110388
- this.sinked = undefined;
110389
- for (const c of stru.getChildren()) {
110390
- this.traverse(c, file);
110391
- }
110392
- return this.issues;
110393
- }
110394
- traverse(n, file) {
110395
- var _a, _b, _c, _d, _e;
110396
- const get = n.get();
110397
- if (get instanceof Structures.ClassDefinition
110398
- || get instanceof Structures.Interface) {
110399
- return; // to optimize performance
110400
- }
110401
- if (n instanceof nodes_1.StructureNode) {
110402
- if (get instanceof Structures.Try) {
110403
- // note that TRY-CATCH might be arbitrarily nested
110404
- const previous = this.sinked ? this.sinked.slice() : undefined;
110405
- this.addFromTryStructure(n);
110406
- for (const c of ((_a = n.findDirectStructure(Structures.Body)) === null || _a === void 0 ? void 0 : _a.getChildren()) || []) {
110407
- this.traverse(c, file);
112692
+ for (const implementation of structure.findAllStructures(Structures.ClassImplementation)) {
112693
+ const name = (_b = (_a = implementation.findFirstStatement(Statements.ClassImplementation)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(Expressions.ClassName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();
112694
+ if (name === undefined || testClasses.has(name) === false) {
112695
+ continue;
112696
+ }
112697
+ for (const statement of implementation.findAllStatementNodes()) {
112698
+ if (this.conf.assertStatement === true && statement.get() instanceof Statements.Assert) {
112699
+ const message = "Use cl_abap_unit_assert instead of ASSERT in a test class";
112700
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
110408
112701
  }
110409
- this.sinked = previous;
110410
- for (const catchStructure of n.findDirectStructures(Structures.Catch)) {
110411
- for (const c of catchStructure.getChildren()) {
110412
- this.traverse(c, file);
112702
+ else if (this.conf.cannotFail === true && statement.get() instanceof Statements.Call) {
112703
+ const message = this.cannotFail(statement);
112704
+ if (message !== undefined) {
112705
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
110413
112706
  }
110414
112707
  }
110415
- for (const c of ((_b = n.findDirectStructure(Structures.Cleanup)) === null || _b === void 0 ? void 0 : _b.getChildren()) || []) {
110416
- this.traverse(c, file);
110417
- }
110418
- }
110419
- else {
110420
- for (const c of n.getChildren()) {
110421
- this.traverse(c, file);
110422
- }
110423
112708
  }
110424
112709
  }
110425
- else if (n instanceof nodes_1.StatementNode) {
110426
- if (get instanceof Statements.MethodImplementation) {
110427
- this.setSinkedFromMethod(n, file);
110428
- }
110429
- else if (get instanceof Statements.EndMethod) {
110430
- this.sinked = undefined; // back to top level
110431
- }
110432
- else if (get instanceof Statements.Form) {
110433
- this.sinked = [];
110434
- const raising = n.findDirectExpression(Expressions.FormRaising);
110435
- for (const c of (raising === null || raising === void 0 ? void 0 : raising.findAllExpressions(Expressions.ClassName)) || []) {
110436
- this.sinked.push(c.concatTokens().toUpperCase());
110437
- }
110438
- }
110439
- else if (get instanceof Statements.EndForm) {
110440
- this.sinked = undefined; // back to top level
110441
- }
110442
- else if (get instanceof Statements.Raise) {
110443
- let name = undefined;
110444
- const concat = n.concatTokens().toUpperCase();
110445
- if (concat.startsWith("RAISE EXCEPTION TYPE ")) {
110446
- name = (_c = n.findFirstExpression(Expressions.ClassName)) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase();
110447
- }
110448
- else if (concat.startsWith("RAISE EXCEPTION NEW ")) {
110449
- name = (_e = (_d = n.findFirstExpression(Expressions.NewObject)) === null || _d === void 0 ? void 0 : _d.findFirstExpression(Expressions.TypeNameOrInfer)) === null || _e === void 0 ? void 0 : _e.getFirstToken().getStr().toUpperCase();
110450
- // todo: else its a normal Source, infer the type from it
112710
+ return issues;
112711
+ }
112712
+ /** names of the FOR TESTING classes defined in any file of the object, upper case */
112713
+ testClassNames(obj) {
112714
+ const ret = new Set();
112715
+ for (const f of obj.getABAPFiles()) {
112716
+ for (const def of f.getInfo().listClassDefinitions()) {
112717
+ if (def.isForTesting === true) {
112718
+ ret.add(def.name.toUpperCase());
110451
112719
  }
110452
- this.check(name, n, file);
110453
- }
110454
- else if (get instanceof Statements.Perform) {
110455
- // todo, PERFORM, or is this not statically checked?
110456
- }
110457
- else {
110458
- this.checkForMethodCalls(n, file);
110459
112720
  }
110460
112721
  }
112722
+ return ret;
110461
112723
  }
110462
- ////////////////////////////////
110463
- check(name, n, file) {
110464
- if (this.isSinked(name) === false) {
110465
- const issue = issue_1.Issue.atStatement(file, n, "Uncaught exception " + name, this.getMetadata().key, this.getConfig().severity);
110466
- this.issues.push(issue);
112724
+ /** returns the message if the call is an assertion that cannot fail */
112725
+ cannotFail(statement) {
112726
+ const call = this.assertCall(statement);
112727
+ if (call === undefined) {
112728
+ return undefined;
110467
112729
  }
110468
- }
110469
- checkForMethodCalls(n, file) {
110470
- const start = n.getFirstToken().getStart();
110471
- const end = n.getLastToken().getEnd();
110472
- const scope = this.syntax.spaghetti.lookupPosition(start, file.getFilename());
110473
- for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
110474
- if (r.referenceType === _reference_1.ReferenceType.MethodReference
110475
- && r.position.getStart().isAfter(start)
110476
- && r.position.getEnd().isBefore(end)
110477
- && r.resolved instanceof types_1.MethodDefinition) {
110478
- for (const name of r.resolved.getRaising()) {
110479
- this.check(name, n, file);
110480
- }
112730
+ if (call.method === "ASSERT_EQUALS" || call.method === "ASSERT_EQUALS_FLOAT") {
112731
+ const act = call.parameters.get("ACT");
112732
+ const exp = call.parameters.get("EXP");
112733
+ if (act === undefined || exp === undefined || this.hasCall(act) || this.hasCall(exp)) {
112734
+ return undefined;
110481
112735
  }
110482
- else if (r.referenceType === _reference_1.ReferenceType.ConstructorReference
110483
- && r.position.getStart().isAfter(start)
110484
- && r.position.getEnd().isBefore(end)
110485
- && r.resolved instanceof types_1.ClassDefinition) {
110486
- const method = this.findConstructor(r.resolved, scope);
110487
- for (const name of (method === null || method === void 0 ? void 0 : method.getRaising()) || []) {
110488
- this.check(name, n, file);
110489
- }
112736
+ if (this.normalized(act) === this.normalized(exp)) {
112737
+ return "Assertion cannot fail, act and exp are the same";
110490
112738
  }
110491
112739
  }
110492
- }
110493
- findConstructor(def, scope) {
110494
- for (const method of def.getMethodDefinitions().getAll()) {
110495
- if (method instanceof types_1.MethodDefinition && method.getName().toUpperCase() === "CONSTRUCTOR") {
110496
- return method;
112740
+ else if (call.method === "ASSERT_TRUE" || call.method === "ASSERT_FALSE") {
112741
+ const act = call.parameters.get("ACT");
112742
+ if (act === undefined) {
112743
+ return undefined;
110497
112744
  }
110498
- }
110499
- const sup = def.getSuperClass();
110500
- if (sup === undefined) {
110501
- return undefined;
110502
- }
110503
- const superDefinition = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(sup);
110504
- return superDefinition ? this.findConstructor(superDefinition, scope) : undefined;
110505
- }
110506
- addFromTryStructure(s) {
110507
- if (this.sinked === undefined) {
110508
- return;
110509
- }
110510
- for (const structure of s.findDirectStructures(Structures.Catch)) {
110511
- const c = structure.findDirectStatement(Statements.Catch);
110512
- if (c === undefined) {
110513
- continue;
112745
+ const value = this.normalized(act);
112746
+ if (call.method === "ASSERT_TRUE" && (value === "ABAP_TRUE" || value === "'X'")) {
112747
+ return "Assertion cannot fail, act is abap_true";
110514
112748
  }
110515
- for (const cn of c.findDirectExpressions(Expressions.ClassName)) {
110516
- this.sinked.push(cn.concatTokens());
112749
+ else if (call.method === "ASSERT_FALSE"
112750
+ && (value === "ABAP_FALSE" || value === "SPACE" || value === "''" || value === "' '")) {
112751
+ return "Assertion cannot fail, act is abap_false";
110517
112752
  }
110518
112753
  }
112754
+ return undefined;
110519
112755
  }
110520
- setSinkedFromMethod(s, file) {
110521
- this.sinked = [];
110522
- const scope = this.syntax.spaghetti.lookupPosition(s.getLastToken().getEnd(), file.getFilename());
110523
- let def = undefined;
110524
- for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
110525
- // there should be only one, so the first is okay
110526
- if (r.referenceType === _reference_1.ReferenceType.MethodImplementationReference
110527
- && r.resolved instanceof types_1.MethodDefinition) {
110528
- def = r.resolved;
110529
- break;
112756
+ /** class method call of cl_abap_unit_assert or cl_aunit_assert: method name and the sources by parameter name, upper case */
112757
+ assertCall(statement) {
112758
+ var _a, _b;
112759
+ let className;
112760
+ let methodName;
112761
+ let parameters;
112762
+ const chain = statement.findDirectExpression(Expressions.MethodCallChain);
112763
+ const source = statement.findDirectExpression(Expressions.MethodSource);
112764
+ if (chain !== undefined) {
112765
+ const children = chain.getChildren();
112766
+ const methodCall = chain.findDirectExpression(Expressions.MethodCall);
112767
+ if (children.length !== 3 || methodCall === undefined) {
112768
+ return undefined;
110530
112769
  }
112770
+ className = chain.findDirectExpression(Expressions.ClassName);
112771
+ methodName = methodCall.findDirectExpression(Expressions.MethodName);
112772
+ parameters = methodCall.findDirectExpression(Expressions.MethodCallParam);
110531
112773
  }
110532
- if (def === undefined) {
110533
- return; // this should not occur, so just report everything as errors
110534
- }
110535
- def.getRaising().forEach(r => { var _a; return (_a = this.sinked) === null || _a === void 0 ? void 0 : _a.push(r); });
110536
- }
110537
- isSinked(name) {
110538
- if (this.sinked === undefined || name === undefined) {
110539
- return true;
110540
- }
110541
- const sup = this.globalExceptions[name.toUpperCase()];
110542
- if (sup === "CX_DYNAMIC_CHECK" && this.getConfig().reportDynamic !== true) {
110543
- return true;
110544
- }
110545
- if (sup === "CX_NO_CHECK" && this.getConfig().reportNoCheck !== true) {
110546
- return true;
112774
+ else if (source !== undefined) {
112775
+ const children = source.getChildren();
112776
+ if (children.length !== 3) {
112777
+ return undefined;
112778
+ }
112779
+ className = source.findDirectExpression(Expressions.ClassName);
112780
+ methodName = source.findDirectExpression(Expressions.AttributeName);
112781
+ parameters = statement.findDirectExpression(Expressions.MethodCallBody);
110547
112782
  }
110548
- const lsup = this.localExceptions[name.toUpperCase()];
110549
- if (lsup === "CX_DYNAMIC_CHECK" && this.getConfig().reportDynamic !== true) {
110550
- return true;
112783
+ if (className === undefined
112784
+ || methodName === undefined
112785
+ || parameters === undefined
112786
+ || ASSERT_CLASSES.includes(className.concatTokens().toUpperCase()) === false) {
112787
+ return undefined;
110551
112788
  }
110552
- if (lsup === "CX_NO_CHECK" && this.getConfig().reportNoCheck !== true) {
110553
- return true;
112789
+ // CALL METHOD x( ... ) and the functional call have a MethodCallParam, CALL METHOD x EXPORTING ... has not
112790
+ const param = parameters.get() instanceof Expressions.MethodCallParam
112791
+ ? parameters : parameters.findDirectExpression(Expressions.MethodCallParam);
112792
+ const list = (param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.ParameterListS))
112793
+ || ((_a = (param || parameters).findDirectExpression(Expressions.MethodParameters)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.ParameterListS));
112794
+ const map = new Map();
112795
+ const single = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.Source);
112796
+ if (single !== undefined) {
112797
+ // only the preferred parameter is given, for the assertions checked here it is ACT
112798
+ map.set("ACT", single);
110554
112799
  }
110555
- return this.sinked.some(a => a.toUpperCase() === name.toUpperCase())
110556
- || (sup !== undefined && this.isSinked(sup) === true)
110557
- || (lsup !== undefined && this.isSinked(lsup) === true);
110558
- }
110559
- findGlobalExceptions() {
110560
- var _a, _b;
110561
- this.globalExceptions = {};
110562
- const ddic = new ddic_1.DDIC(this.reg);
110563
- for (const o of this.reg.getObjects()) {
110564
- if (!(o instanceof objects_1.Class)) {
110565
- continue;
110566
- }
110567
- const def = (_a = o.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getInfo().getClassDefinitionByName(o.getName());
110568
- if (def === undefined || ddic.isException(def, o) === false) {
110569
- continue;
112800
+ for (const parameter of (list === null || list === void 0 ? void 0 : list.findDirectExpressions(Expressions.ParameterS)) || []) {
112801
+ const name = (_b = parameter.findDirectExpression(Expressions.ParameterName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();
112802
+ const value = parameter.findDirectExpression(Expressions.Source);
112803
+ if (name !== undefined && value !== undefined) {
112804
+ map.set(name, value);
110570
112805
  }
110571
- this.globalExceptions[o.getName().toUpperCase()] = (_b = def.superClassName) === null || _b === void 0 ? void 0 : _b.toUpperCase();
110572
112806
  }
112807
+ return { method: methodName.concatTokens().toUpperCase(), parameters: map };
110573
112808
  }
110574
- findLocalExceptions(obj) {
110575
- var _a;
110576
- this.localExceptions = {};
110577
- for (const file of obj.getABAPFiles()) {
110578
- for (const def of file.getInfo().listClassDefinitions()) {
110579
- if (def.isLocal === true && def.superClassName !== undefined) {
110580
- this.localExceptions[def.name.toUpperCase()] = (_a = def.superClassName) === null || _a === void 0 ? void 0 : _a.toUpperCase();
110581
- }
112809
+ /** two evaluations of the source can give different values */
112810
+ hasCall(source) {
112811
+ return source.findFirstExpression(Expressions.MethodCallChain) !== undefined
112812
+ || source.findFirstExpression(Expressions.MethodCall) !== undefined
112813
+ || source.findFirstExpression(Expressions.NewObject) !== undefined;
112814
+ }
112815
+ /** the tokens of the source, upper case outside of literals */
112816
+ normalized(source) {
112817
+ return source.getAllTokens().map(token => {
112818
+ if (token instanceof Tokens.StringToken
112819
+ || token instanceof Tokens.StringTemplate
112820
+ || token instanceof Tokens.StringTemplateBegin
112821
+ || token instanceof Tokens.StringTemplateMiddle
112822
+ || token instanceof Tokens.StringTemplateEnd) {
112823
+ return token.getStr();
110582
112824
  }
110583
- }
112825
+ return token.getStr().toUpperCase();
112826
+ }).join(" ");
110584
112827
  }
110585
112828
  }
110586
- exports.UncaughtException = UncaughtException;
110587
- //# sourceMappingURL=uncaught_exception.js.map
112829
+ exports.UnitTestAssertions = UnitTestAssertions;
112830
+ //# sourceMappingURL=unit_test_assertions.js.map
110588
112831
 
110589
112832
  /***/ },
110590
112833
 
@@ -114128,6 +116371,7 @@ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../co
114128
116371
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
114129
116372
  const fast_xml_parser_1 = __webpack_require__(/*! fast-xml-parser */ "../core/node_modules/fast-xml-parser/lib/fxp.cjs");
114130
116373
  const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
116374
+ const xml_utils_1 = __webpack_require__(/*! ../xml_utils */ "../core/build/src/xml_utils.js");
114131
116375
  const ABAPGIT_ATTRIBUTES = [
114132
116376
  ["version", /<abapGit\b[^>]*\bversion="([^"]+)"/],
114133
116377
  ["serializer_version", /<abapGit\b[^>]*\bserializer_version="([^"]+)"/],
@@ -114160,6 +116404,7 @@ class XMLConsistency {
114160
116404
  * QUAN fields in TABL objects have reference table and field values
114161
116405
  * Transparent TABL objects have delivery class and size category set
114162
116406
  * TABL fields with a built-in type carry the INTTYPE abapGit serializes for it, for the confirmed pairs
116407
+ * Documentation lines(TDLINE) in CLAS and INTF objects are max 72 characters, longer lines are cut by the system
114163
116408
  * Lock parameter names in ENQU objects are max 16 characters
114164
116409
  * DEVC objects are serialized as package.devc.xml
114165
116410
  * Texts and translations do not exceed maximum allowed length.`,
@@ -114247,6 +116492,27 @@ class XMLConsistency {
114247
116492
  issues.push(issue_1.Issue.atRow(file, 1, "Class matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
114248
116493
  }
114249
116494
  issues.push(...this.checkClearedFields(obj, file, "VSEOCLASS", XMLConsistency.clearedClassFields));
116495
+ issues.push(...this.checkDocumentationLines(obj, file));
116496
+ return issues;
116497
+ }
116498
+ // the documentation editor stores lines of max 72 characters, longer TDLINEs are cut when deserialized
116499
+ checkDocumentationLines(obj, file) {
116500
+ const maxLength = 72;
116501
+ const issues = [];
116502
+ const xml = obj.getXML();
116503
+ if (xml === undefined) {
116504
+ return issues;
116505
+ }
116506
+ const regex = /<TDLINE>([^<]*)<\/TDLINE>/g;
116507
+ let match;
116508
+ while ((match = regex.exec(xml)) !== null) {
116509
+ const text = (0, xml_utils_1.unescape)(match[1]);
116510
+ if (text.length > maxLength) {
116511
+ const row = xml.substring(0, match.index).split("\n").length;
116512
+ const message = `Documentation line exceeds maximum length of ${maxLength} characters (actual: ${text.length}), "${text}"`;
116513
+ issues.push(issue_1.Issue.atRow(file, row, message, this.getMetadata().key, this.conf.textAndTranslationLengthSeverity));
116514
+ }
116515
+ }
114250
116516
  return issues;
114251
116517
  }
114252
116518
  checkClearedFields(obj, file, structure, fields) {
@@ -114308,6 +116574,7 @@ class XMLConsistency {
114308
116574
  issues.push(issue_1.Issue.atRow(file, 1, "Interface matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
114309
116575
  }
114310
116576
  issues.push(...this.checkClearedFields(obj, file, "VSEOINTERF", XMLConsistency.clearedInterfaceFields));
116577
+ issues.push(...this.checkDocumentationLines(obj, file));
114311
116578
  return issues;
114312
116579
  }
114313
116580
  checkTextLength(file, fieldName, text, maxLength, lang) {