@abaplint/cli 2.120.106 → 2.120.108

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 +1068 -44
  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 ***!
@@ -38490,8 +38566,8 @@ class ValueBody {
38490
38566
  }
38491
38567
  for (const s of foo.findDirectExpressions(Expressions.Source)) {
38492
38568
  const sourceType = source_1.Source.runSyntax(s, input, rowType);
38493
- if (rowType instanceof basic_1.StringType && sourceType instanceof basic_1.CharacterType) {
38494
- const message = "VALUE, source type CharacterType not compatible with StringType";
38569
+ if ((rowType instanceof basic_1.StringType || rowType instanceof basic_1.XStringType) && sourceType instanceof basic_1.CharacterType) {
38570
+ const message = "VALUE, source type CharacterType not compatible with " + rowType.constructor.name;
38495
38571
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
38496
38572
  }
38497
38573
  else if (this.insertsUsingTableKey(targetType)) {
@@ -39288,6 +39364,11 @@ class Append {
39288
39364
  let targetType = undefined;
39289
39365
  const target = node.findDirectExpression(Expressions.Target);
39290
39366
  if (target) {
39367
+ if (target.findDirectExpression(Expressions.TableExpression) !== undefined) {
39368
+ const message = "APPEND, table expression not allowed in target";
39369
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, target.getFirstToken(), message));
39370
+ return;
39371
+ }
39291
39372
  targetType = target_1.Target.runSyntax(target, input);
39292
39373
  }
39293
39374
  // a hashed table has no index, APPEND adds at the end
@@ -44403,6 +44484,7 @@ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/s
44403
44484
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
44404
44485
  class InsertInternal {
44405
44486
  runSyntax(node, input) {
44487
+ var _a;
44406
44488
  let targetType;
44407
44489
  const t = node.findDirectExpression(Expressions.Target);
44408
44490
  if (t) {
@@ -44465,6 +44547,13 @@ class InsertInternal {
44465
44547
  // yea, well, INSERT doesnt convert the values automatically, like everything else?
44466
44548
  error = true;
44467
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
+ }
44468
44557
  if (error === true) {
44469
44558
  const message = "Types not compatible";
44470
44559
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -44771,7 +44860,6 @@ var __importStar = (this && this.__importStar) || (function () {
44771
44860
  Object.defineProperty(exports, "__esModule", ({ value: true }));
44772
44861
  exports.Loop = void 0;
44773
44862
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
44774
- const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
44775
44863
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
44776
44864
  const target_1 = __webpack_require__(/*! ../expressions/target */ "../core/build/src/abap/5_syntax/expressions/target.js");
44777
44865
  const source_1 = __webpack_require__(/*! ../expressions/source */ "../core/build/src/abap/5_syntax/expressions/source.js");
@@ -44783,6 +44871,7 @@ const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "../core/bui
44783
44871
  const loop_group_by_1 = __webpack_require__(/*! ../expressions/loop_group_by */ "../core/build/src/abap/5_syntax/expressions/loop_group_by.js");
44784
44872
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
44785
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");
44786
44875
  class Loop {
44787
44876
  runSyntax(node, input) {
44788
44877
  var _a, _b;
@@ -44887,7 +44976,7 @@ class Loop {
44887
44976
  // the first component of a sorted secondary key must be compared with = or IS INITIAL
44888
44977
  // in a part of the condition joined by AND, otherwise the WHERE cannot be optimized
44889
44978
  const first = key.keyFields[0].toUpperCase();
44890
- if (this.hasKeyCompare(cond, first) === false) {
44979
+ if ((0, _key_compare_1.hasKeyCompare)(cond, first) === false) {
44891
44980
  const message = "Loop, WHERE cannot be optimized for secondary key " + name +
44892
44981
  ", key component " + first + " needs a comparison with = or IS INITIAL joined by AND";
44893
44982
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -44934,31 +45023,6 @@ class Loop {
44934
45023
  loop_group_by_1.LoopGroupBy.runSyntax(group, input);
44935
45024
  }
44936
45025
  }
44937
- // true if a conjunct reachable through AND only, ie. not under OR or NOT, compares the component with = or IS INITIAL
44938
- hasKeyCompare(cond, component) {
44939
- if (cond.findDirectTokenByText("OR") !== undefined) {
44940
- return false;
44941
- }
44942
- for (const child of cond.getChildren()) {
44943
- if (child.get() instanceof Expressions.ComponentCompare && child instanceof nodes_1.ExpressionNode) {
44944
- const concat = child.concatTokens().toUpperCase().replace(/\s+/g, " ");
44945
- if (concat.startsWith(component + " = ")
44946
- || concat.startsWith(component + " EQ ")
44947
- || concat === component + " IS INITIAL") {
44948
- return true;
44949
- }
44950
- }
44951
- else if (child.get() instanceof Expressions.ComponentCondSub
44952
- && child instanceof nodes_1.ExpressionNode
44953
- && child.findDirectTokenByText("NOT") === undefined) {
44954
- const sub = child.findDirectExpression(Expressions.ComponentCond);
44955
- if (sub !== undefined && this.hasKeyCompare(sub, component)) {
44956
- return true;
44957
- }
44958
- }
44959
- }
44960
- return false;
44961
- }
44962
45026
  }
44963
45027
  exports.Loop = Loop;
44964
45028
  //# sourceMappingURL=loop.js.map
@@ -46338,7 +46402,7 @@ const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/b
46338
46402
  class Raise {
46339
46403
  runSyntax(node, input) {
46340
46404
  // todo
46341
- var _a, _b, _c, _d, _e, _f;
46405
+ var _a, _b, _c, _d, _e, _f, _g;
46342
46406
  const helper = new _object_oriented_1.ObjectOriented(input.scope);
46343
46407
  let method;
46344
46408
  const exceptionName = node.findDirectExpression(Expressions.ExceptionName);
@@ -46354,7 +46418,12 @@ class Raise {
46354
46418
  if (found === null || found === void 0 ? void 0 : found.id) {
46355
46419
  input.scope.addReference(classTok, found.id, _reference_1.ReferenceType.ObjectOrientedReference, input.filename);
46356
46420
  const def = input.scope.findObjectDefinition(className);
46357
- method = (_b = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _b === void 0 ? void 0 : _b.method;
46421
+ if (((_b = input.scope.findClassDefinition(className)) === null || _b === void 0 ? void 0 : _b.isAbstract()) === true) {
46422
+ const message = className + " is abstract, cannot be instantiated";
46423
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, classTok, message));
46424
+ return;
46425
+ }
46426
+ method = (_c = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _c === void 0 ? void 0 : _c.method;
46358
46427
  }
46359
46428
  else if (input.scope.getDDIC().inErrorNamespace(className) === false) {
46360
46429
  const extra = { ooName: className, ooType: "Void" };
@@ -46378,7 +46447,7 @@ class Raise {
46378
46447
  }
46379
46448
  else if (type instanceof basic_1.ObjectReferenceType) {
46380
46449
  const def = input.scope.findObjectDefinition(type.getIdentifierName());
46381
- method = (_c = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _c === void 0 ? void 0 : _c.method;
46450
+ method = (_d = helper.searchMethodName(def, "CONSTRUCTOR")) === null || _d === void 0 ? void 0 : _d.method;
46382
46451
  }
46383
46452
  else if (type !== undefined) {
46384
46453
  const message = "RAISE EXCEPTION, must be object reference, got " + type.constructor.name;
@@ -46407,10 +46476,10 @@ class Raise {
46407
46476
  for (const s of node.findDirectExpressions(Expressions.MessageSource)) {
46408
46477
  message_source_1.MessageSource.runSyntax(s, input);
46409
46478
  }
46410
- const id = (_d = node.findExpressionAfterToken("ID")) === null || _d === void 0 ? void 0 : _d.concatTokens();
46411
- let number = (_e = node.findDirectExpression(Expressions.MessageNumber)) === null || _e === void 0 ? void 0 : _e.concatTokens();
46479
+ const id = (_e = node.findExpressionAfterToken("ID")) === null || _e === void 0 ? void 0 : _e.concatTokens();
46480
+ let number = (_f = node.findDirectExpression(Expressions.MessageNumber)) === null || _f === void 0 ? void 0 : _f.concatTokens();
46412
46481
  if (number === undefined) {
46413
- const num = (_f = node.findExpressionAfterToken("NUMBER")) === null || _f === void 0 ? void 0 : _f.concatTokens();
46482
+ const num = (_g = node.findExpressionAfterToken("NUMBER")) === null || _g === void 0 ? void 0 : _g.concatTokens();
46414
46483
  if (num === null || num === void 0 ? void 0 : num.startsWith("'")) {
46415
46484
  number = num.substring(1, num.length - 1).toUpperCase();
46416
46485
  }
@@ -55106,7 +55175,7 @@ class ClassDefinition extends _identifier_1.Identifier {
55106
55175
  this.events.push(new event_definition_1.EventDefinition(e, visibility_1.Visibility.Public, input)); // todo, all these are not Public
55107
55176
  }
55108
55177
  this.methodDefs = new method_definitions_1.MethodDefinitions(node, input);
55109
- input.scope.pop(node.getLastToken().getEnd());
55178
+ const scope = input.scope.pop(node.getLastToken().getEnd());
55110
55179
  const concat = def.concatTokens().toUpperCase();
55111
55180
  this.testing = concat.includes(" FOR TESTING");
55112
55181
  this.sharedMemory = concat.includes(" SHARED MEMORY ENABLED");
@@ -55128,6 +55197,7 @@ class ClassDefinition extends _identifier_1.Identifier {
55128
55197
  this.checkClassNameLength(input);
55129
55198
  this.checkMethodNameLength(input);
55130
55199
  this.checkClassConstructor(input);
55200
+ this.checkLocalTypesInPublicSections(input, node, scope.getTop());
55131
55201
  }
55132
55202
  getFriends() {
55133
55203
  return this.friends;
@@ -55182,6 +55252,56 @@ class ClassDefinition extends _identifier_1.Identifier {
55182
55252
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, this.getToken(), message));
55183
55253
  }
55184
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
+ }
55185
55305
  findSuper(def, input) {
55186
55306
  var _a;
55187
55307
  const token = (_a = def === null || def === void 0 ? void 0 : def.findDirectExpression(expressions_1.SuperClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
@@ -73878,7 +73998,7 @@ class Registry {
73878
73998
  }
73879
73999
  static abaplintVersion() {
73880
74000
  // magic, see build script "version.js"
73881
- return "2.120.106";
74001
+ return "2.120.108";
73882
74002
  }
73883
74003
  getDDICReferences() {
73884
74004
  return this.ddicReferences;
@@ -74466,6 +74586,7 @@ exports.isReferenceType = isReferenceType;
74466
74586
  exports.identicalTypes = identicalTypes;
74467
74587
  exports.simplePredicate = simplePredicate;
74468
74588
  exports.characterConstant = characterConstant;
74589
+ exports.textLiteral = textLiteral;
74469
74590
  exports.sameCharacters = sameCharacters;
74470
74591
  exports.isCondition = isCondition;
74471
74592
  exports.dataSource = dataSource;
@@ -83533,11 +83654,20 @@ var __importStar = (this && this.__importStar) || (function () {
83533
83654
  Object.defineProperty(exports, "__esModule", ({ value: true }));
83534
83655
  exports.ConstantCondition = exports.ConstantConditionConf = void 0;
83535
83656
  const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
83657
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
83658
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
83536
83659
  const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
83660
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
83661
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
83537
83662
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
83538
83663
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
83539
83664
  const _procedure_analysis_1 = __webpack_require__(/*! ./_procedure_analysis */ "../core/build/src/rules/_procedure_analysis.js");
83540
83665
  class ConstantConditionConf extends _basic_rule_config_1.BasicRuleConfig {
83666
+ constructor() {
83667
+ super(...arguments);
83668
+ /** Report x <> a OR x <> b, always true, and x = a AND x = b, always false, for different character values a and b */
83669
+ this.exclusiveValues = true;
83670
+ }
83541
83671
  }
83542
83672
  exports.ConstantConditionConf = ConstantConditionConf;
83543
83673
  class ConstantCondition {
@@ -83548,7 +83678,8 @@ class ConstantCondition {
83548
83678
  return {
83549
83679
  key: "constant_condition",
83550
83680
  title: "Constant condition",
83551
- shortDescription: `Finds IF and ELSEIF conditions on local variables whose value is known`,
83681
+ shortDescription: `Finds IF and ELSEIF conditions on local variables whose value is known, and conditions that compare
83682
+ a field with two different values and are always true or always false`,
83552
83683
  extendedInformation: `Reports two cases, for local variables of a METHOD, FORM or FUNCTION.
83553
83684
 
83554
83685
  1. DATA(c) = <constant>. where the constant is a character literal like 'X', or a character constant like
@@ -83567,15 +83698,31 @@ an ELSEIF branch that is always taken turns into ELSE. Nothing is reported if a
83567
83698
  data that is used outside of it.
83568
83699
 
83569
83700
  Objects with syntax errors, macros or unknown statements are skipped, as are procedures with dynamic code,
83570
- INCLUDE, test seams, enhancements or native SQL. No release requirement.`,
83701
+ INCLUDE, test seams, enhancements or native SQL. No release requirement.
83702
+
83703
+ Option exclusiveValues: reports x <> a OR x <> b, which is always true, and x = a AND x = b, which is always
83704
+ false, in any condition of a METHOD, FORM or FUNCTION, also with dynamic code. Also with NE and EQ, with NOT,
83705
+ with the operands swapped, and with more conditions joined by the same operator. x is a data object of type c,
83706
+ generic c or string, without calls, offsets or table expressions. a and b are character literals or character
83707
+ constants, also components of constant structures of a class or interface, with different values. Usually one
83708
+ of the operators or one of the values is wrong, there is no quick fix.
83709
+ Not reported: conditions that mix AND and OR or contain a call, values that are not known, like constants of
83710
+ classes outside the registry, other types of x, which can convert different values to the same one, ASSERT,
83711
+ and SQL conditions, where a NULL value makes both comparisons unknown.`,
83571
83712
  tags: [_irule_1.RuleTag.Quickfix],
83572
83713
  badExample: `DATA(lv_active) = abap_true.
83573
83714
  IF lv_active = abap_true.
83574
83715
  run( ).
83575
83716
  ELSE.
83576
83717
  skip( ).
83718
+ ENDIF.
83719
+ IF lv_kind <> 'N' OR lv_kind <> 'P'.
83720
+ skip( ).
83721
+ ENDIF.`,
83722
+ goodExample: `run( ).
83723
+ IF lv_kind <> 'N' AND lv_kind <> 'P'.
83724
+ skip( ).
83577
83725
  ENDIF.`,
83578
- goodExample: `run( ).`,
83579
83726
  };
83580
83727
  }
83581
83728
  getConfig() {
@@ -83595,6 +83742,9 @@ ENDIF.`,
83595
83742
  }
83596
83743
  const issues = [];
83597
83744
  for (const procedure of analysis.procedures) {
83745
+ if (this.conf.exclusiveValues) {
83746
+ issues.push(...this.exclusiveValues(procedure));
83747
+ }
83598
83748
  if (procedure.supported === false) {
83599
83749
  continue;
83600
83750
  }
@@ -83696,6 +83846,175 @@ ENDIF.`,
83696
83846
  return source.countTokens() === 1 && source.findDirectExpression(Expressions.FieldChain) !== undefined
83697
83847
  && source.getFirstToken().getStart().equals(read.token.getStart());
83698
83848
  }
83849
+ /** x <> a OR x <> b, x = a AND x = b */
83850
+ exclusiveValues(procedure) {
83851
+ const issues = [];
83852
+ for (const statement of procedure.statements) {
83853
+ if (statement.get() instanceof Statements.Assert) {
83854
+ continue;
83855
+ }
83856
+ for (const cond of statement.findAllExpressionsRecursive(Expressions.Cond)) {
83857
+ const operators = cond.getChildren().filter(c => c instanceof nodes_1.TokenNode).map(c => c.getFirstToken().getStr().toUpperCase());
83858
+ const operator = operators[0];
83859
+ if ((operator !== "OR" && operator !== "AND") || operators.some(o => o !== operator) || this.hasCall(cond)) {
83860
+ continue;
83861
+ }
83862
+ const seen = [];
83863
+ for (const child of cond.getChildren()) {
83864
+ const comparison = child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Compare
83865
+ ? this.valueComparison(procedure, child) : undefined;
83866
+ if (comparison === undefined || comparison.equal !== (operator === "AND")) {
83867
+ continue;
83868
+ }
83869
+ const other = seen.find(s => s.subject === comparison.subject && !(0, _procedure_analysis_1.sameCharacters)(s.value, comparison.value));
83870
+ if (other !== undefined) {
83871
+ const message = "Condition is always " + (operator === "OR" ? "true" : "false") + ", "
83872
+ + this.subjectText(comparison) + " cannot be both "
83873
+ + other.constant.concatTokens() + " and " + comparison.constant.concatTokens();
83874
+ issues.push(issue_1.Issue.atRange(procedure.file, other.compare.getFirstToken().getStart(), comparison.compare.getLastToken().getEnd(), message, this.getMetadata().key, this.conf.severity));
83875
+ break;
83876
+ }
83877
+ seen.push(comparison);
83878
+ }
83879
+ }
83880
+ }
83881
+ return issues;
83882
+ }
83883
+ hasCall(node) {
83884
+ return node.findFirstExpression(Expressions.MethodCall) !== undefined
83885
+ || node.findFirstExpression(Expressions.MethodCallChain) !== undefined
83886
+ || node.findFirstExpression(Expressions.NewObject) !== undefined;
83887
+ }
83888
+ /** x = a, x <> a, a = x, NOT x = a etc, x character-like and a a known character value */
83889
+ valueComparison(procedure, compare) {
83890
+ const children = compare.getChildren();
83891
+ const negated = children[0] instanceof nodes_1.TokenNode && children[0].getFirstToken().getStr().toUpperCase() === "NOT";
83892
+ const rest = children.slice(negated ? 1 : 0);
83893
+ if (rest.length !== 3 || !(rest[0] instanceof nodes_1.ExpressionNode) || !(rest[2] instanceof nodes_1.ExpressionNode)
83894
+ || !(rest[1].get() instanceof Expressions.CompareOperator)) {
83895
+ return undefined;
83896
+ }
83897
+ const operator = rest[1].concatTokens().toUpperCase().replace(/ /g, "");
83898
+ let equal;
83899
+ if (operator === "=" || operator === "EQ") {
83900
+ equal = true;
83901
+ }
83902
+ else if (operator === "<>" || operator === "><" || operator === "NE") {
83903
+ equal = false;
83904
+ }
83905
+ else {
83906
+ return undefined;
83907
+ }
83908
+ for (const [subject, constant] of [[rest[0], rest[2]], [rest[2], rest[0]]]) {
83909
+ const value = this.constantValue(procedure, constant);
83910
+ const type = value === undefined ? undefined : this.subjectType(procedure, subject);
83911
+ if (value !== undefined
83912
+ && (type instanceof basic_1.CharacterType || type instanceof basic_1.CGenericType || type instanceof basic_1.StringType)) {
83913
+ const text = subject.getTokens().map(t => t.getStr().toUpperCase()).join(" ");
83914
+ return { subject: text, value, equal: equal !== negated, compare, constant };
83915
+ }
83916
+ }
83917
+ return undefined;
83918
+ }
83919
+ subjectText(comparison) {
83920
+ var _a;
83921
+ var _b;
83922
+ return (_b = (_a = comparison.compare.getChildren().find(c => c instanceof nodes_1.ExpressionNode && c !== comparison.constant
83923
+ && c.get() instanceof Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens()) !== null && _b !== void 0 ? _b : comparison.subject;
83924
+ }
83925
+ /** type of a field, field symbol, attribute or component chain, without calls, offsets or table expressions */
83926
+ subjectType(procedure, source) {
83927
+ var _a;
83928
+ var _b;
83929
+ const chain = source.getChildren().length === 1 ? source.findDirectExpression(Expressions.FieldChain) : undefined;
83930
+ const children = (_b = chain === null || chain === void 0 ? void 0 : chain.getChildren()) !== null && _b !== void 0 ? _b : [];
83931
+ let identifier;
83932
+ let next;
83933
+ if (children[0] instanceof nodes_1.ExpressionNode
83934
+ && (children[0].get() instanceof Expressions.SourceField || children[0].get() instanceof Expressions.SourceFieldSymbol)) {
83935
+ identifier = procedure.identifierAt(children[0].getFirstToken());
83936
+ next = 1;
83937
+ }
83938
+ else if (children[0] instanceof nodes_1.ExpressionNode && children[0].get() instanceof Expressions.ClassName
83939
+ && ((_a = children[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "=>" && children[2] instanceof nodes_1.ExpressionNode) {
83940
+ identifier = procedure.identifierAt(children[2].getFirstToken());
83941
+ next = 3;
83942
+ }
83943
+ else {
83944
+ return undefined;
83945
+ }
83946
+ let type = identifier instanceof _typed_identifier_1.TypedIdentifier ? identifier.getType() : undefined;
83947
+ for (let i = next; i < children.length; i += 2) {
83948
+ const separator = children[i];
83949
+ const name = children[i + 1];
83950
+ if (!(separator instanceof nodes_1.TokenNode) || !(name instanceof nodes_1.ExpressionNode) || type === undefined) {
83951
+ return undefined;
83952
+ }
83953
+ else if (separator.getFirstToken().getStr() === "->" && name.get() instanceof Expressions.AttributeName) {
83954
+ const attribute = procedure.identifierAt(name.getFirstToken());
83955
+ type = attribute instanceof _typed_identifier_1.TypedIdentifier ? attribute.getType() : undefined;
83956
+ }
83957
+ else if (separator.getFirstToken().getStr() === "-" && name.get() instanceof Expressions.ComponentName
83958
+ && type instanceof basic_1.StructureType) {
83959
+ type = type.getComponentByName(name.getFirstToken().getStr());
83960
+ }
83961
+ else {
83962
+ return undefined;
83963
+ }
83964
+ }
83965
+ return type;
83966
+ }
83967
+ /** value of a character literal, a character constant or a character component of a constant structure */
83968
+ constantValue(procedure, source) {
83969
+ var _a;
83970
+ var _b;
83971
+ if (source.findDirectExpression(Expressions.Constant) !== undefined) {
83972
+ return (0, _procedure_analysis_1.characterConstant)(procedure, source);
83973
+ }
83974
+ const chain = source.getChildren().length === 1 ? source.findDirectExpression(Expressions.FieldChain) : undefined;
83975
+ const children = (_b = chain === null || chain === void 0 ? void 0 : chain.getChildren()) !== null && _b !== void 0 ? _b : [];
83976
+ let identifier;
83977
+ let next;
83978
+ if (children[0] instanceof nodes_1.ExpressionNode && children[0].get() instanceof Expressions.SourceField) {
83979
+ identifier = procedure.identifierAt(children[0].getFirstToken());
83980
+ next = 1;
83981
+ }
83982
+ else if (children[0] instanceof nodes_1.ExpressionNode && children[0].get() instanceof Expressions.ClassName
83983
+ && ((_a = children[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "=>" && children[2] instanceof nodes_1.ExpressionNode
83984
+ && children[2].get() instanceof Expressions.AttributeName) {
83985
+ identifier = procedure.identifierAt(children[2].getFirstToken());
83986
+ next = 3;
83987
+ }
83988
+ else {
83989
+ return undefined;
83990
+ }
83991
+ if (!(identifier instanceof _typed_identifier_1.TypedIdentifier) || !(0, _procedure_analysis_1.isImmutable)(identifier)) {
83992
+ return undefined;
83993
+ }
83994
+ let type = identifier.getType();
83995
+ let value = identifier.getValue();
83996
+ if (children.length === next + 2) {
83997
+ const name = children[next + 1];
83998
+ if (children[next].getFirstToken().getStr() !== "-" || !(name instanceof nodes_1.ExpressionNode)
83999
+ || !(name.get() instanceof Expressions.ComponentName) || !(type instanceof basic_1.StructureType)
84000
+ || typeof value !== "object") {
84001
+ return undefined;
84002
+ }
84003
+ const component = name.getFirstToken().getStr().toLowerCase();
84004
+ type = type.getComponentByName(component);
84005
+ const key = Object.keys(value).find(k => k.toLowerCase() === component);
84006
+ value = key === undefined ? undefined : value[key];
84007
+ }
84008
+ else if (children.length !== next) {
84009
+ return undefined;
84010
+ }
84011
+ const text = typeof value === "string" ? (0, _procedure_analysis_1.textLiteral)(value) : undefined;
84012
+ if (!(type instanceof basic_1.CharacterType) || text === undefined) {
84013
+ return undefined;
84014
+ }
84015
+ // the value is cut to the length of the constant
84016
+ return text.substring(0, type.getLength());
84017
+ }
83699
84018
  }
83700
84019
  exports.ConstantCondition = ConstantCondition;
83701
84020
  //# sourceMappingURL=constant_condition.js.map
@@ -92302,6 +92621,11 @@ class Conditions {
92302
92621
  }
92303
92622
  }
92304
92623
  class IdenticalConditionsConf extends _basic_rule_config_1.BasicRuleConfig {
92624
+ constructor() {
92625
+ super(...arguments);
92626
+ /** Report a comparison of an operand with itself, like a = a or a <> a */
92627
+ this.selfComparison = true;
92628
+ }
92305
92629
  }
92306
92630
  exports.IdenticalConditionsConf = IdenticalConditionsConf;
92307
92631
  class IdenticalConditions extends _abap_rule_1.ABAPRule {
@@ -92316,19 +92640,30 @@ class IdenticalConditions extends _abap_rule_1.ABAPRule {
92316
92640
  shortDescription: `Find identical conditions in IF + CASE + WHILE etc
92317
92641
 
92318
92642
  Prerequsites: code is pretty printed with identical cAsE`,
92643
+ extendedInformation: `Option selfComparison: reports a comparison with =, <>, <, >, <= or >= (and EQ, NE, LT, GT, LE, GE)
92644
+ whose two operands are the same data object, like a = a or ls_new-id <> ls_new-id. The comparison is always true or
92645
+ always false, usually one side should be another field.
92646
+
92647
+ Only operands that are data objects are compared: fields, components, attributes, field symbols, dereferences,
92648
+ offset/length and table expressions without calls. Not reported: method calls and built-in functions, which can
92649
+ return different values, literals like 1 = 1, ASSERT, and SQL conditions.`,
92319
92650
  tags: [_irule_1.RuleTag.SingleFile],
92320
92651
  badExample: `IF foo = bar OR 1 = a OR foo = bar.
92321
92652
  ENDIF.
92322
92653
  CASE bar.
92323
92654
  WHEN '1'.
92324
92655
  WHEN 'A' OR '1'.
92325
- ENDCASE.`,
92656
+ ENDCASE.
92657
+ IF ls_new-id = ls_new-id.
92658
+ ENDIF.`,
92326
92659
  goodExample: `IF foo = bar OR 1 = a.
92327
92660
  ENDIF.
92328
92661
  CASE bar.
92329
92662
  WHEN '1'.
92330
92663
  WHEN 'A'.
92331
- ENDCASE.`,
92664
+ ENDCASE.
92665
+ IF ls_new-id = ls_old-id.
92666
+ ENDIF.`,
92332
92667
  };
92333
92668
  }
92334
92669
  getConfig() {
@@ -92352,9 +92687,67 @@ ENDCASE.`,
92352
92687
  for (const i of structure.findAllExpressions(Expressions.Cond)) {
92353
92688
  issues = issues.concat(this.analyzeCond(file, i));
92354
92689
  }
92690
+ if (this.conf.selfComparison) {
92691
+ issues = issues.concat(this.analyzeSelfComparison(file));
92692
+ }
92355
92693
  return issues;
92356
92694
  }
92357
92695
  ////////////////
92696
+ analyzeSelfComparison(file) {
92697
+ const issues = [];
92698
+ for (const statement of file.getStatements()) {
92699
+ if (statement.get() instanceof Statements.Assert) {
92700
+ continue;
92701
+ }
92702
+ for (const compare of statement.findAllExpressionsRecursive(Expressions.Compare)) {
92703
+ const children = compare.getChildren();
92704
+ const negated = children[0] instanceof nodes_1.TokenNode && children[0].getFirstToken().getStr().toUpperCase() === "NOT";
92705
+ const rest = children.slice(negated ? 1 : 0);
92706
+ if (rest.length !== 3
92707
+ || !(rest[0] instanceof nodes_1.ExpressionNode) || !(rest[0].get() instanceof Expressions.Source)
92708
+ || !(rest[1] instanceof nodes_1.ExpressionNode) || !(rest[1].get() instanceof Expressions.CompareOperator)
92709
+ || !(rest[2] instanceof nodes_1.ExpressionNode) || !(rest[2].get() instanceof Expressions.Source)) {
92710
+ continue;
92711
+ }
92712
+ const operator = rest[1].concatTokens().toUpperCase().replace(/ /g, "");
92713
+ const value = this.selfValue(operator);
92714
+ const left = this.dataObject(rest[0]);
92715
+ if (value === undefined || left === undefined || left !== this.dataObject(rest[2])) {
92716
+ continue;
92717
+ }
92718
+ const result = value !== negated ? "true" : "false";
92719
+ const message = "Comparison is always " + result + ", " + rest[0].concatTokens() + " is compared with itself";
92720
+ issues.push(issue_1.Issue.atRange(file, compare.getFirstToken().getStart(), compare.getLastToken().getEnd(), message, this.getMetadata().key, this.conf.severity));
92721
+ }
92722
+ }
92723
+ return issues;
92724
+ }
92725
+ /** result of comparing a value with itself, undefined for operators like CO or CP */
92726
+ selfValue(operator) {
92727
+ if (["=", "EQ", "<=", "=<", "LE", ">=", "=>", "GE"].includes(operator)) {
92728
+ return true;
92729
+ }
92730
+ else if (["<>", "><", "NE", "<", "LT", ">", "GT"].includes(operator)) {
92731
+ return false;
92732
+ }
92733
+ return undefined;
92734
+ }
92735
+ /** the text of an operand that is a data object without calls, names in upper case, literals as they are */
92736
+ dataObject(source) {
92737
+ const children = source.getChildren();
92738
+ if (!(children[0] instanceof nodes_1.ExpressionNode) || !(children[0].get() instanceof Expressions.FieldChain)
92739
+ || (children.length === 2 && !(children[1].get() instanceof Expressions.Dereference))
92740
+ || children.length > 2
92741
+ || source.findFirstExpression(Expressions.MethodCall) !== undefined
92742
+ || source.findFirstExpression(Expressions.MethodCallChain) !== undefined
92743
+ || source.findFirstExpression(Expressions.NewObject) !== undefined) {
92744
+ return undefined;
92745
+ }
92746
+ return source.getTokens().map(t => {
92747
+ const str = t.getStr();
92748
+ return str.startsWith("'") || str.startsWith("`") || str.startsWith("|") || str.startsWith("}") ? str : str.toUpperCase();
92749
+ }).join(" ");
92750
+ }
92358
92751
  analyzeCond(file, node) {
92359
92752
  const conditions = new Conditions();
92360
92753
  let operator = "";
@@ -94046,6 +94439,7 @@ __exportStar(__webpack_require__(/*! ./in_statement_indentation */ "../core/buil
94046
94439
  __exportStar(__webpack_require__(/*! ./indentation */ "../core/build/src/rules/indentation.js"), exports);
94047
94440
  __exportStar(__webpack_require__(/*! ./index_completely_contained */ "../core/build/src/rules/index_completely_contained.js"), exports);
94048
94441
  __exportStar(__webpack_require__(/*! ./inline_data_old_versions */ "../core/build/src/rules/inline_data_old_versions.js"), exports);
94442
+ __exportStar(__webpack_require__(/*! ./inline_generic_source */ "../core/build/src/rules/inline_generic_source.js"), exports);
94049
94443
  __exportStar(__webpack_require__(/*! ./inline_packed_computation */ "../core/build/src/rules/inline_packed_computation.js"), exports);
94050
94444
  __exportStar(__webpack_require__(/*! ./intf_referencing_clas */ "../core/build/src/rules/intf_referencing_clas.js"), exports);
94051
94445
  __exportStar(__webpack_require__(/*! ./invalid_table_index */ "../core/build/src/rules/invalid_table_index.js"), exports);
@@ -94127,6 +94521,7 @@ __exportStar(__webpack_require__(/*! ./select_single_full_key */ "../core/build/
94127
94521
  __exportStar(__webpack_require__(/*! ./selection_screen_naming */ "../core/build/src/rules/selection_screen_naming.js"), exports);
94128
94522
  __exportStar(__webpack_require__(/*! ./selection_screen_texts_missing */ "../core/build/src/rules/selection_screen_texts_missing.js"), exports);
94129
94523
  __exportStar(__webpack_require__(/*! ./sequential_blank */ "../core/build/src/rules/sequential_blank.js"), exports);
94524
+ __exportStar(__webpack_require__(/*! ./sequential_read_sorted */ "../core/build/src/rules/sequential_read_sorted.js"), exports);
94130
94525
  __exportStar(__webpack_require__(/*! ./short_case */ "../core/build/src/rules/short_case.js"), exports);
94131
94526
  __exportStar(__webpack_require__(/*! ./sicf_consistency */ "../core/build/src/rules/sicf_consistency.js"), exports);
94132
94527
  __exportStar(__webpack_require__(/*! ./single_use_expression_temp */ "../core/build/src/rules/single_use_expression_temp.js"), exports);
@@ -94365,6 +94760,186 @@ exports.InlineDataOldVersions = InlineDataOldVersions;
94365
94760
 
94366
94761
  /***/ },
94367
94762
 
94763
+ /***/ "../core/build/src/rules/inline_generic_source.js"
94764
+ /*!********************************************************!*\
94765
+ !*** ../core/build/src/rules/inline_generic_source.js ***!
94766
+ \********************************************************/
94767
+ (__unused_webpack_module, exports, __webpack_require__) {
94768
+
94769
+ "use strict";
94770
+
94771
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
94772
+ if (k2 === undefined) k2 = k;
94773
+ var desc = Object.getOwnPropertyDescriptor(m, k);
94774
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
94775
+ desc = { enumerable: true, get: function() { return m[k]; } };
94776
+ }
94777
+ Object.defineProperty(o, k2, desc);
94778
+ }) : (function(o, m, k, k2) {
94779
+ if (k2 === undefined) k2 = k;
94780
+ o[k2] = m[k];
94781
+ }));
94782
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
94783
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
94784
+ }) : function(o, v) {
94785
+ o["default"] = v;
94786
+ });
94787
+ var __importStar = (this && this.__importStar) || (function () {
94788
+ var ownKeys = function(o) {
94789
+ ownKeys = Object.getOwnPropertyNames || function (o) {
94790
+ var ar = [];
94791
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
94792
+ return ar;
94793
+ };
94794
+ return ownKeys(o);
94795
+ };
94796
+ return function (mod) {
94797
+ if (mod && mod.__esModule) return mod;
94798
+ var result = {};
94799
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
94800
+ __setModuleDefault(result, mod);
94801
+ return result;
94802
+ };
94803
+ })();
94804
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
94805
+ exports.InlineGenericSource = exports.InlineGenericSourceConf = void 0;
94806
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
94807
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
94808
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
94809
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
94810
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
94811
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
94812
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
94813
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
94814
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
94815
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
94816
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
94817
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
94818
+ class InlineGenericSourceConf extends _basic_rule_config_1.BasicRuleConfig {
94819
+ }
94820
+ exports.InlineGenericSourceConf = InlineGenericSourceConf;
94821
+ class InlineGenericSource {
94822
+ constructor() {
94823
+ this.conf = new InlineGenericSourceConf();
94824
+ }
94825
+ getMetadata() {
94826
+ return {
94827
+ key: "inline_generic_source",
94828
+ title: "Inline declaration from a generically typed source",
94829
+ shortDescription: `Finds inline declarations whose value is a generically typed parameter or field symbol`,
94830
+ extendedInformation: `DATA( ) or FINAL( ) takes the type of the source. When the source is a parameter or
94831
+ field symbol with a generic type, the type is fixed when the program is compiled: string for clike and
94832
+ csequence, xstring for xsequence. The syntax check warns "The fixed type STRING is used for the generic
94833
+ type CLIKE".
94834
+
94835
+ Reported for DATA(var) = source and FINAL(var) = source when the source is just the parameter or field
94836
+ symbol. Most other generic types cannot be made concrete, that is a syntax error which check_syntax reports.
94837
+
94838
+ Declare the variable with a type, or name the type with CONV.
94839
+
94840
+ The pragma ##TYPE, which hides the syntax check warning, also hides this issue.
94841
+
94842
+ prefer_inline does not suggest inline declarations for generic sources, this rule reports the ones
94843
+ that exist.
94844
+
94845
+ https://help.sap.com/doc/abapdocu_758_index_htm/7.58/en-US/abapmove.htm`,
94846
+ tags: [_irule_1.RuleTag.Quickfix],
94847
+ pragma: "##TYPE",
94848
+ badExample: `METHOD m. " IMPORTING iv TYPE clike
94849
+ DATA(lv) = iv.
94850
+ ENDMETHOD.`,
94851
+ goodExample: `METHOD m. " IMPORTING iv TYPE clike
94852
+ DATA(lv) = CONV string( iv ).
94853
+ ENDMETHOD.`,
94854
+ };
94855
+ }
94856
+ getConfig() {
94857
+ return this.conf;
94858
+ }
94859
+ setConfig(conf) {
94860
+ this.conf = conf;
94861
+ }
94862
+ initialize(reg) {
94863
+ this.reg = reg;
94864
+ return this;
94865
+ }
94866
+ run(obj) {
94867
+ var _a, _b, _c;
94868
+ if (!(obj instanceof _abap_object_1.ABAPObject)) {
94869
+ return [];
94870
+ }
94871
+ const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
94872
+ if (syntax.issues.length > 0) {
94873
+ return [];
94874
+ }
94875
+ const issues = [];
94876
+ for (const file of obj.getABAPFiles()) {
94877
+ for (const statement of file.getStatements()) {
94878
+ if (!(statement.get() instanceof Statements.Move)
94879
+ || statement.getPragmas().some(p => p.getStr().toUpperCase() === this.getMetadata().pragma)) {
94880
+ continue;
94881
+ }
94882
+ const inline = (_a = statement.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.InlineData);
94883
+ const name = (_b = inline === null || inline === void 0 ? void 0 : inline.findDirectExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
94884
+ const operand = this.singleOperand(statement.findDirectExpression(Expressions.Source));
94885
+ if (name === undefined || operand === undefined) {
94886
+ continue;
94887
+ }
94888
+ const scope = syntax.spaghetti.lookupPosition(name.getStart(), file.getFilename());
94889
+ const resolved = (_c = scope === null || scope === void 0 ? void 0 : scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.DataReadReference
94890
+ && reference.position.getStart().equals(operand.getFirstToken().getStart()))) === null || _c === void 0 ? void 0 : _c.resolved;
94891
+ if (!(resolved instanceof _typed_identifier_1.TypedIdentifier)) {
94892
+ continue;
94893
+ }
94894
+ const fixed = this.fixedType(resolved.getType());
94895
+ if (fixed === undefined) {
94896
+ continue;
94897
+ }
94898
+ const message = `The fixed type ${fixed.fixed} is used for the generic type ${fixed.generic} of "${operand.concatTokens()}", ` +
94899
+ `declare "${name.getStr()}" with a type or use CONV`;
94900
+ const replacement = `CONV ${fixed.conv}( ${operand.concatTokens()} )`;
94901
+ const fix = edit_helper_1.EditHelper.replaceRange(file, operand.getFirstToken().getStart(), operand.getLastToken().getEnd(), replacement);
94902
+ issues.push(issue_1.Issue.atToken(file, name, message, this.getMetadata().key, this.conf.severity, fix));
94903
+ }
94904
+ }
94905
+ return issues;
94906
+ }
94907
+ /** The source when it is a single field or field symbol, without components, offset/length or dereference */
94908
+ singleOperand(source) {
94909
+ if (source === undefined || source.getChildren().length !== 1) {
94910
+ return undefined;
94911
+ }
94912
+ const chain = source.findDirectExpression(Expressions.FieldChain);
94913
+ if (chain === undefined || chain.getChildren().length !== 1) {
94914
+ return undefined;
94915
+ }
94916
+ const first = chain.getFirstChild();
94917
+ if (first instanceof nodes_1.ExpressionNode
94918
+ && (first.get() instanceof Expressions.SourceField || first.get() instanceof Expressions.SourceFieldSymbol)) {
94919
+ return chain;
94920
+ }
94921
+ return undefined;
94922
+ }
94923
+ /** The type the system uses for a generic type in an inline declaration, undefined if the type is not generic,
94924
+ * or is a generic type that check_syntax does not make concrete */
94925
+ fixedType(type) {
94926
+ if (type instanceof basic_1.CLikeType) {
94927
+ return { generic: "CLIKE", fixed: "STRING", conv: "string" };
94928
+ }
94929
+ else if (type instanceof basic_1.CSequenceType) {
94930
+ return { generic: "CSEQUENCE", fixed: "STRING", conv: "string" };
94931
+ }
94932
+ else if (type instanceof basic_1.XSequenceType) {
94933
+ return { generic: "XSEQUENCE", fixed: "XSTRING", conv: "xstring" };
94934
+ }
94935
+ return undefined;
94936
+ }
94937
+ }
94938
+ exports.InlineGenericSource = InlineGenericSource;
94939
+ //# sourceMappingURL=inline_generic_source.js.map
94940
+
94941
+ /***/ },
94942
+
94368
94943
  /***/ "../core/build/src/rules/inline_packed_computation.js"
94369
94944
  /*!************************************************************!*\
94370
94945
  !*** ../core/build/src/rules/inline_packed_computation.js ***!
@@ -105269,6 +105844,12 @@ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_i
105269
105844
  const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
105270
105845
  const version_1 = __webpack_require__(/*! ../version */ "../core/build/src/version.js");
105271
105846
  class RedundantConversionConf extends _basic_rule_config_1.BasicRuleConfig {
105847
+ constructor() {
105848
+ super(...arguments);
105849
+ /** Also report a CONV that is the whole right-hand side of an assignment whose target already has the
105850
+ * conversion type, e.g. "count = CONV i( text )." with count TYPE i, the assignment converts by itself */
105851
+ this.assignmentTarget = true;
105852
+ }
105272
105853
  }
105273
105854
  exports.RedundantConversionConf = RedundantConversionConf;
105274
105855
  class RedundantConversion {
@@ -105281,7 +105862,12 @@ class RedundantConversion {
105281
105862
  title: "Redundant Conversion",
105282
105863
  shortDescription: `Find redundant CONV expressions`,
105283
105864
  extendedInformation: `Reports CONV expressions whose operand already has the conversion's target type,
105284
- including the result of a built-in function with a fixed result type, like to_upper( ) or strlen( ).`,
105865
+ including the result of a built-in function with a fixed result type, like to_upper( ) or strlen( ).
105866
+
105867
+ With option assignmentTarget, also reports a CONV that is the whole right-hand side of an assignment
105868
+ whose target already has the conversion's type, "count = CONV i( text )." with count TYPE i, the
105869
+ assignment converts by itself. Not reported for inline declarations, enumerated types, LET, and operands
105870
+ with a generic type.`,
105285
105871
  tags: [_irule_1.RuleTag.Quickfix],
105286
105872
  badExample: `DATA text TYPE string.
105287
105873
  text = CONV string( text ).`,
@@ -105341,7 +105927,11 @@ text = text.`,
105341
105927
  }
105342
105928
  const operandHasSameType = operandType !== undefined && this.sameType(target.getType(), operandType);
105343
105929
  const arithmeticHasSameContext = this.arithmeticUsesSameTargetType(source, bodySource, file, scope, target.getType());
105344
- if (operandHasSameType === false && arithmeticHasSameContext === false) {
105930
+ const assignmentHasSameType = this.conf.assignmentTarget !== false
105931
+ && this.assignmentTargetHasSameType(source, file, scope, target.getType());
105932
+ if (operandHasSameType === false
105933
+ && arithmeticHasSameContext === false
105934
+ && assignmentHasSameType === false) {
105345
105935
  continue;
105346
105936
  }
105347
105937
  const closingParen = source.getDirectTokens().find(token => token.getStr() === ")" && token.getStart().isAfter(bodySource.getLastToken().getStart()));
@@ -105376,6 +105966,88 @@ text = text.`,
105376
105966
  return assignmentTarget instanceof _typed_identifier_1.TypedIdentifier
105377
105967
  && this.sameType(conversionType, assignmentTarget.getType());
105378
105968
  }
105969
+ /** "target = CONV i( text )." where target has the conversion type, the assignment converts the same way */
105970
+ assignmentTargetHasSameType(conversion, file, scope, conversionType) {
105971
+ var _a;
105972
+ // CONV converts the base type to an enumerated type, a plain assignment does not compile
105973
+ if (conversionType instanceof basic_1.EnumType) {
105974
+ return false;
105975
+ }
105976
+ const body = conversion.findDirectExpression(Expressions.ConvBody);
105977
+ if (body === undefined
105978
+ || body.findDirectExpression(Expressions.Let) !== undefined
105979
+ // "CONV type ( body )" without a trailing operator
105980
+ || conversion.getChildren().length !== 5) {
105981
+ return false;
105982
+ }
105983
+ // "target = CONV ...", not "+=", "?=", "a = b = CONV ..." or MOVE
105984
+ const statement = file.getStatements().find(candidate => candidate.includesToken(conversion.getFirstToken()));
105985
+ const children = (_a = statement === null || statement === void 0 ? void 0 : statement.getChildren()) !== null && _a !== void 0 ? _a : [];
105986
+ const target = children[0];
105987
+ if (!((statement === null || statement === void 0 ? void 0 : statement.get()) instanceof Statements.Move)
105988
+ || children.length !== 4
105989
+ || !(target instanceof nodes_1.ExpressionNode)
105990
+ || !(target.get() instanceof Expressions.Target)
105991
+ || children[1].concatTokens() !== "="
105992
+ || children[2] !== conversion) {
105993
+ return false;
105994
+ }
105995
+ // a generic operand gets its type from the CONV, also "ref->*" with ref TYPE REF TO data
105996
+ const bodyStart = body.getFirstToken().getStart();
105997
+ const bodyEnd = body.getLastToken().getEnd();
105998
+ const genericOperand = scope.getData().references.some(reference => {
105999
+ if (reference.referenceType !== _reference_1.ReferenceType.DataReadReference
106000
+ || reference.position.getFilename() !== file.getFilename()
106001
+ || reference.position.getStart().isBetween(bodyStart, bodyEnd) === false
106002
+ || !(reference.resolved instanceof _typed_identifier_1.TypedIdentifier)) {
106003
+ return false;
106004
+ }
106005
+ const type = reference.resolved.getType();
106006
+ return type.isGeneric() || (type instanceof basic_1.DataReference && type.getType().isGeneric());
106007
+ });
106008
+ if (genericOperand === true) {
106009
+ return false;
106010
+ }
106011
+ const targetType = this.targetType(target, scope);
106012
+ return targetType !== undefined && this.sameType(conversionType, targetType);
106013
+ }
106014
+ /** Type of a variable, field symbol, attribute or structure component, undefined for anything else */
106015
+ targetType(target, scope) {
106016
+ var _a;
106017
+ let type;
106018
+ for (const child of target.getChildren()) {
106019
+ if (child instanceof nodes_1.TokenNode) {
106020
+ if (["-", "->", "=>"].includes(child.getFirstToken().getStr()) === false) {
106021
+ return undefined;
106022
+ }
106023
+ }
106024
+ else if (child.get() instanceof Expressions.TargetField
106025
+ || child.get() instanceof Expressions.TargetFieldSymbol
106026
+ || child.get() instanceof Expressions.AttributeName) {
106027
+ const resolved = (_a = scope.getData().references.find(reference => (reference.referenceType === _reference_1.ReferenceType.DataWriteReference
106028
+ || reference.referenceType === _reference_1.ReferenceType.DataReadReference)
106029
+ && reference.position.getStart().equals(child.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
106030
+ if (!(resolved instanceof _typed_identifier_1.TypedIdentifier)) {
106031
+ return undefined;
106032
+ }
106033
+ type = resolved.getType();
106034
+ }
106035
+ else if (child.get() instanceof Expressions.ComponentName) {
106036
+ if (type instanceof basic_1.TableType) {
106037
+ type = type.getRowType();
106038
+ }
106039
+ if (!(type instanceof basic_1.StructureType)) {
106040
+ return undefined;
106041
+ }
106042
+ type = type.getComponentByName(child.concatTokens());
106043
+ }
106044
+ else if (!(child.get() instanceof Expressions.ClassName)) {
106045
+ // inline declarations, dereferences, table expressions, offsets and lengths
106046
+ return undefined;
106047
+ }
106048
+ }
106049
+ return type;
106050
+ }
105379
106051
  sourceType(source, scope) {
105380
106052
  let context;
105381
106053
  // boolc( <condition> ) is not a MethodCallChain, xsdbool( ) has the same shape but is not reported
@@ -106773,6 +107445,334 @@ exports.SequentialBlank = SequentialBlank;
106773
107445
 
106774
107446
  /***/ },
106775
107447
 
107448
+ /***/ "../core/build/src/rules/sequential_read_sorted.js"
107449
+ /*!*********************************************************!*\
107450
+ !*** ../core/build/src/rules/sequential_read_sorted.js ***!
107451
+ \*********************************************************/
107452
+ (__unused_webpack_module, exports, __webpack_require__) {
107453
+
107454
+ "use strict";
107455
+
107456
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
107457
+ if (k2 === undefined) k2 = k;
107458
+ var desc = Object.getOwnPropertyDescriptor(m, k);
107459
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
107460
+ desc = { enumerable: true, get: function() { return m[k]; } };
107461
+ }
107462
+ Object.defineProperty(o, k2, desc);
107463
+ }) : (function(o, m, k, k2) {
107464
+ if (k2 === undefined) k2 = k;
107465
+ o[k2] = m[k];
107466
+ }));
107467
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
107468
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
107469
+ }) : function(o, v) {
107470
+ o["default"] = v;
107471
+ });
107472
+ var __importStar = (this && this.__importStar) || (function () {
107473
+ var ownKeys = function(o) {
107474
+ ownKeys = Object.getOwnPropertyNames || function (o) {
107475
+ var ar = [];
107476
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
107477
+ return ar;
107478
+ };
107479
+ return ownKeys(o);
107480
+ };
107481
+ return function (mod) {
107482
+ if (mod && mod.__esModule) return mod;
107483
+ var result = {};
107484
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
107485
+ __setModuleDefault(result, mod);
107486
+ return result;
107487
+ };
107488
+ })();
107489
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
107490
+ exports.SequentialReadSorted = exports.SequentialReadSortedConf = void 0;
107491
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
107492
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
107493
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
107494
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
107495
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
107496
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
107497
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
107498
+ const _key_compare_1 = __webpack_require__(/*! ../abap/5_syntax/_key_compare */ "../core/build/src/abap/5_syntax/_key_compare.js");
107499
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
107500
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
107501
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
107502
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
107503
+ const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
107504
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
107505
+ class SequentialReadSortedConf extends _basic_rule_config_1.BasicRuleConfig {
107506
+ constructor() {
107507
+ super(...arguments);
107508
+ this.severity = severity_1.Severity.Warning;
107509
+ }
107510
+ }
107511
+ exports.SequentialReadSortedConf = SequentialReadSortedConf;
107512
+ class SequentialReadSorted {
107513
+ constructor() {
107514
+ this.conf = new SequentialReadSortedConf();
107515
+ }
107516
+ getMetadata() {
107517
+ return {
107518
+ key: "sequential_read_sorted",
107519
+ title: "Sequential read on a sorted table",
107520
+ shortDescription: `A WHERE condition or a free key on a sorted table that does not use the primary key`,
107521
+ extendedInformation: `A sorted table is read with a binary search only when the condition fixes an initial part of
107522
+ its key. When the first key component is not compared with = or EQ (or IS INITIAL) in a part of the condition joined
107523
+ by AND, every line is read, like on a standard table. The SAP check "Low Performance Operations on Internal Tables"
107524
+ reports this as "Possible sequential read on a sorted table".
107525
+
107526
+ Checked: LOOP AT ... WHERE, DELETE ... WHERE, MODIFY ... WHERE, READ TABLE ... WITH KEY and table expressions
107527
+ itab[ comp = ... ], on a table whose type is statically known as SORTED with explicit key components, using the
107528
+ primary key.
107529
+
107530
+ Not checked: standard, hashed, generic and unknown table types, tables with a default key, a dynamic WHERE or
107531
+ dynamic components, WITH TABLE KEY, a named key (USING KEY, KEY ... COMPONENTS) other than primary_key,
107532
+ READ TABLE ... BINARY SEARCH and access by index, including LOOP AT and DELETE with FROM or TO.
107533
+
107534
+ Fix: compare the first key component with =, change the key or the table type, or add a secondary key.
107535
+ If the sequential read is intended, add the pseudo comment "#EC CI_SORTSEQ to the statement.`,
107536
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Performance],
107537
+ pseudoComment: "EC CI_SORTSEQ",
107538
+ badExample: `DATA lt_nodes TYPE SORTED TABLE OF ty_node WITH UNIQUE KEY path name.
107539
+ LOOP AT lt_nodes INTO ls_node WHERE name = lv_name.
107540
+ ENDLOOP.
107541
+ DELETE lt_nodes WHERE path CP lv_pattern.`,
107542
+ goodExample: `DATA lt_nodes TYPE SORTED TABLE OF ty_node WITH UNIQUE KEY path name.
107543
+ LOOP AT lt_nodes INTO ls_node WHERE path = lv_path AND name = lv_name.
107544
+ ENDLOOP.
107545
+ DELETE lt_nodes WHERE path CP lv_pattern. "#EC CI_SORTSEQ`,
107546
+ };
107547
+ }
107548
+ getConfig() {
107549
+ return this.conf;
107550
+ }
107551
+ initialize(reg) {
107552
+ this.reg = reg;
107553
+ return this;
107554
+ }
107555
+ setConfig(conf) {
107556
+ this.conf = conf;
107557
+ }
107558
+ run(obj) {
107559
+ if (!(obj instanceof _abap_object_1.ABAPObject) || obj.getType() === "INTF") {
107560
+ return [];
107561
+ }
107562
+ const issues = [];
107563
+ let spaghetti = undefined;
107564
+ for (const file of obj.getABAPFiles()) {
107565
+ const statements = file.getStatements();
107566
+ const pseudoRows = this.findPseudoCommentRows(statements);
107567
+ for (const statement of statements) {
107568
+ const get = statement.get();
107569
+ if (get instanceof _statement_1.Comment) {
107570
+ continue;
107571
+ }
107572
+ const isWhere = get instanceof Statements.Loop
107573
+ || get instanceof Statements.DeleteInternal
107574
+ || get instanceof Statements.ModifyInternal;
107575
+ const isRead = get instanceof Statements.ReadTable;
107576
+ if (isWhere === false
107577
+ && isRead === false
107578
+ && statement.findFirstExpression(Expressions.TableExpression) === undefined) {
107579
+ continue;
107580
+ }
107581
+ if (this.hasPseudoComment(statement, pseudoRows)) {
107582
+ continue;
107583
+ }
107584
+ if (spaghetti === undefined) {
107585
+ spaghetti = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti;
107586
+ }
107587
+ if (isWhere === true) {
107588
+ this.checkWhere(statement, spaghetti, file, issues);
107589
+ }
107590
+ else if (isRead === true) {
107591
+ this.checkReadTable(statement, spaghetti, file, issues);
107592
+ }
107593
+ this.checkTableExpressions(statement, statement, spaghetti, file, issues);
107594
+ }
107595
+ }
107596
+ return issues;
107597
+ }
107598
+ ////////////////
107599
+ findPseudoCommentRows(statements) {
107600
+ const rows = new Set();
107601
+ for (const s of statements) {
107602
+ if (s.get() instanceof _statement_1.Comment && s.concatTokens().toUpperCase().includes(this.getMetadata().pseudoComment + "")) {
107603
+ rows.add(s.getStart().getRow());
107604
+ }
107605
+ }
107606
+ return rows;
107607
+ }
107608
+ /** the pseudo comment is accepted on any row of the statement */
107609
+ hasPseudoComment(statement, pseudoRows) {
107610
+ for (let row = statement.getStart().getRow(); row <= statement.getEnd().getRow(); row++) {
107611
+ if (pseudoRows.has(row)) {
107612
+ return true;
107613
+ }
107614
+ }
107615
+ return false;
107616
+ }
107617
+ /** LOOP AT, DELETE and MODIFY with a static WHERE condition */
107618
+ checkWhere(statement, spaghetti, file, issues) {
107619
+ var _a;
107620
+ const cond = statement.findDirectExpression(Expressions.ComponentCond);
107621
+ if (cond === undefined || this.usesPrimaryKey(statement) === false) {
107622
+ return;
107623
+ }
107624
+ let table;
107625
+ if (statement.get() instanceof Statements.Loop) {
107626
+ table = (_a = statement.findDirectExpression(Expressions.LoopSource)) === null || _a === void 0 ? void 0 : _a.getFirstChild();
107627
+ }
107628
+ else {
107629
+ table = statement.findDirectExpression(Expressions.Target);
107630
+ }
107631
+ if (table === undefined) {
107632
+ return;
107633
+ }
107634
+ if (!(statement.get() instanceof Statements.ModifyInternal)
107635
+ && (statement.findDirectTokenByText("FROM") !== undefined || statement.findDirectTokenByText("TO") !== undefined)) {
107636
+ // an index range
107637
+ return;
107638
+ }
107639
+ const first = this.firstKeyComponent(this.findType(table, spaghetti, file));
107640
+ if (first !== undefined && (0, _key_compare_1.hasKeyCompare)(cond, first) === false) {
107641
+ this.report(statement, table.concatTokens(), first, file, issues);
107642
+ }
107643
+ }
107644
+ checkReadTable(statement, spaghetti, file, issues) {
107645
+ var _a;
107646
+ if (statement.findTokenSequencePosition("WITH", "KEY") === undefined
107647
+ || statement.findDirectTokenByText("COMPONENTS") !== undefined
107648
+ || statement.findDirectTokenByText("BINARY") !== undefined) {
107649
+ return;
107650
+ }
107651
+ const compare = statement.findDirectExpression(Expressions.ComponentCompareSimple);
107652
+ const table = (_a = statement.findDirectExpression(Expressions.SimpleSource2)) !== null && _a !== void 0 ? _a : statement.findDirectExpression(Expressions.Source);
107653
+ if (compare === undefined || table === undefined) {
107654
+ return;
107655
+ }
107656
+ const first = this.firstKeyComponent(this.findType(table, spaghetti, file));
107657
+ if (first !== undefined && this.hasFreeKeyComponent(compare, first) === false) {
107658
+ this.report(statement, table.concatTokens(), first, file, issues);
107659
+ }
107660
+ }
107661
+ /** table expressions with a free key, itab[ comp = ... ], anywhere in the statement */
107662
+ checkTableExpressions(node, statement, spaghetti, file, issues) {
107663
+ var _a;
107664
+ const children = node.getChildren();
107665
+ for (let i = 0; i < children.length; i++) {
107666
+ const child = children[i];
107667
+ if (child instanceof nodes_1.TokenNode) {
107668
+ continue;
107669
+ }
107670
+ if (child.get() instanceof Expressions.TableExpression
107671
+ && child instanceof nodes_1.ExpressionNode
107672
+ && (node.get() instanceof Expressions.FieldChain || node.get() instanceof Expressions.Target)
107673
+ && ((_a = child.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.ComponentChainSimple) {
107674
+ // a free key, not an index and not a named key: KEY name [COMPONENTS]
107675
+ const first = this.firstKeyComponent(this.findChainType(children.slice(0, i), spaghetti, file));
107676
+ if (first !== undefined && this.hasFreeKeyComponent(child, first) === false) {
107677
+ const name = children.slice(0, i).map(c => c.concatTokens()).join("");
107678
+ this.report(statement, name, first, file, issues);
107679
+ }
107680
+ }
107681
+ this.checkTableExpressions(child, statement, spaghetti, file, issues);
107682
+ }
107683
+ }
107684
+ report(statement, name, first, file, issues) {
107685
+ const message = `Sequential read on sorted table ${name}, the first key component ${first} is not compared with =, ` +
107686
+ `add it to the condition or "#EC CI_SORTSEQ`;
107687
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
107688
+ }
107689
+ /** false if USING KEY names a key other than the primary key, or a dynamic one */
107690
+ usesPrimaryKey(statement) {
107691
+ if (statement.findDirectTokenByText("USING") === undefined) {
107692
+ return true;
107693
+ }
107694
+ const keyName = statement.findExpressionAfterToken("KEY");
107695
+ return (keyName === null || keyName === void 0 ? void 0 : keyName.get()) instanceof Expressions.SimpleName && keyName.concatTokens().toUpperCase() === "PRIMARY_KEY";
107696
+ }
107697
+ /** true if a free key, ComponentCompareSimple or the fields of a TableExpression, specifies the component;
107698
+ * also true when a component is dynamic, as it cannot be decided */
107699
+ hasFreeKeyComponent(node, component) {
107700
+ if (node.findDirectExpression(Expressions.Dynamic) !== undefined) {
107701
+ return true;
107702
+ }
107703
+ return node.findDirectExpressions(Expressions.ComponentChainSimple)
107704
+ .some(c => c.concatTokens().toUpperCase().replace(/\s+/g, "") === component);
107705
+ }
107706
+ /** The first component of the primary key of a sorted table with explicit key components, else undefined */
107707
+ firstKeyComponent(type) {
107708
+ var _a, _b;
107709
+ if (!(type instanceof basic_1.TableType)
107710
+ || type.getAccessType() !== basic_1.TableAccessType.sorted
107711
+ || type.getOptions().keyType !== basic_1.TableKeyType.user
107712
+ || type.isGeneric()) {
107713
+ return undefined;
107714
+ }
107715
+ return (_b = (_a = type.getOptions().primaryKey) === null || _a === void 0 ? void 0 : _a.keyFields[0]) === null || _b === void 0 ? void 0 : _b.toUpperCase();
107716
+ }
107717
+ findType(node, spaghetti, file) {
107718
+ if (!(node.get() instanceof Expressions.Target)) {
107719
+ const chain = node.getChildren().length === 1 ? node.findDirectExpression(Expressions.FieldChain) : undefined;
107720
+ if (chain === undefined) {
107721
+ return undefined;
107722
+ }
107723
+ node = chain;
107724
+ }
107725
+ return this.findChainType(node.getChildren(), spaghetti, file);
107726
+ }
107727
+ /** The type of a chain of names, components, attributes, dereferences and table expressions, else undefined */
107728
+ findChainType(children, spaghetti, file) {
107729
+ var _a;
107730
+ let type = undefined;
107731
+ for (const child of children) {
107732
+ const get = child.get();
107733
+ if (get instanceof Expressions.SourceField
107734
+ || get instanceof Expressions.SourceFieldSymbol
107735
+ || get instanceof Expressions.TargetField
107736
+ || get instanceof Expressions.TargetFieldSymbol
107737
+ || get instanceof Expressions.AttributeName) {
107738
+ type = (_a = this.findReference(child.getFirstToken().getStart(), spaghetti, file)) === null || _a === void 0 ? void 0 : _a.getType();
107739
+ }
107740
+ else if (get instanceof Expressions.ComponentName) {
107741
+ type = type instanceof basic_1.StructureType ? type.getComponentByName(child.concatTokens()) : undefined;
107742
+ }
107743
+ else if (get instanceof Expressions.Dereference) {
107744
+ type = type instanceof basic_1.DataReference ? type.getType() : undefined;
107745
+ }
107746
+ else if (get instanceof Expressions.TableExpression) {
107747
+ type = type instanceof basic_1.TableType ? type.getRowType() : undefined;
107748
+ }
107749
+ else if (get instanceof Expressions.ClassName || get instanceof tokens_1.StaticArrow) {
107750
+ continue;
107751
+ }
107752
+ else if (!(get instanceof tokens_1.Dash) && !(get instanceof tokens_1.InstanceArrow)) {
107753
+ return undefined;
107754
+ }
107755
+ if (type === undefined) {
107756
+ return undefined;
107757
+ }
107758
+ }
107759
+ return type;
107760
+ }
107761
+ findReference(start, spaghetti, file) {
107762
+ const scope = spaghetti.lookupPosition(start, file.getFilename());
107763
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
107764
+ if (r.position.getStart().equals(start) && r.resolved instanceof _typed_identifier_1.TypedIdentifier) {
107765
+ return r.resolved;
107766
+ }
107767
+ }
107768
+ return undefined;
107769
+ }
107770
+ }
107771
+ exports.SequentialReadSorted = SequentialReadSorted;
107772
+ //# sourceMappingURL=sequential_read_sorted.js.map
107773
+
107774
+ /***/ },
107775
+
106776
107776
  /***/ "../core/build/src/rules/short_case.js"
106777
107777
  /*!*********************************************!*\
106778
107778
  !*** ../core/build/src/rules/short_case.js ***!
@@ -114118,6 +115118,7 @@ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../co
114118
115118
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
114119
115119
  const fast_xml_parser_1 = __webpack_require__(/*! fast-xml-parser */ "../core/node_modules/fast-xml-parser/lib/fxp.cjs");
114120
115120
  const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
115121
+ const xml_utils_1 = __webpack_require__(/*! ../xml_utils */ "../core/build/src/xml_utils.js");
114121
115122
  const ABAPGIT_ATTRIBUTES = [
114122
115123
  ["version", /<abapGit\b[^>]*\bversion="([^"]+)"/],
114123
115124
  ["serializer_version", /<abapGit\b[^>]*\bserializer_version="([^"]+)"/],
@@ -114150,6 +115151,7 @@ class XMLConsistency {
114150
115151
  * QUAN fields in TABL objects have reference table and field values
114151
115152
  * Transparent TABL objects have delivery class and size category set
114152
115153
  * TABL fields with a built-in type carry the INTTYPE abapGit serializes for it, for the confirmed pairs
115154
+ * Documentation lines(TDLINE) in CLAS and INTF objects are max 72 characters, longer lines are cut by the system
114153
115155
  * Lock parameter names in ENQU objects are max 16 characters
114154
115156
  * DEVC objects are serialized as package.devc.xml
114155
115157
  * Texts and translations do not exceed maximum allowed length.`,
@@ -114237,6 +115239,27 @@ class XMLConsistency {
114237
115239
  issues.push(issue_1.Issue.atRow(file, 1, "Class matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
114238
115240
  }
114239
115241
  issues.push(...this.checkClearedFields(obj, file, "VSEOCLASS", XMLConsistency.clearedClassFields));
115242
+ issues.push(...this.checkDocumentationLines(obj, file));
115243
+ return issues;
115244
+ }
115245
+ // the documentation editor stores lines of max 72 characters, longer TDLINEs are cut when deserialized
115246
+ checkDocumentationLines(obj, file) {
115247
+ const maxLength = 72;
115248
+ const issues = [];
115249
+ const xml = obj.getXML();
115250
+ if (xml === undefined) {
115251
+ return issues;
115252
+ }
115253
+ const regex = /<TDLINE>([^<]*)<\/TDLINE>/g;
115254
+ let match;
115255
+ while ((match = regex.exec(xml)) !== null) {
115256
+ const text = (0, xml_utils_1.unescape)(match[1]);
115257
+ if (text.length > maxLength) {
115258
+ const row = xml.substring(0, match.index).split("\n").length;
115259
+ const message = `Documentation line exceeds maximum length of ${maxLength} characters (actual: ${text.length}), "${text}"`;
115260
+ issues.push(issue_1.Issue.atRow(file, row, message, this.getMetadata().key, this.conf.textAndTranslationLengthSeverity));
115261
+ }
115262
+ }
114240
115263
  return issues;
114241
115264
  }
114242
115265
  checkClearedFields(obj, file, structure, fields) {
@@ -114298,6 +115321,7 @@ class XMLConsistency {
114298
115321
  issues.push(issue_1.Issue.atRow(file, 1, "Interface matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
114299
115322
  }
114300
115323
  issues.push(...this.checkClearedFields(obj, file, "VSEOINTERF", XMLConsistency.clearedInterfaceFields));
115324
+ issues.push(...this.checkDocumentationLines(obj, file));
114301
115325
  return issues;
114302
115326
  }
114303
115327
  checkTextLength(file, fieldName, text, maxLength, lang) {