@abaplint/cli 2.120.74 → 2.120.75

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 +2578 -243
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -1875,6 +1875,9 @@ const Tokens = __importStar(__webpack_require__(/*! ../1_lexer/tokens */ "../cor
1875
1875
  const nodes_1 = __webpack_require__(/*! ../nodes */ "../core/build/src/abap/nodes/index.js");
1876
1876
  const version_1 = __webpack_require__(/*! ../../version */ "../core/build/src/version.js");
1877
1877
  const result_1 = __webpack_require__(/*! ./result */ "../core/build/src/abap/2_statements/result.js");
1878
+ // shared result for "nothing matched", frozen so accidental mutation throws instead of leaking between calls.
1879
+ // Returned arrays are never mutated by callers, which allows returning shared/input arrays as is
1880
+ const EMPTY = Object.freeze([]);
1878
1881
  class Regex {
1879
1882
  constructor(r) {
1880
1883
  this.regexp = r;
@@ -1886,17 +1889,23 @@ class Regex {
1886
1889
  return [];
1887
1890
  }
1888
1891
  run(r) {
1889
- const result = [];
1892
+ let result = undefined;
1890
1893
  for (const input of r) {
1891
1894
  if (input.remainingLength() === 0) {
1892
1895
  continue;
1893
1896
  }
1894
1897
  const token = input.peek();
1895
1898
  if (this.regexp.test(token.getStr()) === true) {
1896
- result.push(input.shift(new nodes_1.TokenNodeRegex(token)));
1899
+ const shifted = input.shift(new nodes_1.TokenNodeRegex(token));
1900
+ if (result === undefined) {
1901
+ result = [shifted];
1902
+ }
1903
+ else {
1904
+ result.push(shifted);
1905
+ }
1897
1906
  }
1898
1907
  }
1899
- return result;
1908
+ return result !== null && result !== void 0 ? result : EMPTY;
1900
1909
  }
1901
1910
  railroad() {
1902
1911
  return "Railroad.Terminal(\"" + this.regexp.source.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\")";
@@ -1919,15 +1928,20 @@ class Word {
1919
1928
  return [];
1920
1929
  }
1921
1930
  run(r) {
1922
- const result = [];
1931
+ let result = undefined;
1923
1932
  for (const input of r) {
1924
1933
  if (input.remainingLength() !== 0
1925
1934
  && input.peek().getUpperStr() === this.s) {
1926
- // console.log("match, " + this.s + result.length);
1927
- result.push(input.shift(new nodes_1.TokenNode(input.peek())));
1935
+ const shifted = input.shift(new nodes_1.TokenNode(input.peek()));
1936
+ if (result === undefined) {
1937
+ result = [shifted];
1938
+ }
1939
+ else {
1940
+ result.push(shifted);
1941
+ }
1928
1942
  }
1929
1943
  }
1930
- return result;
1944
+ return result !== null && result !== void 0 ? result : EMPTY;
1931
1945
  }
1932
1946
  railroad() {
1933
1947
  return "Railroad.Terminal('\"" + this.s + "\"')";
@@ -1951,14 +1965,20 @@ class Token {
1951
1965
  return [];
1952
1966
  }
1953
1967
  run(r) {
1954
- const result = [];
1968
+ let result = undefined;
1955
1969
  for (const input of r) {
1956
1970
  if (input.remainingLength() !== 0
1957
1971
  && input.peek().constructor === this.tokenType) {
1958
- result.push(input.shift(new nodes_1.TokenNode(input.peek())));
1972
+ const shifted = input.shift(new nodes_1.TokenNode(input.peek()));
1973
+ if (result === undefined) {
1974
+ result = [shifted];
1975
+ }
1976
+ else {
1977
+ result.push(shifted);
1978
+ }
1959
1979
  }
1960
1980
  }
1961
- return result;
1981
+ return result !== null && result !== void 0 ? result : EMPTY;
1962
1982
  }
1963
1983
  railroad() {
1964
1984
  let text = this.name;
@@ -1996,9 +2016,9 @@ class Vers {
1996
2016
  if (this.also === AlsoIn.OpenABAP) {
1997
2017
  return this.runnable.run(r);
1998
2018
  }
1999
- return (0, version_1.releaseAtLeast)(version_1.Release.v702, this.release) ? this.runnable.run(r) : [];
2019
+ return (0, version_1.releaseAtLeast)(version_1.Release.v702, this.release) ? this.runnable.run(r) : EMPTY;
2000
2020
  }
2001
- return (0, version_1.releaseAtLeast)(Combi.getRelease(), this.release) ? this.runnable.run(r) : [];
2021
+ return (0, version_1.releaseAtLeast)(Combi.getRelease(), this.release) ? this.runnable.run(r) : EMPTY;
2002
2022
  }
2003
2023
  getUsing() {
2004
2024
  return this.runnable.getUsing();
@@ -2046,7 +2066,7 @@ class LangVers {
2046
2066
  return this.runnable.run(r);
2047
2067
  }
2048
2068
  else {
2049
- return [];
2069
+ return EMPTY;
2050
2070
  }
2051
2071
  }
2052
2072
  railroad() {
@@ -2079,7 +2099,7 @@ class LangVersNot {
2079
2099
  return this.runnable.run(r);
2080
2100
  }
2081
2101
  else {
2082
- return [];
2102
+ return EMPTY;
2083
2103
  }
2084
2104
  }
2085
2105
  railroad() {
@@ -2107,6 +2127,22 @@ class OptionalPriority {
2107
2127
  return this.optional.getUsing();
2108
2128
  }
2109
2129
  run(r) {
2130
+ if (r.length === 1) {
2131
+ // single input, pass and return the input array without wrapping
2132
+ const res = this.optional.run(r);
2133
+ if (res.length > 1) {
2134
+ return res;
2135
+ }
2136
+ else if (res.length === 0) {
2137
+ return r;
2138
+ }
2139
+ else if (res[0].remainingLength() < r[0].remainingLength()) {
2140
+ return res;
2141
+ }
2142
+ else {
2143
+ return r;
2144
+ }
2145
+ }
2110
2146
  const result = [];
2111
2147
  for (const input of r) {
2112
2148
  const res = this.optional.run([input]);
@@ -2146,6 +2182,11 @@ class Optional {
2146
2182
  return this.optional.getUsing();
2147
2183
  }
2148
2184
  run(r) {
2185
+ if (r.length === 1) {
2186
+ // single input, pass and return the input array without wrapping
2187
+ const res = this.optional.run(r);
2188
+ return res.length === 0 ? r : r.concat(res);
2189
+ }
2149
2190
  const result = [];
2150
2191
  for (const input of r) {
2151
2192
  result.push(input);
@@ -2183,14 +2224,16 @@ class Star {
2183
2224
  let result = r;
2184
2225
  try {
2185
2226
  let res = r;
2186
- let input = [];
2187
2227
  for (;;) {
2188
- input = res;
2189
- res = this.sta.run(input);
2228
+ res = this.sta.run(res);
2190
2229
  if (res.length === 0) {
2191
2230
  break;
2192
2231
  }
2193
- if (res.length > 1000) {
2232
+ if (result === r) {
2233
+ // copy on first match, the input array must not be mutated
2234
+ result = r.concat(res);
2235
+ }
2236
+ else if (res.length > 1000) {
2194
2237
  // avoid stack overflow
2195
2238
  result = result.concat(res);
2196
2239
  }
@@ -2332,6 +2375,17 @@ class Sequence {
2332
2375
  return this.list.reduce((a, c) => { return a.concat(c.getUsing()); }, []);
2333
2376
  }
2334
2377
  run(r) {
2378
+ if (r.length === 1) {
2379
+ // single input, pass it down without wrapping and return the last result as is
2380
+ let temp = r;
2381
+ for (const sequence of this.list) {
2382
+ temp = sequence.run(temp);
2383
+ if (temp.length === 0) {
2384
+ return EMPTY;
2385
+ }
2386
+ }
2387
+ return temp;
2388
+ }
2335
2389
  let result = [];
2336
2390
  for (const input of r) {
2337
2391
  let temp = [input];
@@ -2409,12 +2463,33 @@ class Expression {
2409
2463
  this.runnable = undefined;
2410
2464
  }
2411
2465
  run(r) {
2412
- const results = [];
2413
2466
  if (this.runnable === undefined) {
2414
2467
  this.runnable = this.getRunnable();
2415
2468
  }
2469
+ if (r.length === 1) {
2470
+ // single input, pass it down without wrapping
2471
+ const input = r[0];
2472
+ const temp = this.runnable.run(r);
2473
+ if (temp.length === 0) {
2474
+ return EMPTY;
2475
+ }
2476
+ const results = new Array(temp.length);
2477
+ for (let i = 0; i < temp.length; i++) {
2478
+ const t = temp[i];
2479
+ const consumed = input.remainingLength() - t.remainingLength();
2480
+ results[i] = consumed > 0 ? t.wrapConsumed(consumed, new nodes_1.ExpressionNode(this)) : t;
2481
+ }
2482
+ return results;
2483
+ }
2484
+ let results = undefined;
2416
2485
  for (const input of r) {
2417
2486
  const temp = this.runnable.run([input]);
2487
+ if (temp.length === 0) {
2488
+ continue;
2489
+ }
2490
+ else if (results === undefined) {
2491
+ results = [];
2492
+ }
2418
2493
  for (const t of temp) {
2419
2494
  const consumed = input.remainingLength() - t.remainingLength();
2420
2495
  if (consumed > 0) {
@@ -2426,8 +2501,7 @@ class Expression {
2426
2501
  }
2427
2502
  }
2428
2503
  }
2429
- // console.dir(results);
2430
- return results;
2504
+ return results !== null && results !== void 0 ? results : EMPTY;
2431
2505
  }
2432
2506
  listKeywords() {
2433
2507
  // do not recurse, all Expressions are evaluated only on first level
@@ -2468,12 +2542,16 @@ class Permutation {
2468
2542
  return this.list.reduce((a, c) => { return a.concat(c.getUsing()); }, []);
2469
2543
  }
2470
2544
  run(r) {
2471
- const result = [];
2472
- const copy = this.list.slice();
2545
+ let result = undefined;
2546
+ let copy = undefined;
2473
2547
  for (let index = 0; index < this.list.length; index++) {
2474
2548
  const temp = this.list[index].run(r);
2475
2549
  if (temp.length !== 0) {
2476
2550
  // match
2551
+ if (result === undefined || copy === undefined) {
2552
+ result = [];
2553
+ copy = this.list.slice();
2554
+ }
2477
2555
  result.push(...temp);
2478
2556
  const left = copy;
2479
2557
  left.splice(index, 1);
@@ -2485,7 +2563,7 @@ class Permutation {
2485
2563
  }
2486
2564
  }
2487
2565
  }
2488
- return result;
2566
+ return result !== null && result !== void 0 ? result : EMPTY;
2489
2567
  }
2490
2568
  railroad() {
2491
2569
  const children = this.list.map((e) => { return e.railroad(); });
@@ -2562,17 +2640,31 @@ class Alternative {
2562
2640
  return this.list.reduce((a, c) => { return a.concat(c.getUsing()); }, []);
2563
2641
  }
2564
2642
  run(r) {
2565
- const result = [];
2643
+ var _a;
2644
+ // only allocate a new array when more than one alternative matches
2645
+ let single = undefined;
2646
+ let result = undefined;
2566
2647
  for (const sequ of this.list) {
2567
2648
  const temp = sequ.run(r);
2568
- if (temp.length === 1) {
2569
- result.push(temp[0]);
2649
+ if (temp.length === 0) {
2650
+ continue;
2651
+ }
2652
+ else if (result !== undefined) {
2653
+ if (temp.length === 1) {
2654
+ result.push(temp[0]);
2655
+ }
2656
+ else {
2657
+ result.push(...temp);
2658
+ }
2659
+ }
2660
+ else if (single !== undefined) {
2661
+ result = single.concat(temp);
2570
2662
  }
2571
2663
  else {
2572
- result.push(...temp);
2664
+ single = temp;
2573
2665
  }
2574
2666
  }
2575
- return result;
2667
+ return (_a = result !== null && result !== void 0 ? result : single) !== null && _a !== void 0 ? _a : EMPTY;
2576
2668
  }
2577
2669
  railroad() {
2578
2670
  const children = this.list.map((e) => { return e.railroad(); });
@@ -2623,21 +2715,13 @@ class AlternativePriority {
2623
2715
  return this.list.reduce((a, c) => { return a.concat(c.getUsing()); }, []);
2624
2716
  }
2625
2717
  run(r) {
2626
- const result = [];
2627
2718
  for (const sequ of this.list) {
2628
- // console.log(seq.toStr());
2629
2719
  const temp = sequ.run(r);
2630
2720
  if (temp.length > 0) {
2631
- if (temp.length === 1) {
2632
- result.push(temp[0]);
2633
- }
2634
- else {
2635
- result.push(...temp);
2636
- }
2637
- break;
2721
+ return temp;
2638
2722
  }
2639
2723
  }
2640
- return result;
2724
+ return EMPTY;
2641
2725
  }
2642
2726
  railroad() {
2643
2727
  const children = this.list.map((e) => { return e.railroad(); });
@@ -2843,18 +2927,21 @@ class StopBefore2 {
2843
2927
  getUsing() { return []; }
2844
2928
  run(r) {
2845
2929
  var _a;
2846
- const result = [];
2847
- for (const input of r) {
2930
+ // only copy when something is filtered out
2931
+ let result = undefined;
2932
+ for (let i = 0; i < r.length; i++) {
2933
+ const input = r[i];
2848
2934
  const next = input.peek();
2849
- if (next === undefined) {
2850
- continue;
2851
- }
2852
- if (next.getUpperStr() === this.t1 && ((_a = input.peekAt(1)) === null || _a === void 0 ? void 0 : _a.getUpperStr()) === this.t2) {
2935
+ if (next === undefined
2936
+ || (next.getUpperStr() === this.t1 && ((_a = input.peekAt(1)) === null || _a === void 0 ? void 0 : _a.getUpperStr()) === this.t2)) {
2937
+ if (result === undefined) {
2938
+ result = r.slice(0, i);
2939
+ }
2853
2940
  continue;
2854
2941
  }
2855
- result.push(input);
2942
+ result === null || result === void 0 ? void 0 : result.push(input);
2856
2943
  }
2857
- return result;
2944
+ return result !== null && result !== void 0 ? result : r;
2858
2945
  }
2859
2946
  railroad() { return "Railroad.Terminal('stopBefore(" + this.t1 + " " + this.t2 + ")')"; }
2860
2947
  toStr() { return "stopBefore(" + this.t1 + "," + this.t2 + ")"; }
@@ -2869,15 +2956,20 @@ class StopBefore1 {
2869
2956
  getUsing() { return []; }
2870
2957
  run(r) {
2871
2958
  var _a;
2872
- const result = [];
2873
- for (const input of r) {
2959
+ // only copy when something is filtered out
2960
+ let result = undefined;
2961
+ for (let i = 0; i < r.length; i++) {
2962
+ const input = r[i];
2874
2963
  const next = (_a = input.peek()) === null || _a === void 0 ? void 0 : _a.getUpperStr();
2875
2964
  if (next !== undefined && this.words.includes(next)) {
2965
+ if (result === undefined) {
2966
+ result = r.slice(0, i);
2967
+ }
2876
2968
  continue;
2877
2969
  }
2878
- result.push(input);
2970
+ result === null || result === void 0 ? void 0 : result.push(input);
2879
2971
  }
2880
- return result;
2972
+ return result !== null && result !== void 0 ? result : r;
2881
2973
  }
2882
2974
  railroad() { return "Railroad.Terminal('stopBefore(" + this.words.join("|") + ")')"; }
2883
2975
  toStr() { return "stopBefore(" + this.words.join(",") + ")"; }
@@ -37749,6 +37841,12 @@ class Append {
37749
37841
  if (target) {
37750
37842
  targetType = target_1.Target.runSyntax(target, input);
37751
37843
  }
37844
+ // a hashed table has no index, APPEND adds at the end
37845
+ if (targetType instanceof basic_1.TableType && targetType.getAccessType() === basic_1.TableAccessType.hashed) {
37846
+ const message = "Implicit or explicit index operation on hashed table is not possible";
37847
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
37848
+ return;
37849
+ }
37752
37850
  const fsTarget = node.findExpressionAfterToken("ASSIGNING");
37753
37851
  if (fsTarget && fsTarget.get() instanceof Expressions.FSTarget) {
37754
37852
  if (!(targetType instanceof basic_1.TableType) && !(targetType instanceof basic_1.VoidType) && !(targetType instanceof basic_1.UnknownType)) {
@@ -57248,7 +57346,7 @@ class DDIC {
57248
57346
  lookupDomain(name, dataElement, description) {
57249
57347
  const found = this.reg.getObject("DOMA", name);
57250
57348
  if (found) {
57251
- return { type: found.parseType(this.reg, dataElement, description), object: found };
57349
+ return { type: found.parseDomainType(this.reg, dataElement, description), object: found };
57252
57350
  }
57253
57351
  else if (this.reg.inErrorNamespace(name)) {
57254
57352
  return { type: new Types.UnknownType(name + ", lookupDomain"), object: undefined };
@@ -64220,7 +64318,10 @@ class Domain extends _abstract_object_1.AbstractObject {
64220
64318
  this.parsedXML = undefined;
64221
64319
  super.setDirty();
64222
64320
  }
64223
- parseType(reg, dataElement, description) {
64321
+ parseType(reg) {
64322
+ return this.parseDomainType(reg);
64323
+ }
64324
+ parseDomainType(reg, dataElement, description) {
64224
64325
  // dont cache the DOMA parsed type, they are cached on DTEL level
64225
64326
  // also note that the type carries the name of the DTEL
64226
64327
  if (this.parsedXML === undefined) {
@@ -70841,7 +70942,7 @@ class Registry {
70841
70942
  }
70842
70943
  static abaplintVersion() {
70843
70944
  // magic, see build script "version.js"
70844
- return "2.120.74";
70945
+ return "2.120.75";
70845
70946
  }
70846
70947
  getDDICReferences() {
70847
70948
  return this.ddicReferences;
@@ -71503,10 +71604,10 @@ exports.Abapdoc = Abapdoc;
71503
71604
 
71504
71605
  /***/ },
71505
71606
 
71506
- /***/ "../core/build/src/rules/add_test_attributes.js"
71507
- /*!******************************************************!*\
71508
- !*** ../core/build/src/rules/add_test_attributes.js ***!
71509
- \******************************************************/
71607
+ /***/ "../core/build/src/rules/abapdoc_html_tag.js"
71608
+ /*!***************************************************!*\
71609
+ !*** ../core/build/src/rules/abapdoc_html_tag.js ***!
71610
+ \***************************************************/
71510
71611
  (__unused_webpack_module, exports, __webpack_require__) {
71511
71612
 
71512
71613
  "use strict";
@@ -71545,49 +71646,45 @@ var __importStar = (this && this.__importStar) || (function () {
71545
71646
  };
71546
71647
  })();
71547
71648
  Object.defineProperty(exports, "__esModule", ({ value: true }));
71548
- exports.AddTestAttributes = exports.AddTestAttributesConf = void 0;
71649
+ exports.AbapdocHtmlTag = exports.AbapdocHtmlTagConf = void 0;
71650
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
71549
71651
  const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
71550
71652
  const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
71551
71653
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
71552
- const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
71553
- const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
71554
71654
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
71555
- class AddTestAttributesConf extends _basic_rule_config_1.BasicRuleConfig {
71655
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
71656
+ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
71657
+ class AbapdocHtmlTagConf extends _basic_rule_config_1.BasicRuleConfig {
71556
71658
  }
71557
- exports.AddTestAttributesConf = AddTestAttributesConf;
71558
- class AddTestAttributes extends _abap_rule_1.ABAPRule {
71659
+ exports.AbapdocHtmlTagConf = AbapdocHtmlTagConf;
71660
+ const ALLOWED = new Set(["p", "em", "strong", "ul", "ol", "li", "br", "h1", "h2", "h3"]);
71661
+ class AbapdocHtmlTag extends _abap_rule_1.ABAPRule {
71559
71662
  constructor() {
71560
71663
  super(...arguments);
71561
- this.conf = new AddTestAttributesConf();
71664
+ this.conf = new AbapdocHtmlTagConf();
71562
71665
  }
71563
71666
  getMetadata() {
71564
71667
  return {
71565
- key: "add_test_attributes",
71566
- title: "Add test attributes for tests classes with test methods",
71567
- shortDescription: `Add test attributes DURATION and RISK LEVEL for tests classes with test methods`,
71568
- tags: [_irule_1.RuleTag.SingleFile],
71569
- badExample: `CLASS ltcl_test1 DEFINITION FINAL FOR TESTING.
71570
- PUBLIC SECTION.
71571
- PROTECTED SECTION.
71572
- PRIVATE SECTION.
71573
- METHODS test FOR TESTING RAISING cx_static_check.
71574
- ENDCLASS.
71668
+ key: "abapdoc_html_tag",
71669
+ title: "Unsupported HTML tag in ABAP Doc",
71670
+ shortDescription: `Reports tag-like tokens in ABAP Doc which are not ABAP Doc HTML tags.`,
71671
+ extendedInformation: `ABAP Doc is parsed as HTML, a field symbol or a placeholder written as <name> is an
71672
+ unsupported and unclosed tag, the system warns and the rendered documentation drops the word.
71575
71673
 
71576
- CLASS ltcl_test1 IMPLEMENTATION.
71577
- METHOD test.
71578
- ENDMETHOD.
71579
- ENDCLASS.`,
71580
- goodExample: `CLASS ltcl_test2 DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
71581
- PUBLIC SECTION.
71582
- PROTECTED SECTION.
71583
- PRIVATE SECTION.
71584
- METHODS test FOR TESTING RAISING cx_static_check.
71585
- ENDCLASS.
71674
+ Supported tags are p, em, strong, ul, ol, li, br, h1, h2 and h3, also as closing tags and with attributes.
71586
71675
 
71587
- CLASS ltcl_test2 IMPLEMENTATION.
71588
- METHOD test.
71589
- ENDMETHOD.
71590
- ENDCLASS.`,
71676
+ Write &lt;name&gt; to show the angle brackets. A "<" which is not followed by a letter, like "a < b", is not reported.
71677
+
71678
+ Only checks ABAP Doc inside class definitions and interfaces.`,
71679
+ tags: [_irule_1.RuleTag.SingleFile],
71680
+ badExample: `INTERFACE zif_foo PUBLIC.
71681
+ "! Returns the <name> of the selected row
71682
+ METHODS name RETURNING VALUE(result) TYPE string.
71683
+ ENDINTERFACE.`,
71684
+ goodExample: `INTERFACE zif_foo PUBLIC.
71685
+ "! Returns the &lt;name&gt; of the selected row
71686
+ METHODS name RETURNING VALUE(result) TYPE string.
71687
+ ENDINTERFACE.`,
71591
71688
  };
71592
71689
  }
71593
71690
  getConfig() {
@@ -71598,76 +71695,130 @@ ENDCLASS.`,
71598
71695
  }
71599
71696
  runParsed(file) {
71600
71697
  const issues = [];
71601
- const stru = file.getStructure();
71602
- if (stru === undefined) {
71603
- return [];
71604
- }
71605
- for (const classStructure of stru.findAllStructures(Structures.ClassDefinition)) {
71606
- const cdef = classStructure.findFirstStatement(Statements.ClassDefinition);
71607
- if (cdef === undefined) {
71698
+ let definition = false;
71699
+ for (const statement of file.getStatements()) {
71700
+ const type = statement.get();
71701
+ if (type instanceof Statements.ClassDefinition || type instanceof Statements.Interface) {
71702
+ definition = true;
71608
71703
  continue;
71609
71704
  }
71610
- const cdefConcat = cdef === null || cdef === void 0 ? void 0 : cdef.concatTokens().toUpperCase();
71611
- if ((cdefConcat === null || cdefConcat === void 0 ? void 0 : cdefConcat.includes(" FOR TESTING")) === false) {
71705
+ else if (type instanceof Statements.EndClass || type instanceof Statements.EndInterface) {
71706
+ definition = false;
71612
71707
  continue;
71613
71708
  }
71614
- const hasDuration = cdefConcat === null || cdefConcat === void 0 ? void 0 : cdefConcat.includes(" DURATION ");
71615
- const hasRiskLevel = cdefConcat === null || cdefConcat === void 0 ? void 0 : cdefConcat.includes(" RISK LEVEL ");
71616
- if (hasDuration === true && hasRiskLevel === true) {
71709
+ else if (definition === false || !(type instanceof _statement_1.Comment)) {
71617
71710
  continue;
71618
71711
  }
71619
- let hasTestMethod = false;
71620
- for (const mdef of classStructure.findAllStatements(Statements.MethodDef)) {
71621
- const concat = mdef.concatTokens().toUpperCase();
71622
- if (concat.includes(" FOR TESTING")) {
71623
- hasTestMethod = true;
71624
- }
71625
- }
71626
- if (hasTestMethod === false) {
71712
+ const token = statement.getFirstToken();
71713
+ const str = token.getStr();
71714
+ if (str.startsWith(`"!`) === false) {
71627
71715
  continue;
71628
71716
  }
71629
- if (hasDuration === false) {
71630
- issues.push(issue_1.Issue.atStatement(file, cdef, "Add DURATION", this.getMetadata().key, this.getConfig().severity));
71631
- }
71632
- if (hasRiskLevel === false) {
71633
- issues.push(issue_1.Issue.atStatement(file, cdef, "Add RISK LEVEL", this.getMetadata().key, this.getConfig().severity));
71717
+ const regex = /<\/?([a-zA-Z][\w-]*)(\s[^<>]*)?\/?>/g;
71718
+ let match;
71719
+ while ((match = regex.exec(str)) !== null) {
71720
+ const name = match[1];
71721
+ if (ALLOWED.has(name.toLowerCase())) {
71722
+ continue;
71723
+ }
71724
+ const row = token.getStart().getRow();
71725
+ const col = token.getStart().getCol() + match.index;
71726
+ const start = new position_1.Position(row, col);
71727
+ const end = new position_1.Position(row, col + match[0].length);
71728
+ const message = `HTML tag <${name}> is not supported in ABAP Doc, write &lt;${name}&gt;`;
71729
+ issues.push(issue_1.Issue.atRange(file, start, end, message, this.getMetadata().key, this.conf.severity));
71634
71730
  }
71635
71731
  }
71636
71732
  return issues;
71637
71733
  }
71638
71734
  }
71639
- exports.AddTestAttributes = AddTestAttributes;
71640
- //# sourceMappingURL=add_test_attributes.js.map
71735
+ exports.AbapdocHtmlTag = AbapdocHtmlTag;
71736
+ //# sourceMappingURL=abapdoc_html_tag.js.map
71641
71737
 
71642
71738
  /***/ },
71643
71739
 
71644
- /***/ "../core/build/src/rules/aff_and_xml.js"
71645
- /*!**********************************************!*\
71646
- !*** ../core/build/src/rules/aff_and_xml.js ***!
71647
- \**********************************************/
71740
+ /***/ "../core/build/src/rules/abapdoc_leading_at.js"
71741
+ /*!*****************************************************!*\
71742
+ !*** ../core/build/src/rules/abapdoc_leading_at.js ***!
71743
+ \*****************************************************/
71648
71744
  (__unused_webpack_module, exports, __webpack_require__) {
71649
71745
 
71650
71746
  "use strict";
71651
71747
 
71748
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
71749
+ if (k2 === undefined) k2 = k;
71750
+ var desc = Object.getOwnPropertyDescriptor(m, k);
71751
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
71752
+ desc = { enumerable: true, get: function() { return m[k]; } };
71753
+ }
71754
+ Object.defineProperty(o, k2, desc);
71755
+ }) : (function(o, m, k, k2) {
71756
+ if (k2 === undefined) k2 = k;
71757
+ o[k2] = m[k];
71758
+ }));
71759
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
71760
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
71761
+ }) : function(o, v) {
71762
+ o["default"] = v;
71763
+ });
71764
+ var __importStar = (this && this.__importStar) || (function () {
71765
+ var ownKeys = function(o) {
71766
+ ownKeys = Object.getOwnPropertyNames || function (o) {
71767
+ var ar = [];
71768
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
71769
+ return ar;
71770
+ };
71771
+ return ownKeys(o);
71772
+ };
71773
+ return function (mod) {
71774
+ if (mod && mod.__esModule) return mod;
71775
+ var result = {};
71776
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
71777
+ __setModuleDefault(result, mod);
71778
+ return result;
71779
+ };
71780
+ })();
71652
71781
  Object.defineProperty(exports, "__esModule", ({ value: true }));
71653
- exports.AFFAndXML = exports.AFFAndXMLConf = void 0;
71782
+ exports.AbapdocLeadingAt = exports.AbapdocLeadingAtConf = void 0;
71783
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
71654
71784
  const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
71655
- const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
71785
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
71656
71786
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
71657
- class AFFAndXMLConf extends _basic_rule_config_1.BasicRuleConfig {
71787
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
71788
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
71789
+ class AbapdocLeadingAtConf extends _basic_rule_config_1.BasicRuleConfig {
71658
71790
  }
71659
- exports.AFFAndXMLConf = AFFAndXMLConf;
71660
- class AFFAndXML {
71791
+ exports.AbapdocLeadingAtConf = AbapdocLeadingAtConf;
71792
+ class AbapdocLeadingAt extends _abap_rule_1.ABAPRule {
71661
71793
  constructor() {
71662
- this.conf = new AFFAndXMLConf();
71794
+ super(...arguments);
71795
+ this.conf = new AbapdocLeadingAtConf();
71663
71796
  }
71664
71797
  getMetadata() {
71665
71798
  return {
71666
- key: "aff_and_xml",
71667
- title: "AFF and XML",
71668
- shortDescription: `Checks for objects that have both AFF (.json) and XML (.xml) files`,
71669
- extendedInformation: `If an object has both an ABAP file format JSON file and an XML file, the XML file should be removed`,
71670
- tags: [_irule_1.RuleTag.Syntax],
71799
+ key: "abapdoc_leading_at",
71800
+ title: "ABAP Doc line starting with @",
71801
+ shortDescription: `Reports ABAP Doc lines starting with "@" which is not followed by a command.`,
71802
+ extendedInformation: `In ABAP Doc, "@" at the start of a line introduces a command, the commands are
71803
+ @parameter, @raising and @exception. Any other text after a leading "@", like a CDS annotation,
71804
+ gives the syntax warning 'A command was expected after ABAP Doc symbol "@"'.
71805
+
71806
+ An "@" in the middle of a line is plain text and not reported.
71807
+
71808
+ Only checks ABAP Doc inside class definitions and interfaces.`,
71809
+ tags: [_irule_1.RuleTag.SingleFile],
71810
+ badExample: `CLASS zcl_foo DEFINITION PUBLIC.
71811
+ PUBLIC SECTION.
71812
+ "! the first of
71813
+ "! @UI.presentationVariant sortOrder
71814
+ DATA mv_sort_field TYPE string.
71815
+ ENDCLASS.`,
71816
+ goodExample: `CLASS zcl_foo DEFINITION PUBLIC.
71817
+ PUBLIC SECTION.
71818
+ "! the first of @UI.presentationVariant
71819
+ "! sortOrder
71820
+ DATA mv_sort_field TYPE string.
71821
+ ENDCLASS.`,
71671
71822
  };
71672
71823
  }
71673
71824
  getConfig() {
@@ -71676,42 +71827,411 @@ class AFFAndXML {
71676
71827
  setConfig(conf) {
71677
71828
  this.conf = conf;
71678
71829
  }
71679
- initialize(_reg) {
71680
- return this;
71681
- }
71682
- run(obj) {
71683
- const files = obj.getFiles();
71684
- let hasJSON = false;
71685
- let hasXML = false;
71686
- const type = obj.getType().toLowerCase();
71687
- for (const file of files) {
71688
- const filename = file.getFilename().toLowerCase();
71689
- if (filename.endsWith("." + type + ".json")) {
71690
- hasJSON = true;
71830
+ runParsed(file) {
71831
+ const issues = [];
71832
+ let definition = false;
71833
+ for (const statement of file.getStatements()) {
71834
+ const type = statement.get();
71835
+ if (type instanceof Statements.ClassDefinition || type instanceof Statements.Interface) {
71836
+ definition = true;
71837
+ continue;
71691
71838
  }
71692
- else if (filename.endsWith("." + type + ".xml")) {
71693
- hasXML = true;
71839
+ else if (type instanceof Statements.EndClass || type instanceof Statements.EndInterface) {
71840
+ definition = false;
71841
+ continue;
71694
71842
  }
71695
- }
71696
- if (hasJSON && hasXML) {
71697
- const xmlFile = obj.getXMLFile();
71698
- if (xmlFile) {
71699
- const message = "Object has both AFF JSON and XML files, remove the XML";
71700
- return [issue_1.Issue.atRow(xmlFile, 1, message, this.getMetadata().key, this.conf.severity)];
71843
+ else if (definition === false || !(type instanceof _statement_1.Comment)) {
71844
+ continue;
71845
+ }
71846
+ const token = statement.getFirstToken();
71847
+ const str = token.getStr();
71848
+ if (str.startsWith(`"!`) === false) {
71849
+ continue;
71701
71850
  }
71851
+ const text = str.substring(2).trimStart();
71852
+ if (text.startsWith("@") === false
71853
+ || text.match(/^@(parameter|raising|exception)(\s|$)/i) !== null) {
71854
+ continue;
71855
+ }
71856
+ const message = `A command was expected after ABAP Doc symbol "@", move the "@" away from the start of the line`;
71857
+ issues.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
71702
71858
  }
71703
- return [];
71859
+ return issues;
71704
71860
  }
71705
71861
  }
71706
- exports.AFFAndXML = AFFAndXML;
71707
- //# sourceMappingURL=aff_and_xml.js.map
71862
+ exports.AbapdocLeadingAt = AbapdocLeadingAt;
71863
+ //# sourceMappingURL=abapdoc_leading_at.js.map
71708
71864
 
71709
71865
  /***/ },
71710
71866
 
71711
- /***/ "../core/build/src/rules/align_parameters.js"
71712
- /*!***************************************************!*\
71713
- !*** ../core/build/src/rules/align_parameters.js ***!
71714
- \***************************************************/
71867
+ /***/ "../core/build/src/rules/abapdoc_parameter_names.js"
71868
+ /*!**********************************************************!*\
71869
+ !*** ../core/build/src/rules/abapdoc_parameter_names.js ***!
71870
+ \**********************************************************/
71871
+ (__unused_webpack_module, exports, __webpack_require__) {
71872
+
71873
+ "use strict";
71874
+
71875
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
71876
+ if (k2 === undefined) k2 = k;
71877
+ var desc = Object.getOwnPropertyDescriptor(m, k);
71878
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
71879
+ desc = { enumerable: true, get: function() { return m[k]; } };
71880
+ }
71881
+ Object.defineProperty(o, k2, desc);
71882
+ }) : (function(o, m, k, k2) {
71883
+ if (k2 === undefined) k2 = k;
71884
+ o[k2] = m[k];
71885
+ }));
71886
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
71887
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
71888
+ }) : function(o, v) {
71889
+ o["default"] = v;
71890
+ });
71891
+ var __importStar = (this && this.__importStar) || (function () {
71892
+ var ownKeys = function(o) {
71893
+ ownKeys = Object.getOwnPropertyNames || function (o) {
71894
+ var ar = [];
71895
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
71896
+ return ar;
71897
+ };
71898
+ return ownKeys(o);
71899
+ };
71900
+ return function (mod) {
71901
+ if (mod && mod.__esModule) return mod;
71902
+ var result = {};
71903
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
71904
+ __setModuleDefault(result, mod);
71905
+ return result;
71906
+ };
71907
+ })();
71908
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
71909
+ exports.AbapdocParameterNames = exports.AbapdocParameterNamesConf = void 0;
71910
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
71911
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
71912
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
71913
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
71914
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
71915
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
71916
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
71917
+ class AbapdocParameterNamesConf extends _basic_rule_config_1.BasicRuleConfig {
71918
+ }
71919
+ exports.AbapdocParameterNamesConf = AbapdocParameterNamesConf;
71920
+ class AbapdocParameterNames extends _abap_rule_1.ABAPRule {
71921
+ constructor() {
71922
+ super(...arguments);
71923
+ this.conf = new AbapdocParameterNamesConf();
71924
+ }
71925
+ getMetadata() {
71926
+ return {
71927
+ key: "abapdoc_parameter_names",
71928
+ title: "ABAP Doc parameter names",
71929
+ shortDescription: `Checks that the parameters documented in ABAP Doc exist in the method definition.`,
71930
+ extendedInformation: `Reports "! @parameter lines in the ABAP Doc block in front of a METHODS or CLASS-METHODS
71931
+ definition when the parameter is not a parameter of the method, typically after a parameter was renamed or removed.
71932
+ Also reports a parameter documented twice.
71933
+
71934
+ Missing @parameter lines are not reported, documenting parameters is optional. @raising and @exception lines are not checked.
71935
+
71936
+ Only the block directly in front of the method is checked, a blank line or a plain comment ends the block,
71937
+ see rule wrong_abapdoc_position for misplaced ABAP Doc.`,
71938
+ tags: [_irule_1.RuleTag.SingleFile],
71939
+ badExample: `CLASS zcl_foo DEFINITION PUBLIC.
71940
+ PUBLIC SECTION.
71941
+ "! @parameter iv_bar | Bar
71942
+ METHODS foo IMPORTING iv_foo TYPE i.
71943
+ ENDCLASS.`,
71944
+ goodExample: `CLASS zcl_foo DEFINITION PUBLIC.
71945
+ PUBLIC SECTION.
71946
+ "! @parameter iv_foo | Foo
71947
+ METHODS foo IMPORTING iv_foo TYPE i.
71948
+ ENDCLASS.`,
71949
+ };
71950
+ }
71951
+ getConfig() {
71952
+ return this.conf;
71953
+ }
71954
+ setConfig(conf) {
71955
+ this.conf = conf;
71956
+ }
71957
+ runParsed(file) {
71958
+ var _a;
71959
+ const issues = [];
71960
+ const statements = file.getStatements();
71961
+ for (let i = 0; i < statements.length; i++) {
71962
+ const def = statements[i];
71963
+ if (!(def.get() instanceof Statements.MethodDef)) {
71964
+ continue;
71965
+ }
71966
+ const name = def.findDirectExpression(Expressions.MethodName);
71967
+ if (name === undefined) {
71968
+ continue;
71969
+ }
71970
+ const abapdoc = [];
71971
+ let nextRow = undefined;
71972
+ for (let j = i - 1; j >= 0 && statements[j].get() instanceof _statement_1.Comment; j--) {
71973
+ const comment = statements[j];
71974
+ const start = comment.getStart();
71975
+ if (start.isAfter(name.getFirstToken().getStart())) {
71976
+ continue; // comment inside the statement, after the method name
71977
+ }
71978
+ nextRow = nextRow !== null && nextRow !== void 0 ? nextRow : (_a = def.getTokens().find(t => t.getStart().isAfter(start))) === null || _a === void 0 ? void 0 : _a.getStart().getRow();
71979
+ if (this.isAbapdoc(comment, def) === false || start.getRow() + 1 !== nextRow) {
71980
+ break; // a blank line or a plain comment ends the block
71981
+ }
71982
+ abapdoc.unshift(comment);
71983
+ nextRow = start.getRow();
71984
+ }
71985
+ if (abapdoc.length === 0) {
71986
+ continue;
71987
+ }
71988
+ const parameters = def.findAllExpressions(Expressions.MethodParamName)
71989
+ .map(p => p.getFirstToken().getStr().replace(/^!/, "").toUpperCase());
71990
+ const documented = new Set();
71991
+ for (const comment of abapdoc) {
71992
+ const match = comment.getFirstToken().getStr().match(/^"!\s*@parameter\s+!?([^\s|]+)/i);
71993
+ if (match === null) {
71994
+ continue;
71995
+ }
71996
+ const parameter = match[1].toUpperCase();
71997
+ let message = undefined;
71998
+ if (parameters.includes(parameter) === false) {
71999
+ message = `ABAP Doc parameter "${match[1]}" is not a parameter of method ${name.concatTokens()}`;
72000
+ }
72001
+ else if (documented.has(parameter) === true) {
72002
+ message = `ABAP Doc parameter "${match[1]}" documented more than once`;
72003
+ }
72004
+ documented.add(parameter);
72005
+ if (message !== undefined) {
72006
+ issues.push(issue_1.Issue.atStatement(file, comment, message, this.getMetadata().key, this.conf.severity));
72007
+ }
72008
+ }
72009
+ }
72010
+ return issues;
72011
+ }
72012
+ /** ABAP Doc in front of the method name, after the colon of a chain */
72013
+ isAbapdoc(comment, def) {
72014
+ if (comment.getFirstToken().getStr().startsWith(`"!`) === false) {
72015
+ return false;
72016
+ }
72017
+ const colon = def.getColon();
72018
+ return colon === undefined || comment.getStart().isAfter(colon.getStart());
72019
+ }
72020
+ }
72021
+ exports.AbapdocParameterNames = AbapdocParameterNames;
72022
+ //# sourceMappingURL=abapdoc_parameter_names.js.map
72023
+
72024
+ /***/ },
72025
+
72026
+ /***/ "../core/build/src/rules/add_test_attributes.js"
72027
+ /*!******************************************************!*\
72028
+ !*** ../core/build/src/rules/add_test_attributes.js ***!
72029
+ \******************************************************/
72030
+ (__unused_webpack_module, exports, __webpack_require__) {
72031
+
72032
+ "use strict";
72033
+
72034
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
72035
+ if (k2 === undefined) k2 = k;
72036
+ var desc = Object.getOwnPropertyDescriptor(m, k);
72037
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
72038
+ desc = { enumerable: true, get: function() { return m[k]; } };
72039
+ }
72040
+ Object.defineProperty(o, k2, desc);
72041
+ }) : (function(o, m, k, k2) {
72042
+ if (k2 === undefined) k2 = k;
72043
+ o[k2] = m[k];
72044
+ }));
72045
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
72046
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
72047
+ }) : function(o, v) {
72048
+ o["default"] = v;
72049
+ });
72050
+ var __importStar = (this && this.__importStar) || (function () {
72051
+ var ownKeys = function(o) {
72052
+ ownKeys = Object.getOwnPropertyNames || function (o) {
72053
+ var ar = [];
72054
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
72055
+ return ar;
72056
+ };
72057
+ return ownKeys(o);
72058
+ };
72059
+ return function (mod) {
72060
+ if (mod && mod.__esModule) return mod;
72061
+ var result = {};
72062
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
72063
+ __setModuleDefault(result, mod);
72064
+ return result;
72065
+ };
72066
+ })();
72067
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
72068
+ exports.AddTestAttributes = exports.AddTestAttributesConf = void 0;
72069
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
72070
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
72071
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
72072
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
72073
+ const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
72074
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
72075
+ class AddTestAttributesConf extends _basic_rule_config_1.BasicRuleConfig {
72076
+ }
72077
+ exports.AddTestAttributesConf = AddTestAttributesConf;
72078
+ class AddTestAttributes extends _abap_rule_1.ABAPRule {
72079
+ constructor() {
72080
+ super(...arguments);
72081
+ this.conf = new AddTestAttributesConf();
72082
+ }
72083
+ getMetadata() {
72084
+ return {
72085
+ key: "add_test_attributes",
72086
+ title: "Add test attributes for tests classes with test methods",
72087
+ shortDescription: `Add test attributes DURATION and RISK LEVEL for tests classes with test methods`,
72088
+ tags: [_irule_1.RuleTag.SingleFile],
72089
+ badExample: `CLASS ltcl_test1 DEFINITION FINAL FOR TESTING.
72090
+ PUBLIC SECTION.
72091
+ PROTECTED SECTION.
72092
+ PRIVATE SECTION.
72093
+ METHODS test FOR TESTING RAISING cx_static_check.
72094
+ ENDCLASS.
72095
+
72096
+ CLASS ltcl_test1 IMPLEMENTATION.
72097
+ METHOD test.
72098
+ ENDMETHOD.
72099
+ ENDCLASS.`,
72100
+ goodExample: `CLASS ltcl_test2 DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
72101
+ PUBLIC SECTION.
72102
+ PROTECTED SECTION.
72103
+ PRIVATE SECTION.
72104
+ METHODS test FOR TESTING RAISING cx_static_check.
72105
+ ENDCLASS.
72106
+
72107
+ CLASS ltcl_test2 IMPLEMENTATION.
72108
+ METHOD test.
72109
+ ENDMETHOD.
72110
+ ENDCLASS.`,
72111
+ };
72112
+ }
72113
+ getConfig() {
72114
+ return this.conf;
72115
+ }
72116
+ setConfig(conf) {
72117
+ this.conf = conf;
72118
+ }
72119
+ runParsed(file) {
72120
+ const issues = [];
72121
+ const stru = file.getStructure();
72122
+ if (stru === undefined) {
72123
+ return [];
72124
+ }
72125
+ for (const classStructure of stru.findAllStructures(Structures.ClassDefinition)) {
72126
+ const cdef = classStructure.findFirstStatement(Statements.ClassDefinition);
72127
+ if (cdef === undefined) {
72128
+ continue;
72129
+ }
72130
+ const cdefConcat = cdef === null || cdef === void 0 ? void 0 : cdef.concatTokens().toUpperCase();
72131
+ if ((cdefConcat === null || cdefConcat === void 0 ? void 0 : cdefConcat.includes(" FOR TESTING")) === false) {
72132
+ continue;
72133
+ }
72134
+ const hasDuration = cdefConcat === null || cdefConcat === void 0 ? void 0 : cdefConcat.includes(" DURATION ");
72135
+ const hasRiskLevel = cdefConcat === null || cdefConcat === void 0 ? void 0 : cdefConcat.includes(" RISK LEVEL ");
72136
+ if (hasDuration === true && hasRiskLevel === true) {
72137
+ continue;
72138
+ }
72139
+ let hasTestMethod = false;
72140
+ for (const mdef of classStructure.findAllStatements(Statements.MethodDef)) {
72141
+ const concat = mdef.concatTokens().toUpperCase();
72142
+ if (concat.includes(" FOR TESTING")) {
72143
+ hasTestMethod = true;
72144
+ }
72145
+ }
72146
+ if (hasTestMethod === false) {
72147
+ continue;
72148
+ }
72149
+ if (hasDuration === false) {
72150
+ issues.push(issue_1.Issue.atStatement(file, cdef, "Add DURATION", this.getMetadata().key, this.getConfig().severity));
72151
+ }
72152
+ if (hasRiskLevel === false) {
72153
+ issues.push(issue_1.Issue.atStatement(file, cdef, "Add RISK LEVEL", this.getMetadata().key, this.getConfig().severity));
72154
+ }
72155
+ }
72156
+ return issues;
72157
+ }
72158
+ }
72159
+ exports.AddTestAttributes = AddTestAttributes;
72160
+ //# sourceMappingURL=add_test_attributes.js.map
72161
+
72162
+ /***/ },
72163
+
72164
+ /***/ "../core/build/src/rules/aff_and_xml.js"
72165
+ /*!**********************************************!*\
72166
+ !*** ../core/build/src/rules/aff_and_xml.js ***!
72167
+ \**********************************************/
72168
+ (__unused_webpack_module, exports, __webpack_require__) {
72169
+
72170
+ "use strict";
72171
+
72172
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
72173
+ exports.AFFAndXML = exports.AFFAndXMLConf = void 0;
72174
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
72175
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
72176
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
72177
+ class AFFAndXMLConf extends _basic_rule_config_1.BasicRuleConfig {
72178
+ }
72179
+ exports.AFFAndXMLConf = AFFAndXMLConf;
72180
+ class AFFAndXML {
72181
+ constructor() {
72182
+ this.conf = new AFFAndXMLConf();
72183
+ }
72184
+ getMetadata() {
72185
+ return {
72186
+ key: "aff_and_xml",
72187
+ title: "AFF and XML",
72188
+ shortDescription: `Checks for objects that have both AFF (.json) and XML (.xml) files`,
72189
+ extendedInformation: `If an object has both an ABAP file format JSON file and an XML file, the XML file should be removed`,
72190
+ tags: [_irule_1.RuleTag.Syntax],
72191
+ };
72192
+ }
72193
+ getConfig() {
72194
+ return this.conf;
72195
+ }
72196
+ setConfig(conf) {
72197
+ this.conf = conf;
72198
+ }
72199
+ initialize(_reg) {
72200
+ return this;
72201
+ }
72202
+ run(obj) {
72203
+ const files = obj.getFiles();
72204
+ let hasJSON = false;
72205
+ let hasXML = false;
72206
+ const type = obj.getType().toLowerCase();
72207
+ for (const file of files) {
72208
+ const filename = file.getFilename().toLowerCase();
72209
+ if (filename.endsWith("." + type + ".json")) {
72210
+ hasJSON = true;
72211
+ }
72212
+ else if (filename.endsWith("." + type + ".xml")) {
72213
+ hasXML = true;
72214
+ }
72215
+ }
72216
+ if (hasJSON && hasXML) {
72217
+ const xmlFile = obj.getXMLFile();
72218
+ if (xmlFile) {
72219
+ const message = "Object has both AFF JSON and XML files, remove the XML";
72220
+ return [issue_1.Issue.atRow(xmlFile, 1, message, this.getMetadata().key, this.conf.severity)];
72221
+ }
72222
+ }
72223
+ return [];
72224
+ }
72225
+ }
72226
+ exports.AFFAndXML = AFFAndXML;
72227
+ //# sourceMappingURL=aff_and_xml.js.map
72228
+
72229
+ /***/ },
72230
+
72231
+ /***/ "../core/build/src/rules/align_parameters.js"
72232
+ /*!***************************************************!*\
72233
+ !*** ../core/build/src/rules/align_parameters.js ***!
72234
+ \***************************************************/
71715
72235
  (__unused_webpack_module, exports, __webpack_require__) {
71716
72236
 
71717
72237
  "use strict";
@@ -73803,10 +74323,10 @@ Missing objects are only reported when their names match the configured errorNam
73803
74323
  let searchable;
73804
74324
  for (const annotation of tree.findAllExpressionsRecursive(expressions_1.CDSAnnotation)) {
73805
74325
  const normalized = annotation.concatTokens().replace(/\s/g, "").toUpperCase().replace(/^@</, "@");
73806
- if (this.hasSearchAnnotation(normalized, "defaultSearchElement")) {
74326
+ if (this.hasSearchAnnotation(normalized, /[.{,]DEFAULTSEARCHELEMENT:TRUE/)) {
73807
74327
  return;
73808
74328
  }
73809
- else if (searchable === undefined && this.hasSearchAnnotation(normalized, "searchable")) {
74329
+ else if (searchable === undefined && this.hasSearchAnnotation(normalized, /[.{,]SEARCHABLE:TRUE/)) {
73810
74330
  searchable = annotation;
73811
74331
  }
73812
74332
  }
@@ -73816,11 +74336,11 @@ Missing objects are only reported when their names match the configured errorNam
73816
74336
  issues.push(issue_1.Issue.atToken(file, searchable.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
73817
74337
  }
73818
74338
  }
73819
- hasSearchAnnotation(normalized, name) {
74339
+ hasSearchAnnotation(normalized, annotation) {
73820
74340
  if (normalized.startsWith("@SEARCH") === false) {
73821
74341
  return false;
73822
74342
  }
73823
- return new RegExp("[.{,]" + name.toUpperCase() + ":TRUE").test(normalized);
74343
+ return annotation.test(normalized);
73824
74344
  }
73825
74345
  checkReservedNames(tree, issues, file) {
73826
74346
  var _a, _b;
@@ -74660,6 +75180,7 @@ class ChangeIfToCase extends _abap_rule_1.ABAPRule {
74660
75180
  constructor() {
74661
75181
  super(...arguments);
74662
75182
  this.conf = new ChangeIfToCaseConf();
75183
+ this.skipNames = [];
74663
75184
  }
74664
75185
  getMetadata() {
74665
75186
  return {
@@ -74686,6 +75207,7 @@ ENDCASE.`,
74686
75207
  }
74687
75208
  setConfig(conf) {
74688
75209
  this.conf = conf;
75210
+ this.skipNames = (this.conf.skipNames || []).map(skip => new RegExp(skip, "i"));
74689
75211
  }
74690
75212
  runParsed(file) {
74691
75213
  var _a;
@@ -74763,8 +75285,7 @@ ENDCASE.`,
74763
75285
  else {
74764
75286
  return false;
74765
75287
  }
74766
- for (const skip of this.getConfig().skipNames || []) {
74767
- const reg = new RegExp(skip, "i");
75288
+ for (const reg of this.skipNames) {
74768
75289
  if (chain.match(reg)) {
74769
75290
  return false;
74770
75291
  }
@@ -74782,6 +75303,251 @@ exports.ChangeIfToCase = ChangeIfToCase;
74782
75303
 
74783
75304
  /***/ },
74784
75305
 
75306
+ /***/ "../core/build/src/rules/changing_sorted_line.js"
75307
+ /*!*******************************************************!*\
75308
+ !*** ../core/build/src/rules/changing_sorted_line.js ***!
75309
+ \*******************************************************/
75310
+ (__unused_webpack_module, exports, __webpack_require__) {
75311
+
75312
+ "use strict";
75313
+
75314
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
75315
+ if (k2 === undefined) k2 = k;
75316
+ var desc = Object.getOwnPropertyDescriptor(m, k);
75317
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
75318
+ desc = { enumerable: true, get: function() { return m[k]; } };
75319
+ }
75320
+ Object.defineProperty(o, k2, desc);
75321
+ }) : (function(o, m, k, k2) {
75322
+ if (k2 === undefined) k2 = k;
75323
+ o[k2] = m[k];
75324
+ }));
75325
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
75326
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
75327
+ }) : function(o, v) {
75328
+ o["default"] = v;
75329
+ });
75330
+ var __importStar = (this && this.__importStar) || (function () {
75331
+ var ownKeys = function(o) {
75332
+ ownKeys = Object.getOwnPropertyNames || function (o) {
75333
+ var ar = [];
75334
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
75335
+ return ar;
75336
+ };
75337
+ return ownKeys(o);
75338
+ };
75339
+ return function (mod) {
75340
+ if (mod && mod.__esModule) return mod;
75341
+ var result = {};
75342
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
75343
+ __setModuleDefault(result, mod);
75344
+ return result;
75345
+ };
75346
+ })();
75347
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
75348
+ exports.ChangingSortedLine = exports.ChangingSortedLineConf = void 0;
75349
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
75350
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
75351
+ const Structures = __importStar(__webpack_require__(/*! ../abap/3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
75352
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
75353
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
75354
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
75355
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
75356
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
75357
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
75358
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
75359
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
75360
+ const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
75361
+ class ChangingSortedLineConf extends _basic_rule_config_1.BasicRuleConfig {
75362
+ }
75363
+ exports.ChangingSortedLineConf = ChangingSortedLineConf;
75364
+ class ChangingSortedLine {
75365
+ constructor() {
75366
+ this.conf = new ChangingSortedLineConf();
75367
+ }
75368
+ getMetadata() {
75369
+ return {
75370
+ key: "changing_sorted_line",
75371
+ title: "Line of a sorted or hashed table passed to CHANGING",
75372
+ shortDescription: `A field symbol on a whole line of a sorted or hashed table, passed to a CHANGING parameter of a method`,
75373
+ extendedInformation: `The key fields of a sorted or hashed table line are write-protected, so the line as a whole is
75374
+ write-protected. Binding it to a CHANGING parameter activates, but the call fails at runtime with
75375
+ CX_SY_DYN_CALL_ILLEGAL_TYPE, "the actual parameter for ... is write-protected", even when the method does not
75376
+ change the key.
75377
+
75378
+ Only field symbols assigned in the same method, form or function module are checked, via READ TABLE ... ASSIGNING,
75379
+ LOOP AT ... ASSIGNING, INSERT ... INTO TABLE ... ASSIGNING and ASSIGN itab[ ... ] TO.
75380
+
75381
+ Fix: read the line into a work area, pass the work area and MODIFY TABLE ... FROM it afterwards,
75382
+ or pass only the non-key fields the method needs.`,
75383
+ tags: [_irule_1.RuleTag.SingleFile],
75384
+ badExample: `READ TABLE lt_sum WITH TABLE KEY app = lv_app ASSIGNING FIELD-SYMBOL(<sum>).
75385
+ add( CHANGING cs_sum = <sum> ).`,
75386
+ goodExample: `READ TABLE lt_sum WITH TABLE KEY app = lv_app INTO DATA(ls_sum).
75387
+ add( CHANGING cs_sum = ls_sum ).
75388
+ MODIFY TABLE lt_sum FROM ls_sum.`,
75389
+ };
75390
+ }
75391
+ getConfig() {
75392
+ return this.conf;
75393
+ }
75394
+ initialize(reg) {
75395
+ this.reg = reg;
75396
+ return this;
75397
+ }
75398
+ setConfig(conf) {
75399
+ this.conf = conf;
75400
+ }
75401
+ run(obj) {
75402
+ if (!(obj instanceof _abap_object_1.ABAPObject) || obj.getType() === "INTF") {
75403
+ return [];
75404
+ }
75405
+ const issues = [];
75406
+ let spaghetti = undefined;
75407
+ for (const file of obj.getABAPFiles()) {
75408
+ const stru = file.getStructure();
75409
+ if (stru === undefined || stru.findFirstExpression(Expressions.MethodParameters) === undefined) {
75410
+ continue;
75411
+ }
75412
+ if (spaghetti === undefined) {
75413
+ spaghetti = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti;
75414
+ }
75415
+ const blocks = [...stru.findAllStructures(Structures.Method),
75416
+ ...stru.findAllStructures(Structures.Form),
75417
+ ...stru.findAllStructures(Structures.FunctionModule)];
75418
+ for (const block of blocks) {
75419
+ // field symbol name -> name of the sorted or hashed table it points into
75420
+ const lines = new Map();
75421
+ for (const statement of block.findAllStatementNodes()) {
75422
+ for (const p of statement.findAllExpressions(Expressions.MethodParameters)) {
75423
+ this.checkChanging(p, lines, spaghetti, file, issues);
75424
+ }
75425
+ this.updateAssigned(statement, lines, spaghetti, file);
75426
+ }
75427
+ }
75428
+ }
75429
+ return issues;
75430
+ }
75431
+ ////////////////
75432
+ checkChanging(params, lines, spaghetti, file, issues) {
75433
+ var _a, _b;
75434
+ let changing = false;
75435
+ for (const child of params.getChildren()) {
75436
+ const str = child.concatTokens().toUpperCase();
75437
+ if (child instanceof nodes_1.ExpressionNode && changing === true && child.get() instanceof Expressions.ParameterListT) {
75438
+ for (const p of child.findDirectExpressions(Expressions.ParameterT)) {
75439
+ const target = p.findDirectExpression(Expressions.Target);
75440
+ const fs = (target === null || target === void 0 ? void 0 : target.getChildren().length) === 1 ? target.findDirectExpression(Expressions.TargetFieldSymbol) : undefined;
75441
+ if (fs === undefined) {
75442
+ continue;
75443
+ }
75444
+ const table = lines.get(fs.concatTokens().toUpperCase());
75445
+ const type = (_a = this.findReference(fs.getFirstToken().getStart(), spaghetti, file)) === null || _a === void 0 ? void 0 : _a.getType();
75446
+ if (table === undefined || type === undefined || type.isGeneric()) {
75447
+ continue;
75448
+ }
75449
+ const name = (_b = p.findDirectExpression(Expressions.ParameterName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
75450
+ const message = `Line of sorted or hashed table ${table} passed to CHANGING ${name} is write-protected, ` +
75451
+ `the call fails at runtime. Use a work area and MODIFY TABLE ... FROM, or pass only non-key fields`;
75452
+ issues.push(issue_1.Issue.atToken(file, fs.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
75453
+ }
75454
+ }
75455
+ changing = str === "CHANGING";
75456
+ }
75457
+ }
75458
+ /** Tracks which field symbols the last assignment pointed to a whole line of a sorted or hashed table */
75459
+ updateAssigned(statement, lines, spaghetti, file) {
75460
+ var _a, _b, _c;
75461
+ var _d;
75462
+ const get = statement.get();
75463
+ const fs = get instanceof Statements.Unassign
75464
+ ? statement.findDirectExpression(Expressions.TargetFieldSymbol)
75465
+ : (_a = statement.findFirstExpression(Expressions.FSTarget)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(Expressions.TargetFieldSymbol);
75466
+ if (fs === undefined) {
75467
+ return;
75468
+ }
75469
+ const name = fs.concatTokens().toUpperCase();
75470
+ let table = undefined;
75471
+ let isTableExpression = false;
75472
+ if (get instanceof Statements.ReadTable) {
75473
+ table = (_d = statement.findDirectExpression(Expressions.SimpleSource2)) !== null && _d !== void 0 ? _d : statement.findDirectExpression(Expressions.Source);
75474
+ }
75475
+ else if (get instanceof Statements.Loop) {
75476
+ table = (_b = statement.findDirectExpression(Expressions.LoopSource)) === null || _b === void 0 ? void 0 : _b.getFirstChild();
75477
+ }
75478
+ else if (get instanceof Statements.InsertInternal && statement.findDirectTokenByText("TABLE") !== undefined) {
75479
+ table = statement.findDirectExpression(Expressions.Target);
75480
+ }
75481
+ else if (get instanceof Statements.Assign) {
75482
+ table = (_c = statement.findDirectExpression(Expressions.AssignSource)) === null || _c === void 0 ? void 0 : _c.getFirstChild();
75483
+ isTableExpression = true;
75484
+ }
75485
+ const tableType = table instanceof nodes_1.ExpressionNode ? this.findTableType(table, isTableExpression, spaghetti, file) : undefined;
75486
+ if (table instanceof nodes_1.ExpressionNode && tableType instanceof basic_1.TableType
75487
+ && (tableType.getAccessType() === basic_1.TableAccessType.sorted || tableType.getAccessType() === basic_1.TableAccessType.hashed)) {
75488
+ lines.set(name, table.concatTokens().replace(/\[.*$/, "").trim());
75489
+ }
75490
+ else {
75491
+ lines.delete(name);
75492
+ }
75493
+ }
75494
+ /** The type of a table given by a plain field chain of names, components and attributes, else undefined.
75495
+ * With tableExpression, the chain must end with a table expression, and the type of the chain before it is returned */
75496
+ findTableType(node, tableExpression, spaghetti, file) {
75497
+ var _a, _b;
75498
+ if (!(node.get() instanceof Expressions.Target)) {
75499
+ const chain = node.getChildren().length === 1 ? node.findDirectExpression(Expressions.FieldChain) : undefined;
75500
+ if (chain === undefined) {
75501
+ return undefined;
75502
+ }
75503
+ node = chain;
75504
+ }
75505
+ const children = [...node.getChildren()];
75506
+ if (tableExpression === true) {
75507
+ if (!(((_a = children.pop()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.TableExpression)) {
75508
+ return undefined;
75509
+ }
75510
+ }
75511
+ let type = undefined;
75512
+ for (const child of children) {
75513
+ const get = child.get();
75514
+ if (get instanceof Expressions.SourceField
75515
+ || get instanceof Expressions.SourceFieldSymbol
75516
+ || get instanceof Expressions.TargetField
75517
+ || get instanceof Expressions.TargetFieldSymbol
75518
+ || get instanceof Expressions.AttributeName) {
75519
+ type = (_b = this.findReference(child.getFirstToken().getStart(), spaghetti, file)) === null || _b === void 0 ? void 0 : _b.getType();
75520
+ }
75521
+ else if (get instanceof Expressions.ComponentName) {
75522
+ type = type instanceof basic_1.StructureType ? type.getComponentByName(child.concatTokens()) : undefined;
75523
+ }
75524
+ else if (get instanceof Expressions.ClassName || get instanceof tokens_1.StaticArrow) {
75525
+ continue;
75526
+ }
75527
+ else if (!(get instanceof tokens_1.Dash) && !(get instanceof tokens_1.InstanceArrow)) {
75528
+ return undefined;
75529
+ }
75530
+ if (type === undefined) {
75531
+ return undefined;
75532
+ }
75533
+ }
75534
+ return type;
75535
+ }
75536
+ findReference(start, spaghetti, file) {
75537
+ const scope = spaghetti.lookupPosition(start, file.getFilename());
75538
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
75539
+ if (r.position.getStart().equals(start) && r.resolved instanceof _typed_identifier_1.TypedIdentifier) {
75540
+ return r.resolved;
75541
+ }
75542
+ }
75543
+ return undefined;
75544
+ }
75545
+ }
75546
+ exports.ChangingSortedLine = ChangingSortedLine;
75547
+ //# sourceMappingURL=changing_sorted_line.js.map
75548
+
75549
+ /***/ },
75550
+
74785
75551
  /***/ "../core/build/src/rules/check_abstract.js"
74786
75552
  /*!*************************************************!*\
74787
75553
  !*** ../core/build/src/rules/check_abstract.js ***!
@@ -75731,6 +76497,7 @@ class ClassAttributeNames extends _abap_rule_1.ABAPRule {
75731
76497
  constructor() {
75732
76498
  super(...arguments);
75733
76499
  this.conf = new ClassAttributeNamesConf();
76500
+ this.regex = this.compile();
75734
76501
  }
75735
76502
  getMetadata() {
75736
76503
  return {
@@ -75758,6 +76525,15 @@ ENDCLASS.`,
75758
76525
  }
75759
76526
  setConfig(conf) {
75760
76527
  this.conf = conf;
76528
+ this.regex = this.compile();
76529
+ }
76530
+ compile() {
76531
+ return {
76532
+ statics: new RegExp(this.conf.statics, "i"),
76533
+ instance: new RegExp(this.conf.instance, "i"),
76534
+ constants: new RegExp(this.conf.constants, "i"),
76535
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
76536
+ };
75761
76537
  }
75762
76538
  runParsed(file, obj) {
75763
76539
  if (this.conf.patternKind === undefined) {
@@ -75790,13 +76566,13 @@ ENDCLASS.`,
75790
76566
  for (const a of attr) {
75791
76567
  switch (a.level) {
75792
76568
  case _abap_file_information_1.AttributeLevel.Instance:
75793
- ret = ret.concat(this.checkName(a.identifier, this.conf.instance));
76569
+ ret = ret.concat(this.checkName(a.identifier, this.conf.instance, this.regex.instance));
75794
76570
  break;
75795
76571
  case _abap_file_information_1.AttributeLevel.Static:
75796
- ret = ret.concat(this.checkName(a.identifier, this.conf.statics));
76572
+ ret = ret.concat(this.checkName(a.identifier, this.conf.statics, this.regex.statics));
75797
76573
  break;
75798
76574
  case _abap_file_information_1.AttributeLevel.Constant:
75799
- ret = ret.concat(this.checkName(a.identifier, this.conf.constants));
76575
+ ret = ret.concat(this.checkName(a.identifier, this.conf.constants, this.regex.constants));
75800
76576
  break;
75801
76577
  default:
75802
76578
  break;
@@ -75804,11 +76580,10 @@ ENDCLASS.`,
75804
76580
  }
75805
76581
  return ret;
75806
76582
  }
75807
- checkName(attr, expected) {
76583
+ checkName(attr, expected, regex) {
75808
76584
  const ret = [];
75809
- const regex = new RegExp(expected, "i");
75810
76585
  const name = attr.getName();
75811
- if (name_validator_1.NameValidator.violatesRule(name, regex, this.conf)) {
76586
+ if (name_validator_1.NameValidator.violatesRule(name, regex, this.conf, this.regex.ignorePatterns)) {
75812
76587
  const issue = issue_1.Issue.atIdentifier(attr, this.getDescription(name, expected), this.getMetadata().key, this.conf.severity);
75813
76588
  ret.push(issue);
75814
76589
  }
@@ -77638,6 +78413,179 @@ exports.DefinitionsTop = DefinitionsTop;
77638
78413
 
77639
78414
  /***/ },
77640
78415
 
78416
+ /***/ "../core/build/src/rules/delete_index_in_loop.js"
78417
+ /*!*******************************************************!*\
78418
+ !*** ../core/build/src/rules/delete_index_in_loop.js ***!
78419
+ \*******************************************************/
78420
+ (__unused_webpack_module, exports, __webpack_require__) {
78421
+
78422
+ "use strict";
78423
+
78424
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
78425
+ if (k2 === undefined) k2 = k;
78426
+ var desc = Object.getOwnPropertyDescriptor(m, k);
78427
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
78428
+ desc = { enumerable: true, get: function() { return m[k]; } };
78429
+ }
78430
+ Object.defineProperty(o, k2, desc);
78431
+ }) : (function(o, m, k, k2) {
78432
+ if (k2 === undefined) k2 = k;
78433
+ o[k2] = m[k];
78434
+ }));
78435
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
78436
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
78437
+ }) : function(o, v) {
78438
+ o["default"] = v;
78439
+ });
78440
+ var __importStar = (this && this.__importStar) || (function () {
78441
+ var ownKeys = function(o) {
78442
+ ownKeys = Object.getOwnPropertyNames || function (o) {
78443
+ var ar = [];
78444
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
78445
+ return ar;
78446
+ };
78447
+ return ownKeys(o);
78448
+ };
78449
+ return function (mod) {
78450
+ if (mod && mod.__esModule) return mod;
78451
+ var result = {};
78452
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
78453
+ __setModuleDefault(result, mod);
78454
+ return result;
78455
+ };
78456
+ })();
78457
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
78458
+ exports.DeleteIndexInLoop = exports.DeleteIndexInLoopConf = void 0;
78459
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
78460
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
78461
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
78462
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
78463
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
78464
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
78465
+ const token_node_1 = __webpack_require__(/*! ../abap/nodes/token_node */ "../core/build/src/abap/nodes/token_node.js");
78466
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
78467
+ class DeleteIndexInLoopConf extends _basic_rule_config_1.BasicRuleConfig {
78468
+ }
78469
+ exports.DeleteIndexInLoopConf = DeleteIndexInLoopConf;
78470
+ class DeleteIndexInLoop extends _abap_rule_1.ABAPRule {
78471
+ constructor() {
78472
+ super(...arguments);
78473
+ this.conf = new DeleteIndexInLoopConf();
78474
+ }
78475
+ getMetadata() {
78476
+ return {
78477
+ key: "delete_index_in_loop",
78478
+ title: "DELETE INDEX sy-tabix inside a LOOP over the same table",
78479
+ shortDescription: `Reports DELETE itab INDEX sy-tabix inside a LOOP AT the same table`,
78480
+ extendedInformation: `sy-tabix is the index of the loop's current row only until another statement writes it.
78481
+ READ TABLE, APPEND, INSERT, COLLECT, a nested LOOP and any method called in the loop body
78482
+ all set sy-tabix. After that the DELETE removes a different row, and if sy-tabix is 0 it
78483
+ raises the runtime error TABLE_INVALID_INDEX.
78484
+
78485
+ Use DELETE itab WHERE ..., or collect the rows to keep in a second table.
78486
+
78487
+ Not reported: DELETE itab INDEX sy-tabix directly after READ TABLE itab, where sy-tabix
78488
+ is the index the READ just set.`,
78489
+ tags: [_irule_1.RuleTag.SingleFile],
78490
+ badExample: `LOOP AT tab INTO row.
78491
+ IF row-flag = abap_true.
78492
+ DELETE tab INDEX sy-tabix.
78493
+ ENDIF.
78494
+ ENDLOOP.`,
78495
+ goodExample: `DELETE tab WHERE flag = abap_true.`,
78496
+ };
78497
+ }
78498
+ getConfig() {
78499
+ return this.conf;
78500
+ }
78501
+ setConfig(conf) {
78502
+ this.conf = conf;
78503
+ }
78504
+ runParsed(file) {
78505
+ const issues = [];
78506
+ const statements = file.getStatements();
78507
+ for (let i = 0; i < statements.length; i++) {
78508
+ const statement = statements[i];
78509
+ if (!(statement.get() instanceof Statements.DeleteInternal) || this.byTabix(statement) === false) {
78510
+ continue;
78511
+ }
78512
+ // DELETE TABLE and DELETE ADJACENT DUPLICATES have a keyword before the target
78513
+ const target = statement.findDirectExpression(Expressions.Target);
78514
+ if (target === undefined || statement.getChildren()[1] !== target) {
78515
+ continue;
78516
+ }
78517
+ const table = target.concatTokens().toUpperCase();
78518
+ if (this.previousReadsTable(i, statements, table) === true
78519
+ || this.enclosingLoopTables(i, statements).includes(table) === false) {
78520
+ continue;
78521
+ }
78522
+ const message = `DELETE ${target.concatTokens()} INDEX sy-tabix inside LOOP AT the same table,`
78523
+ + ` sy-tabix might not be the loop's current row`;
78524
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
78525
+ }
78526
+ return issues;
78527
+ }
78528
+ ////////////////
78529
+ byTabix(statement) {
78530
+ const children = statement.getChildren();
78531
+ for (let i = 0; i < children.length - 1; i++) {
78532
+ const child = children[i];
78533
+ if (child instanceof token_node_1.TokenNode && child.getFirstToken().getStr().toUpperCase() === "INDEX") {
78534
+ return children[i + 1].concatTokens().toUpperCase() === "SY-TABIX";
78535
+ }
78536
+ }
78537
+ return false;
78538
+ }
78539
+ previousReadsTable(index, statements, table) {
78540
+ var _a;
78541
+ for (let i = index - 1; i >= 0; i--) {
78542
+ const statement = statements[i];
78543
+ if (statement.get() instanceof _statement_1.Comment) {
78544
+ continue;
78545
+ }
78546
+ if (!(statement.get() instanceof Statements.ReadTable)) {
78547
+ return false;
78548
+ }
78549
+ const read = (_a = statement.findDirectExpression(Expressions.SimpleSource2)) !== null && _a !== void 0 ? _a : statement.findDirectExpression(Expressions.Source);
78550
+ return (read === null || read === void 0 ? void 0 : read.concatTokens().toUpperCase()) === table;
78551
+ }
78552
+ return false;
78553
+ }
78554
+ enclosingLoopTables(index, statements) {
78555
+ const tables = [];
78556
+ let depth = 0;
78557
+ for (let i = index - 1; i >= 0; i--) {
78558
+ const statement = statements[i];
78559
+ const s = statement.get();
78560
+ if (s instanceof Statements.EndLoop) {
78561
+ depth++;
78562
+ }
78563
+ else if (s instanceof Statements.Loop) {
78564
+ if (depth === 0) {
78565
+ const source = statement.findDirectExpression(Expressions.LoopSource);
78566
+ if (source !== undefined) {
78567
+ tables.push(source.concatTokens().toUpperCase());
78568
+ }
78569
+ }
78570
+ else {
78571
+ depth--;
78572
+ }
78573
+ }
78574
+ else if (s instanceof Statements.MethodImplementation
78575
+ || s instanceof Statements.Form
78576
+ || s instanceof Statements.FunctionModule
78577
+ || s instanceof Statements.Module) {
78578
+ break;
78579
+ }
78580
+ }
78581
+ return tables;
78582
+ }
78583
+ }
78584
+ exports.DeleteIndexInLoop = DeleteIndexInLoop;
78585
+ //# sourceMappingURL=delete_index_in_loop.js.map
78586
+
78587
+ /***/ },
78588
+
77641
78589
  /***/ "../core/build/src/rules/description_empty.js"
77642
78590
  /*!****************************************************!*\
77643
78591
  !*** ../core/build/src/rules/description_empty.js ***!
@@ -82485,6 +83433,94 @@ exports.Exporting = Exporting;
82485
83433
 
82486
83434
  /***/ },
82487
83435
 
83436
+ /***/ "../core/build/src/rules/final_newline.js"
83437
+ /*!************************************************!*\
83438
+ !*** ../core/build/src/rules/final_newline.js ***!
83439
+ \************************************************/
83440
+ (__unused_webpack_module, exports, __webpack_require__) {
83441
+
83442
+ "use strict";
83443
+
83444
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
83445
+ exports.FinalNewline = exports.FinalNewlineConf = void 0;
83446
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
83447
+ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
83448
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
83449
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
83450
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
83451
+ const objects_1 = __webpack_require__(/*! ../objects */ "../core/build/src/objects/index.js");
83452
+ class FinalNewlineConf extends _basic_rule_config_1.BasicRuleConfig {
83453
+ }
83454
+ exports.FinalNewlineConf = FinalNewlineConf;
83455
+ class FinalNewline {
83456
+ constructor() {
83457
+ this.conf = new FinalNewlineConf();
83458
+ }
83459
+ getMetadata() {
83460
+ return {
83461
+ key: "final_newline",
83462
+ title: "Final newline",
83463
+ shortDescription: `Checks that ABAP and XML files end with exactly one newline`,
83464
+ extendedInformation: `abapGit serializes every file with exactly one newline at the end. A file without it,
83465
+ or with empty lines at the end, is changed again on the next pull and shows up in every diff.
83466
+
83467
+ Empty files and files containing only line breaks are not checked. A carriage return before the
83468
+ newline is ignored, see rule line_break_style. SMIM and W3MI files and XSLT sources are not checked.`,
83469
+ tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
83470
+ badExample: `WRITE 'hello'.`,
83471
+ goodExample: `WRITE 'hello'.\n`,
83472
+ };
83473
+ }
83474
+ getConfig() {
83475
+ return this.conf;
83476
+ }
83477
+ setConfig(conf) {
83478
+ this.conf = conf;
83479
+ }
83480
+ initialize(_reg) {
83481
+ return this;
83482
+ }
83483
+ run(obj) {
83484
+ const issues = [];
83485
+ if (obj instanceof objects_1.MIMEObject || obj instanceof objects_1.WebMIME) {
83486
+ return issues;
83487
+ }
83488
+ for (const file of obj.getFiles()) {
83489
+ const filename = file.getFilename();
83490
+ if ((filename.endsWith(".abap") || filename.endsWith(".xml")) && !filename.endsWith(".xslt.source.xml")) {
83491
+ const issue = this.checkFile(file);
83492
+ if (issue) {
83493
+ issues.push(issue);
83494
+ }
83495
+ }
83496
+ }
83497
+ return issues;
83498
+ }
83499
+ checkFile(file) {
83500
+ const rows = file.getRawRows();
83501
+ const last = rows[rows.length - 1];
83502
+ if (last !== "") {
83503
+ const end = new position_1.Position(rows.length, last.length + 1);
83504
+ const fix = edit_helper_1.EditHelper.insertAt(file, end, "\n");
83505
+ return issue_1.Issue.atPosition(file, end, "Add newline at end of file", this.getMetadata().key, this.conf.severity, fix);
83506
+ }
83507
+ let row = rows.length - 2;
83508
+ while (row >= 0 && (rows[row] === "" || rows[row] === "\r")) {
83509
+ row--;
83510
+ }
83511
+ if (row < 0 || row === rows.length - 2) {
83512
+ return undefined;
83513
+ }
83514
+ const start = new position_1.Position(row + 2, 1);
83515
+ const fix = edit_helper_1.EditHelper.deleteRange(file, start, new position_1.Position(rows.length, 1));
83516
+ return issue_1.Issue.atPosition(file, start, "Remove empty lines at end of file", this.getMetadata().key, this.conf.severity, fix);
83517
+ }
83518
+ }
83519
+ exports.FinalNewline = FinalNewline;
83520
+ //# sourceMappingURL=final_newline.js.map
83521
+
83522
+ /***/ },
83523
+
82488
83524
  /***/ "../core/build/src/rules/fm_global_parameters_obsolete.js"
82489
83525
  /*!****************************************************************!*\
82490
83526
  !*** ../core/build/src/rules/fm_global_parameters_obsolete.js ***!
@@ -82609,6 +83645,7 @@ class ForbiddenIdentifier extends _abap_rule_1.ABAPRule {
82609
83645
  constructor() {
82610
83646
  super(...arguments);
82611
83647
  this.conf = new ForbiddenIdentifierConf();
83648
+ this.checks = [];
82612
83649
  }
82613
83650
  getMetadata() {
82614
83651
  return {
@@ -82628,9 +83665,10 @@ https://github.com/abaplint/transpiler/blob/bda94b8b56e2b7f2f87be2168f12361aa530
82628
83665
  if (this.conf.check === undefined) {
82629
83666
  this.conf.check = [];
82630
83667
  }
83668
+ this.checks = this.conf.check.map(c => new RegExp(c, "i"));
82631
83669
  }
82632
83670
  runParsed(file) {
82633
- if (this.conf.check.length === 0) {
83671
+ if (this.checks.length === 0) {
82634
83672
  return [];
82635
83673
  }
82636
83674
  let ret = [];
@@ -82657,8 +83695,7 @@ https://github.com/abaplint/transpiler/blob/bda94b8b56e2b7f2f87be2168f12361aa530
82657
83695
  check(token, file) {
82658
83696
  const str = token.getStr();
82659
83697
  const ret = [];
82660
- for (const c of this.conf.check) {
82661
- const reg = new RegExp(c, "i");
83698
+ for (const reg of this.checks) {
82662
83699
  if (reg.exec(str)) {
82663
83700
  const message = "Identifer \"" + str + "\" not allowed";
82664
83701
  ret.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
@@ -82884,6 +83921,7 @@ exports.ForbiddenVoidTypeConf = ForbiddenVoidTypeConf;
82884
83921
  class ForbiddenVoidType {
82885
83922
  constructor() {
82886
83923
  this.conf = new ForbiddenVoidTypeConf();
83924
+ this.checks = [];
82887
83925
  }
82888
83926
  getMetadata() {
82889
83927
  return {
@@ -82903,13 +83941,14 @@ DATS, TIMS, DATUM, FLAG, INT4, NUMC3, NUMC4, SAP_BOOL, TEXT25, TEXT80, X255, XFE
82903
83941
  if (this.conf.check === undefined) {
82904
83942
  this.conf.check = [];
82905
83943
  }
83944
+ this.checks = this.conf.check.map(c => new RegExp(c, "i"));
82906
83945
  }
82907
83946
  initialize(reg) {
82908
83947
  this.reg = reg;
82909
83948
  return this;
82910
83949
  }
82911
83950
  run(obj) {
82912
- if (!(obj instanceof _abap_object_1.ABAPObject) || this.conf.check.length === 0) {
83951
+ if (!(obj instanceof _abap_object_1.ABAPObject) || this.checks.length === 0) {
82913
83952
  return [];
82914
83953
  }
82915
83954
  return this.traverse(new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop());
@@ -82952,14 +83991,7 @@ DATS, TIMS, DATUM, FLAG, INT4, NUMC3, NUMC4, SAP_BOOL, TEXT25, TEXT80, X255, XFE
82952
83991
  if (name === undefined) {
82953
83992
  return false;
82954
83993
  }
82955
- for (const c of this.conf.check) {
82956
- const reg = new RegExp(c, "i");
82957
- const match = reg.test(name);
82958
- if (match === true) {
82959
- return true;
82960
- }
82961
- }
82962
- return false;
83994
+ return this.checks.some(reg => reg.test(name));
82963
83995
  }
82964
83996
  }
82965
83997
  exports.ForbiddenVoidType = ForbiddenVoidType;
@@ -85570,6 +86602,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
85570
86602
  Object.defineProperty(exports, "__esModule", ({ value: true }));
85571
86603
  __exportStar(__webpack_require__(/*! ./7bit_ascii */ "../core/build/src/rules/7bit_ascii.js"), exports);
85572
86604
  __exportStar(__webpack_require__(/*! ./abapdoc */ "../core/build/src/rules/abapdoc.js"), exports);
86605
+ __exportStar(__webpack_require__(/*! ./abapdoc_html_tag */ "../core/build/src/rules/abapdoc_html_tag.js"), exports);
86606
+ __exportStar(__webpack_require__(/*! ./abapdoc_leading_at */ "../core/build/src/rules/abapdoc_leading_at.js"), exports);
86607
+ __exportStar(__webpack_require__(/*! ./abapdoc_parameter_names */ "../core/build/src/rules/abapdoc_parameter_names.js"), exports);
85573
86608
  __exportStar(__webpack_require__(/*! ./add_test_attributes */ "../core/build/src/rules/add_test_attributes.js"), exports);
85574
86609
  __exportStar(__webpack_require__(/*! ./aff_and_xml */ "../core/build/src/rules/aff_and_xml.js"), exports);
85575
86610
  __exportStar(__webpack_require__(/*! ./align_parameters */ "../core/build/src/rules/align_parameters.js"), exports);
@@ -85592,6 +86627,7 @@ __exportStar(__webpack_require__(/*! ./cds_naming */ "../core/build/src/rules/cd
85592
86627
  __exportStar(__webpack_require__(/*! ./cds_parser_error */ "../core/build/src/rules/cds_parser_error.js"), exports);
85593
86628
  __exportStar(__webpack_require__(/*! ./chain_mainly_declarations */ "../core/build/src/rules/chain_mainly_declarations.js"), exports);
85594
86629
  __exportStar(__webpack_require__(/*! ./change_if_to_case */ "../core/build/src/rules/change_if_to_case.js"), exports);
86630
+ __exportStar(__webpack_require__(/*! ./changing_sorted_line */ "../core/build/src/rules/changing_sorted_line.js"), exports);
85595
86631
  __exportStar(__webpack_require__(/*! ./check_abstract */ "../core/build/src/rules/check_abstract.js"), exports);
85596
86632
  __exportStar(__webpack_require__(/*! ./check_comments */ "../core/build/src/rules/check_comments.js"), exports);
85597
86633
  __exportStar(__webpack_require__(/*! ./check_ddic */ "../core/build/src/rules/check_ddic.js"), exports);
@@ -85614,6 +86650,7 @@ __exportStar(__webpack_require__(/*! ./cyclomatic_complexity */ "../core/build/s
85614
86650
  __exportStar(__webpack_require__(/*! ./dangerous_statement */ "../core/build/src/rules/dangerous_statement.js"), exports);
85615
86651
  __exportStar(__webpack_require__(/*! ./db_operation_in_loop */ "../core/build/src/rules/db_operation_in_loop.js"), exports);
85616
86652
  __exportStar(__webpack_require__(/*! ./definitions_top */ "../core/build/src/rules/definitions_top.js"), exports);
86653
+ __exportStar(__webpack_require__(/*! ./delete_index_in_loop */ "../core/build/src/rules/delete_index_in_loop.js"), exports);
85617
86654
  __exportStar(__webpack_require__(/*! ./description_empty */ "../core/build/src/rules/description_empty.js"), exports);
85618
86655
  __exportStar(__webpack_require__(/*! ./double_space */ "../core/build/src/rules/double_space.js"), exports);
85619
86656
  __exportStar(__webpack_require__(/*! ./downport */ "../core/build/src/rules/downport.js"), exports);
@@ -85627,6 +86664,7 @@ __exportStar(__webpack_require__(/*! ./else_after_all_returns */ "../core/build/
85627
86664
  __exportStar(__webpack_require__(/*! ./exit_or_check */ "../core/build/src/rules/exit_or_check.js"), exports);
85628
86665
  __exportStar(__webpack_require__(/*! ./expand_macros */ "../core/build/src/rules/expand_macros.js"), exports);
85629
86666
  __exportStar(__webpack_require__(/*! ./exporting */ "../core/build/src/rules/exporting.js"), exports);
86667
+ __exportStar(__webpack_require__(/*! ./final_newline */ "../core/build/src/rules/final_newline.js"), exports);
85630
86668
  __exportStar(__webpack_require__(/*! ./fm_global_parameters_obsolete */ "../core/build/src/rules/fm_global_parameters_obsolete.js"), exports);
85631
86669
  __exportStar(__webpack_require__(/*! ./forbidden_identifier */ "../core/build/src/rules/forbidden_identifier.js"), exports);
85632
86670
  __exportStar(__webpack_require__(/*! ./forbidden_pseudo_and_pragma */ "../core/build/src/rules/forbidden_pseudo_and_pragma.js"), exports);
@@ -85650,6 +86688,7 @@ __exportStar(__webpack_require__(/*! ./in_statement_indentation */ "../core/buil
85650
86688
  __exportStar(__webpack_require__(/*! ./indentation */ "../core/build/src/rules/indentation.js"), exports);
85651
86689
  __exportStar(__webpack_require__(/*! ./index_completely_contained */ "../core/build/src/rules/index_completely_contained.js"), exports);
85652
86690
  __exportStar(__webpack_require__(/*! ./inline_data_old_versions */ "../core/build/src/rules/inline_data_old_versions.js"), exports);
86691
+ __exportStar(__webpack_require__(/*! ./inline_packed_computation */ "../core/build/src/rules/inline_packed_computation.js"), exports);
85653
86692
  __exportStar(__webpack_require__(/*! ./intf_referencing_clas */ "../core/build/src/rules/intf_referencing_clas.js"), exports);
85654
86693
  __exportStar(__webpack_require__(/*! ./invalid_table_index */ "../core/build/src/rules/invalid_table_index.js"), exports);
85655
86694
  __exportStar(__webpack_require__(/*! ./keep_single_parameter_on_one_line */ "../core/build/src/rules/keep_single_parameter_on_one_line.js"), exports);
@@ -85701,6 +86740,7 @@ __exportStar(__webpack_require__(/*! ./parser_missing_space */ "../core/build/sr
85701
86740
  __exportStar(__webpack_require__(/*! ./pragma_style */ "../core/build/src/rules/pragma_style.js"), exports);
85702
86741
  __exportStar(__webpack_require__(/*! ./prefer_corresponding */ "../core/build/src/rules/prefer_corresponding.js"), exports);
85703
86742
  __exportStar(__webpack_require__(/*! ./prefer_inline */ "../core/build/src/rules/prefer_inline.js"), exports);
86743
+ __exportStar(__webpack_require__(/*! ./prefer_inline_cast */ "../core/build/src/rules/prefer_inline_cast.js"), exports);
85704
86744
  __exportStar(__webpack_require__(/*! ./prefer_insert_into_table */ "../core/build/src/rules/prefer_insert_into_table.js"), exports);
85705
86745
  __exportStar(__webpack_require__(/*! ./prefer_is_not */ "../core/build/src/rules/prefer_is_not.js"), exports);
85706
86746
  __exportStar(__webpack_require__(/*! ./prefer_pragmas */ "../core/build/src/rules/prefer_pragmas.js"), exports);
@@ -85713,6 +86753,7 @@ __exportStar(__webpack_require__(/*! ./prefer_xsdbool */ "../core/build/src/rule
85713
86753
  __exportStar(__webpack_require__(/*! ./preferred_compare_operator */ "../core/build/src/rules/preferred_compare_operator.js"), exports);
85714
86754
  __exportStar(__webpack_require__(/*! ./preferred_parameter_ignored */ "../core/build/src/rules/preferred_parameter_ignored.js"), exports);
85715
86755
  __exportStar(__webpack_require__(/*! ./prefix_is_current_class */ "../core/build/src/rules/prefix_is_current_class.js"), exports);
86756
+ __exportStar(__webpack_require__(/*! ./range_row_values */ "../core/build/src/rules/range_row_values.js"), exports);
85716
86757
  __exportStar(__webpack_require__(/*! ./reduce_procedural_code */ "../core/build/src/rules/reduce_procedural_code.js"), exports);
85717
86758
  __exportStar(__webpack_require__(/*! ./reduce_string_templates */ "../core/build/src/rules/reduce_string_templates.js"), exports);
85718
86759
  __exportStar(__webpack_require__(/*! ./redundant_conversion */ "../core/build/src/rules/redundant_conversion.js"), exports);
@@ -85729,6 +86770,7 @@ __exportStar(__webpack_require__(/*! ./short_case */ "../core/build/src/rules/sh
85729
86770
  __exportStar(__webpack_require__(/*! ./sicf_consistency */ "../core/build/src/rules/sicf_consistency.js"), exports);
85730
86771
  __exportStar(__webpack_require__(/*! ./slow_parameter_passing */ "../core/build/src/rules/slow_parameter_passing.js"), exports);
85731
86772
  __exportStar(__webpack_require__(/*! ./smim_consistency */ "../core/build/src/rules/smim_consistency.js"), exports);
86773
+ __exportStar(__webpack_require__(/*! ./sort_empty_key */ "../core/build/src/rules/sort_empty_key.js"), exports);
85732
86774
  __exportStar(__webpack_require__(/*! ./space_before_colon */ "../core/build/src/rules/space_before_colon.js"), exports);
85733
86775
  __exportStar(__webpack_require__(/*! ./space_before_dot */ "../core/build/src/rules/space_before_dot.js"), exports);
85734
86776
  __exportStar(__webpack_require__(/*! ./sql_escape_host_variables */ "../core/build/src/rules/sql_escape_host_variables.js"), exports);
@@ -85736,6 +86778,7 @@ __exportStar(__webpack_require__(/*! ./sql_value_conversion */ "../core/build/sr
85736
86778
  __exportStar(__webpack_require__(/*! ./start_at_tab */ "../core/build/src/rules/start_at_tab.js"), exports);
85737
86779
  __exportStar(__webpack_require__(/*! ./static_call_via_instance */ "../core/build/src/rules/static_call_via_instance.js"), exports);
85738
86780
  __exportStar(__webpack_require__(/*! ./strict_sql */ "../core/build/src/rules/strict_sql.js"), exports);
86781
+ __exportStar(__webpack_require__(/*! ./subrc_after_assign */ "../core/build/src/rules/subrc_after_assign.js"), exports);
85739
86782
  __exportStar(__webpack_require__(/*! ./superclass_final */ "../core/build/src/rules/superclass_final.js"), exports);
85740
86783
  __exportStar(__webpack_require__(/*! ./superfluous_value */ "../core/build/src/rules/superfluous_value.js"), exports);
85741
86784
  __exportStar(__webpack_require__(/*! ./sy_modification */ "../core/build/src/rules/sy_modification.js"), exports);
@@ -85958,6 +87001,236 @@ exports.InlineDataOldVersions = InlineDataOldVersions;
85958
87001
 
85959
87002
  /***/ },
85960
87003
 
87004
+ /***/ "../core/build/src/rules/inline_packed_computation.js"
87005
+ /*!************************************************************!*\
87006
+ !*** ../core/build/src/rules/inline_packed_computation.js ***!
87007
+ \************************************************************/
87008
+ (__unused_webpack_module, exports, __webpack_require__) {
87009
+
87010
+ "use strict";
87011
+
87012
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
87013
+ if (k2 === undefined) k2 = k;
87014
+ var desc = Object.getOwnPropertyDescriptor(m, k);
87015
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
87016
+ desc = { enumerable: true, get: function() { return m[k]; } };
87017
+ }
87018
+ Object.defineProperty(o, k2, desc);
87019
+ }) : (function(o, m, k, k2) {
87020
+ if (k2 === undefined) k2 = k;
87021
+ o[k2] = m[k];
87022
+ }));
87023
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
87024
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
87025
+ }) : function(o, v) {
87026
+ o["default"] = v;
87027
+ });
87028
+ var __importStar = (this && this.__importStar) || (function () {
87029
+ var ownKeys = function(o) {
87030
+ ownKeys = Object.getOwnPropertyNames || function (o) {
87031
+ var ar = [];
87032
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
87033
+ return ar;
87034
+ };
87035
+ return ownKeys(o);
87036
+ };
87037
+ return function (mod) {
87038
+ if (mod && mod.__esModule) return mod;
87039
+ var result = {};
87040
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
87041
+ __setModuleDefault(result, mod);
87042
+ return result;
87043
+ };
87044
+ })();
87045
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
87046
+ exports.InlinePackedComputation = exports.InlinePackedComputationConf = void 0;
87047
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
87048
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
87049
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
87050
+ const constant_1 = __webpack_require__(/*! ../abap/5_syntax/expressions/constant */ "../core/build/src/abap/5_syntax/expressions/constant.js");
87051
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
87052
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
87053
+ const types_1 = __webpack_require__(/*! ../abap/types */ "../core/build/src/abap/types/index.js");
87054
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
87055
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
87056
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
87057
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
87058
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
87059
+ class InlinePackedComputationConf extends _basic_rule_config_1.BasicRuleConfig {
87060
+ }
87061
+ exports.InlinePackedComputationConf = InlinePackedComputationConf;
87062
+ class InlinePackedComputation {
87063
+ constructor() {
87064
+ this.conf = new InlinePackedComputationConf();
87065
+ }
87066
+ getMetadata() {
87067
+ return {
87068
+ key: "inline_packed_computation",
87069
+ title: "Inline declaration from a packed computation",
87070
+ shortDescription: `Finds inline declarations whose value is an arithmetic expression with calculation type p`,
87071
+ extendedInformation: `The result of a computation with calculation type p has no length and number of decimals
87072
+ that a declaration could take over, so DATA( ) or FINAL( ) gets the type p LENGTH 8 DECIMALS 0 and the
87073
+ syntax check warns "For the result of a computation with type P, the type P(8,0) is used here implicitly".
87074
+ Decimals of the operands are lost, and so are digits beyond the length.
87075
+
87076
+ Reported when at least one operand is packed and all other operands are of type i, int8 or p. Operands
87077
+ of other types, generic or unknown types, and the operator ** are not reported.
87078
+
87079
+ Declare the variable with the operands' type, or name the type with CONV.`,
87080
+ tags: [],
87081
+ badExample: `DATA a TYPE p LENGTH 8 DECIMALS 2.
87082
+ DATA b TYPE p LENGTH 8 DECIMALS 2.
87083
+ DATA(diff) = a - b.`,
87084
+ goodExample: `DATA a TYPE p LENGTH 8 DECIMALS 2.
87085
+ DATA b TYPE p LENGTH 8 DECIMALS 2.
87086
+ DATA diff LIKE a.
87087
+ diff = a - b.`,
87088
+ };
87089
+ }
87090
+ getConfig() {
87091
+ return this.conf;
87092
+ }
87093
+ setConfig(conf) {
87094
+ this.conf = conf;
87095
+ }
87096
+ initialize(reg) {
87097
+ this.reg = reg;
87098
+ return this;
87099
+ }
87100
+ run(obj) {
87101
+ var _a, _b;
87102
+ if (!(obj instanceof _abap_object_1.ABAPObject)) {
87103
+ return [];
87104
+ }
87105
+ const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
87106
+ if (syntax.issues.length > 0) {
87107
+ return [];
87108
+ }
87109
+ const issues = [];
87110
+ for (const file of obj.getABAPFiles()) {
87111
+ for (const statement of file.getStatements()) {
87112
+ if (!(statement.get() instanceof Statements.Move)) {
87113
+ continue;
87114
+ }
87115
+ const inline = (_a = statement.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.InlineData);
87116
+ const name = (_b = inline === null || inline === void 0 ? void 0 : inline.findDirectExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
87117
+ const source = statement.findDirectExpression(Expressions.Source);
87118
+ if (name === undefined
87119
+ || source === undefined
87120
+ || source.findDirectExpression(Expressions.ArithOperator) === undefined) {
87121
+ continue;
87122
+ }
87123
+ const scope = syntax.spaghetti.lookupPosition(name.getStart(), file.getFilename());
87124
+ if (scope === undefined) {
87125
+ continue;
87126
+ }
87127
+ const operands = this.operandTypes(source, scope);
87128
+ if (operands === undefined || operands.some(t => t instanceof basic_1.PackedType) === false) {
87129
+ continue;
87130
+ }
87131
+ const message = `"${name.getStr()}" gets type p LENGTH 8 DECIMALS 0 from this packed computation, ` +
87132
+ `declare it with the operands' type or use CONV`;
87133
+ issues.push(issue_1.Issue.atToken(file, name, message, this.getMetadata().key, this.conf.severity));
87134
+ }
87135
+ }
87136
+ return issues;
87137
+ }
87138
+ /** The types of the operands of an arithmetic expression, undefined when an operand is not of type
87139
+ * i, int8 or p, or is not known */
87140
+ operandTypes(source, scope) {
87141
+ const ret = [];
87142
+ for (const child of source.getChildren()) {
87143
+ let found = undefined;
87144
+ if (child instanceof nodes_1.TokenNode) {
87145
+ // parentheses and a sign, anything else is a constructor expression or a string operator
87146
+ if (["(", ")", "+", "-"].includes(child.getFirstToken().getStr()) === false) {
87147
+ return undefined;
87148
+ }
87149
+ continue;
87150
+ }
87151
+ else if (child.get() instanceof Expressions.ArithOperator) {
87152
+ if (["+", "-", "*", "/", "DIV", "MOD"].includes(child.concatTokens().toUpperCase()) === false) {
87153
+ return undefined;
87154
+ }
87155
+ continue;
87156
+ }
87157
+ else if (child.get() instanceof Expressions.Source) {
87158
+ const nested = this.operandTypes(child, scope);
87159
+ if (nested === undefined) {
87160
+ return undefined;
87161
+ }
87162
+ ret.push(...nested);
87163
+ continue;
87164
+ }
87165
+ else if (child.get() instanceof Expressions.FieldChain) {
87166
+ found = this.fieldChainType(child, scope);
87167
+ }
87168
+ else if (child.get() instanceof Expressions.MethodCallChain) {
87169
+ found = this.methodCallType(child, scope);
87170
+ }
87171
+ else if (child.get() instanceof Expressions.Constant) {
87172
+ found = constant_1.Constant.runSyntax(child);
87173
+ }
87174
+ if (found === undefined
87175
+ || found.isGeneric()
87176
+ || !(found instanceof basic_1.PackedType || found instanceof basic_1.IntegerType || found instanceof basic_1.Integer8Type)) {
87177
+ return undefined;
87178
+ }
87179
+ ret.push(found);
87180
+ }
87181
+ return ret;
87182
+ }
87183
+ methodCallType(chain, scope) {
87184
+ var _a, _b, _c;
87185
+ const last = chain.getLastChild();
87186
+ if (!(last instanceof nodes_1.ExpressionNode) || !(last.get() instanceof Expressions.MethodCall)) {
87187
+ return undefined;
87188
+ }
87189
+ const name = (_a = last.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
87190
+ if (name === undefined) {
87191
+ return undefined;
87192
+ }
87193
+ const method = (_b = scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.MethodReference
87194
+ && reference.position.getStart().equals(name.getStart()))) === null || _b === void 0 ? void 0 : _b.resolved;
87195
+ if (!(method instanceof types_1.MethodDefinition)) {
87196
+ return undefined;
87197
+ }
87198
+ return (_c = method.getParameters().getReturning()) === null || _c === void 0 ? void 0 : _c.getType();
87199
+ }
87200
+ fieldChainType(fieldChain, scope) {
87201
+ var _a;
87202
+ const operand = (_a = scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.DataReadReference
87203
+ && reference.position.getStart().equals(fieldChain.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
87204
+ if (!(operand instanceof _typed_identifier_1.TypedIdentifier)) {
87205
+ return undefined;
87206
+ }
87207
+ let type = operand.getType();
87208
+ for (const child of fieldChain.getChildren()) {
87209
+ if (!(child instanceof nodes_1.ExpressionNode)
87210
+ || child.get() instanceof Expressions.SourceField) {
87211
+ continue;
87212
+ }
87213
+ else if (child.get() instanceof Expressions.ComponentName) {
87214
+ if (type instanceof basic_1.TableType) {
87215
+ type = type.getRowType();
87216
+ }
87217
+ if (!(type instanceof basic_1.StructureType)) {
87218
+ return undefined;
87219
+ }
87220
+ type = type.getComponentByName(child.concatTokens());
87221
+ }
87222
+ else {
87223
+ return undefined;
87224
+ }
87225
+ }
87226
+ return type;
87227
+ }
87228
+ }
87229
+ exports.InlinePackedComputation = InlinePackedComputation;
87230
+ //# sourceMappingURL=inline_packed_computation.js.map
87231
+
87232
+ /***/ },
87233
+
85961
87234
  /***/ "../core/build/src/rules/intf_referencing_clas.js"
85962
87235
  /*!********************************************************!*\
85963
87236
  !*** ../core/build/src/rules/intf_referencing_clas.js ***!
@@ -85987,6 +87260,7 @@ exports.IntfReferencingClasConf = IntfReferencingClasConf;
85987
87260
  class IntfReferencingClas {
85988
87261
  constructor() {
85989
87262
  this.conf = new IntfReferencingClasConf();
87263
+ this.allow = [];
85990
87264
  }
85991
87265
  getMetadata() {
85992
87266
  return {
@@ -86007,6 +87281,7 @@ class IntfReferencingClas {
86007
87281
  }
86008
87282
  setConfig(conf) {
86009
87283
  this.conf = conf;
87284
+ this.allow = (this.conf.allow || []).map(reg => new RegExp(reg, "i"));
86010
87285
  }
86011
87286
  initialize(reg) {
86012
87287
  this.reg = reg;
@@ -86032,7 +87307,7 @@ class IntfReferencingClas {
86032
87307
  if (found && ddic.isException(found.getClassDefinition(), found)) {
86033
87308
  continue;
86034
87309
  }
86035
- else if (this.getConfig().allow.some(reg => new RegExp(reg, "i").test(r.extra.ooName))) {
87310
+ else if (this.allow.some(reg => reg.test(r.extra.ooName))) {
86036
87311
  continue;
86037
87312
  }
86038
87313
  ret.push(issue_1.Issue.atIdentifier(r.position, message + r.extra.ooName, this.getMetadata().key, this.conf.severity));
@@ -87017,7 +88292,7 @@ https://docs.abapopenchecks.org/checks/16/`,
87017
88292
  }
87018
88293
  }
87019
88294
  const rows = file.getRawRows();
87020
- const reg = new RegExp("^\\)?\\. *(\\\".*)?$");
88295
+ const reg = /^\)?\. *(".*)?$/;
87021
88296
  for (let i = 0; i < rows.length; i++) {
87022
88297
  if (reg.exec(rows[i].trim())) {
87023
88298
  const column = rows[i].indexOf(")") >= 0 ? rows[i].indexOf(")") + 1 : rows[i].indexOf(".") + 1;
@@ -87082,6 +88357,7 @@ class LocalClassNaming extends _abap_rule_1.ABAPRule {
87082
88357
  constructor() {
87083
88358
  super(...arguments);
87084
88359
  this.conf = new LocalClassNamingConf();
88360
+ this.regex = this.compile();
87085
88361
  }
87086
88362
  getMetadata() {
87087
88363
  return {
@@ -87105,6 +88381,15 @@ ENDCLASS.`,
87105
88381
  }
87106
88382
  setConfig(conf) {
87107
88383
  this.conf = conf;
88384
+ this.regex = this.compile();
88385
+ }
88386
+ compile() {
88387
+ return {
88388
+ local: new RegExp(this.conf.local, "i"),
88389
+ exception: new RegExp(this.conf.exception, "i"),
88390
+ test: new RegExp(this.conf.test, "i"),
88391
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
88392
+ };
87108
88393
  }
87109
88394
  runParsed(file, obj) {
87110
88395
  const issues = [];
@@ -87118,20 +88403,23 @@ ENDCLASS.`,
87118
88403
  }
87119
88404
  const className = classDef.name;
87120
88405
  let expected;
88406
+ let regex;
87121
88407
  if (classDef.isForTesting) {
87122
88408
  expected = this.conf.test;
88409
+ regex = this.regex.test;
87123
88410
  }
87124
88411
  else if (ddic.isException(classDef, obj)) {
87125
88412
  expected = this.conf.exception;
88413
+ regex = this.regex.exception;
87126
88414
  }
87127
88415
  else {
87128
88416
  expected = this.conf.local;
88417
+ regex = this.regex.local;
87129
88418
  }
87130
88419
  if (expected === undefined || expected.length === 0) {
87131
88420
  continue;
87132
88421
  }
87133
- const regex = new RegExp(expected, "i");
87134
- if (name_validator_1.NameValidator.violatesRule(className, regex, this.conf)) {
88422
+ if (name_validator_1.NameValidator.violatesRule(className, regex, this.conf, this.regex.ignorePatterns)) {
87135
88423
  issues.push(issue_1.Issue.atIdentifier(classDef.identifier, this.getDescription(expected, className), this.getMetadata().key, this.conf.severity));
87136
88424
  }
87137
88425
  }
@@ -87293,6 +88581,7 @@ class LocalVariableNames extends _abap_rule_1.ABAPRule {
87293
88581
  constructor() {
87294
88582
  super(...arguments);
87295
88583
  this.conf = new LocalVariableNamesConf();
88584
+ this.regex = this.compile();
87296
88585
  }
87297
88586
  getMetadata() {
87298
88587
  return {
@@ -87320,6 +88609,15 @@ ENDFORM.`,
87320
88609
  }
87321
88610
  setConfig(conf) {
87322
88611
  this.conf = conf;
88612
+ this.regex = this.compile();
88613
+ }
88614
+ compile() {
88615
+ return {
88616
+ expectedData: new RegExp(this.conf.expectedData, "i"),
88617
+ expectedConstant: new RegExp(this.conf.expectedConstant, "i"),
88618
+ expectedFS: new RegExp(this.conf.expectedFS, "i"),
88619
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
88620
+ };
87323
88621
  }
87324
88622
  runParsed(file) {
87325
88623
  const ret = [];
@@ -87353,7 +88651,7 @@ ENDFORM.`,
87353
88651
  const found = dat.findFirstExpression(Expressions.DefinitionName);
87354
88652
  if (found) {
87355
88653
  const token = found.getFirstToken();
87356
- ret = ret.concat(this.checkName(token, file, this.conf.expectedData));
88654
+ ret = ret.concat(this.checkName(token, file, this.conf.expectedData, this.regex.expectedData));
87357
88655
  }
87358
88656
  }
87359
88657
  // inline data
@@ -87361,7 +88659,7 @@ ENDFORM.`,
87361
88659
  const found = dat.findFirstExpression(Expressions.TargetField);
87362
88660
  if (found) {
87363
88661
  const token = found.getFirstToken();
87364
- ret = ret.concat(this.checkName(token, file, this.conf.expectedData));
88662
+ ret = ret.concat(this.checkName(token, file, this.conf.expectedData, this.regex.expectedData));
87365
88663
  }
87366
88664
  }
87367
88665
  // data structures, data begin of, first level
@@ -87372,14 +88670,14 @@ ENDFORM.`,
87372
88670
  const found = stat === null || stat === void 0 ? void 0 : stat.findFirstExpression(Expressions.DefinitionName);
87373
88671
  if (found) {
87374
88672
  const token = found.getFirstToken();
87375
- ret = ret.concat(this.checkName(token, file, this.conf.expectedData));
88673
+ ret = ret.concat(this.checkName(token, file, this.conf.expectedData, this.regex.expectedData));
87376
88674
  }
87377
88675
  }
87378
88676
  for (const fieldsymbol of structure.findAllStatements(Statements.FieldSymbol)) {
87379
88677
  const found = fieldsymbol.findFirstExpression(Expressions.FieldSymbol);
87380
88678
  if (found) {
87381
88679
  const token = found.getFirstToken();
87382
- ret = ret.concat(this.checkName(token, file, this.conf.expectedFS));
88680
+ ret = ret.concat(this.checkName(token, file, this.conf.expectedFS, this.regex.expectedFS));
87383
88681
  }
87384
88682
  }
87385
88683
  // inline field symbols
@@ -87387,7 +88685,7 @@ ENDFORM.`,
87387
88685
  const found = fieldsymbol.findFirstExpression(Expressions.TargetFieldSymbol);
87388
88686
  if (found) {
87389
88687
  const token = found.getFirstToken();
87390
- ret = ret.concat(this.checkName(token, file, this.conf.expectedFS));
88688
+ ret = ret.concat(this.checkName(token, file, this.conf.expectedFS, this.regex.expectedFS));
87391
88689
  }
87392
88690
  }
87393
88691
  const constants = structure.findAllStatements(Statements.Constant);
@@ -87399,16 +88697,15 @@ ENDFORM.`,
87399
88697
  const found = constant.findFirstExpression(Expressions.DefinitionName);
87400
88698
  if (found) {
87401
88699
  const token = found.getFirstToken();
87402
- ret = ret.concat(this.checkName(token, file, this.conf.expectedConstant));
88700
+ ret = ret.concat(this.checkName(token, file, this.conf.expectedConstant, this.regex.expectedConstant));
87403
88701
  }
87404
88702
  }
87405
88703
  return ret;
87406
88704
  }
87407
- checkName(token, file, expected) {
88705
+ checkName(token, file, expected, regex) {
87408
88706
  const ret = [];
87409
- const regex = new RegExp(expected, "i");
87410
88707
  const name = token.getStr();
87411
- if (name_validator_1.NameValidator.violatesRule(name, regex, this.conf)) {
88708
+ if (name_validator_1.NameValidator.violatesRule(name, regex, this.conf, this.regex.ignorePatterns)) {
87412
88709
  const message = this.getDescription(expected, name);
87413
88710
  const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity);
87414
88711
  ret.push(issue);
@@ -87483,6 +88780,7 @@ class MacroNaming extends _abap_rule_1.ABAPRule {
87483
88780
  constructor() {
87484
88781
  super(...arguments);
87485
88782
  this.conf = new MacroNamingConf();
88783
+ this.regex = new RegExp(this.conf.pattern, "i");
87486
88784
  }
87487
88785
  getMetadata() {
87488
88786
  return {
@@ -87502,10 +88800,10 @@ END-OF-DEFINITION.`,
87502
88800
  }
87503
88801
  setConfig(conf) {
87504
88802
  this.conf = conf;
88803
+ this.regex = new RegExp(this.conf.pattern, "i");
87505
88804
  }
87506
88805
  runParsed(file, obj) {
87507
88806
  const issues = [];
87508
- const testRegex = new RegExp(this.conf.pattern, "i");
87509
88807
  if (obj instanceof objects_1.TypePool) {
87510
88808
  return [];
87511
88809
  }
@@ -87518,7 +88816,7 @@ END-OF-DEFINITION.`,
87518
88816
  continue;
87519
88817
  }
87520
88818
  const token = expr.getFirstToken();
87521
- if (testRegex.exec(token.getStr())) {
88819
+ if (this.regex.exec(token.getStr())) {
87522
88820
  continue;
87523
88821
  }
87524
88822
  else {
@@ -88657,6 +89955,7 @@ exports.MethodParameterNamesConf = MethodParameterNamesConf;
88657
89955
  class MethodParameterNames {
88658
89956
  constructor() {
88659
89957
  this.conf = new MethodParameterNamesConf();
89958
+ this.regex = this.compile();
88660
89959
  }
88661
89960
  getMetadata() {
88662
89961
  return {
@@ -88682,6 +89981,16 @@ class MethodParameterNames {
88682
89981
  }
88683
89982
  setConfig(conf) {
88684
89983
  this.conf = conf;
89984
+ this.regex = this.compile();
89985
+ }
89986
+ compile() {
89987
+ return {
89988
+ importing: new RegExp(this.conf.importing, "i"),
89989
+ returning: new RegExp(this.conf.returning, "i"),
89990
+ changing: new RegExp(this.conf.changing, "i"),
89991
+ exporting: new RegExp(this.conf.exporting, "i"),
89992
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
89993
+ };
88685
89994
  }
88686
89995
  initialize(reg) {
88687
89996
  this.reg = reg;
@@ -88721,16 +90030,16 @@ class MethodParameterNames {
88721
90030
  for (const p of method.parameters) {
88722
90031
  switch (p.direction) {
88723
90032
  case _abap_file_information_1.MethodParameterDirection.Importing:
88724
- ret = ret.concat(this.checkParameter(p, this.conf.importing));
90033
+ ret = ret.concat(this.checkParameter(p, this.conf.importing, this.regex.importing));
88725
90034
  break;
88726
90035
  case _abap_file_information_1.MethodParameterDirection.Exporting:
88727
- ret = ret.concat(this.checkParameter(p, this.conf.exporting));
90036
+ ret = ret.concat(this.checkParameter(p, this.conf.exporting, this.regex.exporting));
88728
90037
  break;
88729
90038
  case _abap_file_information_1.MethodParameterDirection.Changing:
88730
- ret = ret.concat(this.checkParameter(p, this.conf.changing));
90039
+ ret = ret.concat(this.checkParameter(p, this.conf.changing, this.regex.changing));
88731
90040
  break;
88732
90041
  case _abap_file_information_1.MethodParameterDirection.Returning:
88733
- ret = ret.concat(this.checkParameter(p, this.conf.returning));
90042
+ ret = ret.concat(this.checkParameter(p, this.conf.returning, this.regex.returning));
88734
90043
  break;
88735
90044
  default:
88736
90045
  break;
@@ -88738,11 +90047,10 @@ class MethodParameterNames {
88738
90047
  }
88739
90048
  return ret;
88740
90049
  }
88741
- checkParameter(param, expected) {
90050
+ checkParameter(param, expected, regex) {
88742
90051
  const ret = [];
88743
- const regex = new RegExp(expected, "i");
88744
90052
  const name = param.name;
88745
- if (name_validator_1.NameValidator.violatesRule(name, regex, this.conf)) {
90053
+ if (name_validator_1.NameValidator.violatesRule(name, regex, this.conf, this.regex.ignorePatterns)) {
88746
90054
  const message = this.getDescription(expected, name);
88747
90055
  const issue = issue_1.Issue.atIdentifier(param.identifier, message, this.getMetadata().key, this.conf.severity);
88748
90056
  ret.push(issue);
@@ -88927,6 +90235,7 @@ exports.ModifyOnlyOwnDBTablesConf = ModifyOnlyOwnDBTablesConf;
88927
90235
  class ModifyOnlyOwnDBTables {
88928
90236
  constructor() {
88929
90237
  this.conf = new ModifyOnlyOwnDBTablesConf();
90238
+ this.ownTables = new RegExp(this.conf.ownTables, "i");
88930
90239
  }
88931
90240
  getMetadata() {
88932
90241
  return {
@@ -88944,6 +90253,7 @@ class ModifyOnlyOwnDBTables {
88944
90253
  }
88945
90254
  setConfig(conf) {
88946
90255
  this.conf = conf;
90256
+ this.ownTables = new RegExp(this.conf.ownTables, "i");
88947
90257
  }
88948
90258
  initialize(reg) {
88949
90259
  this.reg = reg;
@@ -88961,7 +90271,6 @@ class ModifyOnlyOwnDBTables {
88961
90271
  if (struc === undefined) {
88962
90272
  return [];
88963
90273
  }
88964
- const regExp = new RegExp(this.getConfig().ownTables, "i");
88965
90274
  for (const s of file.getStatements()) {
88966
90275
  const g = s.get();
88967
90276
  if (g instanceof Statements.DeleteDatabase
@@ -88979,7 +90288,7 @@ class ModifyOnlyOwnDBTables {
88979
90288
  continue;
88980
90289
  }
88981
90290
  const concat = databaseTable.concatTokens().toUpperCase();
88982
- if (regExp.test(concat) === false) {
90291
+ if (this.ownTables.test(concat) === false) {
88983
90292
  // must contain a ReferenceType.TableVoidReference or a ReferenceType.TableReference if its a dependency
88984
90293
  if (spaghetti === undefined) {
88985
90294
  spaghetti = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti;
@@ -90681,6 +91990,7 @@ class NoPrefixes extends _abap_rule_1.ABAPRule {
90681
91990
  constructor() {
90682
91991
  super(...arguments);
90683
91992
  this.conf = new NoPrefixesConf();
91993
+ this.regex = this.compile();
90684
91994
  }
90685
91995
  getMetadata() {
90686
91996
  return {
@@ -90704,6 +92014,18 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/sub-sections/AvoidEncodi
90704
92014
  }
90705
92015
  setConfig(conf) {
90706
92016
  this.conf = conf;
92017
+ this.regex = this.compile();
92018
+ }
92019
+ compile() {
92020
+ const compile = (pattern) => pattern !== undefined && pattern !== "" ? new RegExp(pattern, "i") : undefined;
92021
+ return {
92022
+ data: compile(this.conf.data),
92023
+ statics: compile(this.conf.statics),
92024
+ fieldSymbols: compile(this.conf.fieldSymbols),
92025
+ constants: compile(this.conf.constants),
92026
+ types: compile(this.conf.types),
92027
+ methodParameters: compile(this.conf.methodParameters),
92028
+ };
90707
92029
  }
90708
92030
  runParsed(file) {
90709
92031
  const ret = [];
@@ -90717,38 +92039,38 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/sub-sections/AvoidEncodi
90717
92039
  if (max === undefined || max < 1) {
90718
92040
  max = 10;
90719
92041
  }
90720
- if (config.data !== undefined && config.data !== "") {
90721
- ret.push(...this.checkData(structure, new RegExp(config.data, "i"), file));
92042
+ if (this.regex.data !== undefined) {
92043
+ ret.push(...this.checkData(structure, this.regex.data, file));
90722
92044
  }
90723
92045
  if (ret.length >= max) {
90724
92046
  return ret;
90725
92047
  }
90726
- if (config.statics !== undefined && config.statics !== "") {
90727
- ret.push(...this.checkStatics(structure, new RegExp(config.statics, "i"), file));
92048
+ if (this.regex.statics !== undefined) {
92049
+ ret.push(...this.checkStatics(structure, this.regex.statics, file));
90728
92050
  }
90729
92051
  if (ret.length >= max) {
90730
92052
  return ret;
90731
92053
  }
90732
- if (config.fieldSymbols !== undefined && config.fieldSymbols !== "") {
90733
- ret.push(...this.checkFieldSymbols(structure, new RegExp(config.fieldSymbols, "i"), file));
92054
+ if (this.regex.fieldSymbols !== undefined) {
92055
+ ret.push(...this.checkFieldSymbols(structure, this.regex.fieldSymbols, file));
90734
92056
  }
90735
92057
  if (ret.length >= max) {
90736
92058
  return ret;
90737
92059
  }
90738
- if (config.constants !== undefined && config.constants !== "") {
90739
- ret.push(...this.checkConstants(structure, new RegExp(config.constants, "i"), file));
92060
+ if (this.regex.constants !== undefined) {
92061
+ ret.push(...this.checkConstants(structure, this.regex.constants, file));
90740
92062
  }
90741
92063
  if (ret.length >= max) {
90742
92064
  return ret;
90743
92065
  }
90744
- if (config.types !== undefined && config.types !== "") {
90745
- ret.push(...this.checkTypes(structure, new RegExp(config.types, "i"), file));
92066
+ if (this.regex.types !== undefined) {
92067
+ ret.push(...this.checkTypes(structure, this.regex.types, file));
90746
92068
  }
90747
92069
  if (ret.length >= max) {
90748
92070
  return ret;
90749
92071
  }
90750
- if (config.methodParameters !== undefined && config.methodParameters !== "") {
90751
- ret.push(...this.checkMethodParameters(structure, new RegExp(config.methodParameters, "i"), file));
92072
+ if (this.regex.methodParameters !== undefined) {
92073
+ ret.push(...this.checkMethodParameters(structure, this.regex.methodParameters, file));
90752
92074
  }
90753
92075
  return ret;
90754
92076
  }
@@ -91303,6 +92625,7 @@ exports.ObjectNamingConf = ObjectNamingConf;
91303
92625
  class ObjectNaming {
91304
92626
  constructor() {
91305
92627
  this.conf = new ObjectNamingConf();
92628
+ this.regex = this.compile();
91306
92629
  }
91307
92630
  getMetadata() {
91308
92631
  return {
@@ -91325,6 +92648,20 @@ class ObjectNaming {
91325
92648
  }
91326
92649
  setConfig(conf) {
91327
92650
  this.conf = conf;
92651
+ this.regex = this.compile();
92652
+ }
92653
+ compile() {
92654
+ const config = this.getConfig();
92655
+ const patterns = new Map();
92656
+ for (const [key, value] of Object.entries(config)) {
92657
+ if (typeof value === "string" && key !== "patternKind" && key !== "severity") {
92658
+ patterns.set(key, new RegExp(value, "i"));
92659
+ }
92660
+ }
92661
+ return {
92662
+ patterns,
92663
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(config),
92664
+ };
91328
92665
  }
91329
92666
  initialize(_reg) {
91330
92667
  return this;
@@ -91338,11 +92675,11 @@ class ObjectNaming {
91338
92675
  const config = this.getConfig();
91339
92676
  // @ts-ignore
91340
92677
  const pattern = config[abapType];
91341
- if (pattern === undefined) {
92678
+ const regex = this.regex.patterns.get(abapType);
92679
+ if (pattern === undefined || regex === undefined) {
91342
92680
  return [];
91343
92681
  }
91344
- const regex = new RegExp(pattern, "i");
91345
- if (name_validator_1.NameValidator.violatesRule(obj.getName(), regex, this.conf)) {
92682
+ if (name_validator_1.NameValidator.violatesRule(obj.getName(), regex, this.conf, this.regex.ignorePatterns)) {
91346
92683
  message = this.getDescription(pattern, obj.getName());
91347
92684
  }
91348
92685
  if (message) {
@@ -93788,6 +95125,292 @@ exports.PreferInline = PreferInline;
93788
95125
 
93789
95126
  /***/ },
93790
95127
 
95128
+ /***/ "../core/build/src/rules/prefer_inline_cast.js"
95129
+ /*!*****************************************************!*\
95130
+ !*** ../core/build/src/rules/prefer_inline_cast.js ***!
95131
+ \*****************************************************/
95132
+ (__unused_webpack_module, exports, __webpack_require__) {
95133
+
95134
+ "use strict";
95135
+
95136
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
95137
+ if (k2 === undefined) k2 = k;
95138
+ var desc = Object.getOwnPropertyDescriptor(m, k);
95139
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
95140
+ desc = { enumerable: true, get: function() { return m[k]; } };
95141
+ }
95142
+ Object.defineProperty(o, k2, desc);
95143
+ }) : (function(o, m, k, k2) {
95144
+ if (k2 === undefined) k2 = k;
95145
+ o[k2] = m[k];
95146
+ }));
95147
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
95148
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
95149
+ }) : function(o, v) {
95150
+ o["default"] = v;
95151
+ });
95152
+ var __importStar = (this && this.__importStar) || (function () {
95153
+ var ownKeys = function(o) {
95154
+ ownKeys = Object.getOwnPropertyNames || function (o) {
95155
+ var ar = [];
95156
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
95157
+ return ar;
95158
+ };
95159
+ return ownKeys(o);
95160
+ };
95161
+ return function (mod) {
95162
+ if (mod && mod.__esModule) return mod;
95163
+ var result = {};
95164
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
95165
+ __setModuleDefault(result, mod);
95166
+ return result;
95167
+ };
95168
+ })();
95169
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
95170
+ exports.PreferInlineCast = exports.PreferInlineCastConf = void 0;
95171
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
95172
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
95173
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
95174
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
95175
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
95176
+ const _identifier_1 = __webpack_require__(/*! ../abap/4_file_information/_identifier */ "../core/build/src/abap/4_file_information/_identifier.js");
95177
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
95178
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
95179
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
95180
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
95181
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
95182
+ const version_1 = __webpack_require__(/*! ../version */ "../core/build/src/version.js");
95183
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
95184
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
95185
+ class PreferInlineCastConf extends _basic_rule_config_1.BasicRuleConfig {
95186
+ }
95187
+ exports.PreferInlineCastConf = PreferInlineCastConf;
95188
+ class PreferInlineCast {
95189
+ constructor() {
95190
+ this.conf = new PreferInlineCastConf();
95191
+ }
95192
+ getMetadata() {
95193
+ return {
95194
+ key: "prefer_inline_cast",
95195
+ title: "Prefer Inline CAST",
95196
+ shortDescription: `Inline a CAST helper read only once in the next statement`,
95197
+ extendedInformation: `Requires 7.40 SP02 or above, or ABAP Cloud, and no syntax errors.
95198
+
95199
+ Reports DATA(t) = CAST type( source ) when the helper has exactly one read and no other access,
95200
+ except its declaration write, in the entire syntax scope (including earlier reads in loop bodies and exception handlers).
95201
+ The immediately following statement must be a plain assignment, an attribute read, a receiver method call,
95202
+ or a named IMPORTING argument of a functional method call (caller syntax p = t).
95203
+
95204
+ Only class/interface CAST targets, simple assignment targets and static access are supported.
95205
+ For argument uses, the CAST operand must be a plain field chain without calls, the receiver and all
95206
+ other arguments must be plain variables or literals, and the method signature must be known.
95207
+ Explicit EXPORTING, IMPORTING and CHANGING sections are not supported.
95208
+ Objects containing macros or dynamic access are skipped. Field symbols, reference-taking,
95209
+ pragmas and chained statements are not supported.
95210
+
95211
+ Predicates such as IS INITIAL / IS BOUND and removal of statically redundant CASTs are left for a future version.`,
95212
+ tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
95213
+ badExample: `DATA(helper) = CAST lcl_node( object ).
95214
+ result = helper->get_tokens( ).`,
95215
+ goodExample: `result = CAST lcl_node( object )->get_tokens( ).`,
95216
+ };
95217
+ }
95218
+ getConfig() {
95219
+ return this.conf;
95220
+ }
95221
+ setConfig(conf) {
95222
+ this.conf = conf;
95223
+ }
95224
+ initialize(reg) {
95225
+ this.reg = reg;
95226
+ return this;
95227
+ }
95228
+ run(obj) {
95229
+ var _a;
95230
+ if (!(obj instanceof _abap_object_1.ABAPObject)
95231
+ || (!(0, version_1.releaseAtLeast)(this.reg.getConfig().getRelease(), version_1.Release.v740sp02)
95232
+ && this.reg.getConfig().getLanguageVersion() !== version_1.LanguageVersion.Cloud)) {
95233
+ return [];
95234
+ }
95235
+ // Neither macro expansion nor a dynamically named variable has reliable references.
95236
+ let hasCast = false;
95237
+ for (const file of obj.getABAPFiles()) {
95238
+ for (const statement of file.getStatements()) {
95239
+ hasCast || (hasCast = statement.findFirstExpression(Expressions.Cast) !== undefined);
95240
+ const type = statement.get();
95241
+ if (type instanceof _statement_1.Unknown || type instanceof Statements.Define
95242
+ || type instanceof _statement_1.MacroCall || type instanceof _statement_1.MacroContent || type instanceof _statement_1.MacroRecursion
95243
+ || statement.findFirstExpression(Expressions.Dynamic) !== undefined) {
95244
+ return [];
95245
+ }
95246
+ }
95247
+ }
95248
+ if (!hasCast) {
95249
+ return [];
95250
+ }
95251
+ const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
95252
+ if (syntax.issues.length > 0) {
95253
+ return [];
95254
+ }
95255
+ const references = new Map();
95256
+ const knownMethods = new Set();
95257
+ for (const reference of this.references(syntax.spaghetti.getTop())) {
95258
+ if (reference.resolved === undefined) {
95259
+ continue;
95260
+ }
95261
+ const key = this.identifierKey(reference.resolved);
95262
+ const uses = references.get(key) || [];
95263
+ uses.push(reference);
95264
+ references.set(key, uses);
95265
+ if (reference.referenceType === _reference_1.ReferenceType.MethodReference) {
95266
+ knownMethods.add(this.identifierKey(reference.position));
95267
+ }
95268
+ }
95269
+ const issues = [];
95270
+ for (const file of obj.getABAPFiles()) {
95271
+ const statements = file.getStatements();
95272
+ for (let index = 0; index < statements.length - 1; index++) {
95273
+ const declaration = statements[index];
95274
+ const next = statements[index + 1];
95275
+ const cast = this.castDeclaration(declaration);
95276
+ const inline = declaration.findFirstExpression(Expressions.InlineData);
95277
+ const name = (_a = inline === null || inline === void 0 ? void 0 : inline.findDirectExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
95278
+ if (cast === undefined || name === undefined) {
95279
+ continue;
95280
+ }
95281
+ const scope = syntax.spaghetti.lookupPosition(name.getStart(), file.getFilename());
95282
+ const identifier = scope === null || scope === void 0 ? void 0 : scope.findVariable(name.getStr());
95283
+ if (!(identifier instanceof _typed_identifier_1.TypedIdentifier) || !(identifier.getType() instanceof basic_1.ObjectReferenceType)
95284
+ || identifier.getType().containsVoid()
95285
+ || identifier.getType().isGeneric()) {
95286
+ continue;
95287
+ }
95288
+ const uses = references.get(this.identifierKey(identifier)) || [];
95289
+ const reads = uses.filter(r => r.referenceType === _reference_1.ReferenceType.DataReadReference);
95290
+ const writes = uses.filter(r => r.referenceType === _reference_1.ReferenceType.DataWriteReference);
95291
+ if (reads.length !== 1 || writes.length !== 1
95292
+ || !declaration.includesToken(writes[0].position.getToken())
95293
+ || uses.length !== 2 || !next.includesToken(reads[0].position.getToken())
95294
+ || !this.supportedUse(next, reads[0].position, knownMethods, cast)) {
95295
+ continue;
95296
+ }
95297
+ // Replace the later occurrence first, also when both statements are on the same line.
95298
+ const fix = edit_helper_1.EditHelper.merge(edit_helper_1.EditHelper.replaceToken(file, reads[0].position.getToken(), cast.concatTokensWithLinebreaks()), edit_helper_1.EditHelper.deleteStatement(file, declaration));
95299
+ issues.push(issue_1.Issue.atToken(file, name, "Inline single-use CAST helper", this.getMetadata().key, this.conf.severity, fix));
95300
+ }
95301
+ }
95302
+ return issues;
95303
+ }
95304
+ identifierKey(identifier) {
95305
+ const start = identifier.getStart();
95306
+ return identifier.getFilename() + "," + start.getRow() + "," + start.getCol();
95307
+ }
95308
+ references(node) {
95309
+ return node.getData().references.concat(...node.getChildren().map(child => this.references(child)));
95310
+ }
95311
+ castDeclaration(statement) {
95312
+ var _a;
95313
+ if (!(statement.get() instanceof Statements.Move) || statement.getColon() !== undefined
95314
+ || statement.getPragmas().length > 0) {
95315
+ return undefined;
95316
+ }
95317
+ const target = statement.findDirectExpression(Expressions.Target);
95318
+ const source = statement.findDirectExpression(Expressions.Source);
95319
+ const chain = source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.MethodCallChain);
95320
+ const cast = chain === null || chain === void 0 ? void 0 : chain.findDirectExpression(Expressions.Cast);
95321
+ if ((target === null || target === void 0 ? void 0 : target.getChildren().length) !== 1 || target.findDirectExpression(Expressions.InlineData) === undefined
95322
+ || (source === null || source === void 0 ? void 0 : source.getChildren().length) !== 1 || (chain === null || chain === void 0 ? void 0 : chain.getChildren().length) !== 1
95323
+ || cast === undefined || cast.findDirectExpression(Expressions.Let) !== undefined
95324
+ || cast.findDirectExpression(Expressions.Dereference) !== undefined
95325
+ || ((_a = cast.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === "#"
95326
+ || statement.findFirstExpression(Expressions.SourceFieldSymbol) !== undefined
95327
+ || statement.getTokens().length !== target.countTokens() + source.countTokens() + 2
95328
+ || statement.getTokens()[target.countTokens()].getStr() !== "=") {
95329
+ return undefined;
95330
+ }
95331
+ return cast;
95332
+ }
95333
+ supportedUse(statement, read, knownMethods, cast) {
95334
+ var _a, _b, _c;
95335
+ if (statement.getColon() !== undefined || statement.getPragmas().length > 0
95336
+ || statement.findFirstExpression(Expressions.SourceFieldSymbol) !== undefined
95337
+ || statement.findFirstExpression(Expressions.MethodParameters) !== undefined) {
95338
+ return false;
95339
+ }
95340
+ let chain;
95341
+ if (statement.get() instanceof Statements.Move) {
95342
+ const target = statement.findDirectExpression(Expressions.Target);
95343
+ const source = statement.findDirectExpression(Expressions.Source);
95344
+ if (target === undefined || source === undefined || !this.simpleTarget(target)
95345
+ || statement.getTokens().length !== target.countTokens() + source.countTokens() + 2
95346
+ || statement.getTokens()[target.countTokens()].getStr() !== "="
95347
+ || source.getChildren().length !== 1) {
95348
+ return false;
95349
+ }
95350
+ const field = source.findDirectExpression(Expressions.FieldChain);
95351
+ if (field !== undefined) {
95352
+ const tokens = field.getTokens();
95353
+ return field.getFirstToken().getStart().equals(read.getStart())
95354
+ && (tokens.length === 1 || (tokens.length === 3 && tokens[1].getStr() === "->"
95355
+ && field.findDirectExpression(Expressions.AttributeName) !== undefined));
95356
+ }
95357
+ chain = source.findDirectExpression(Expressions.MethodCallChain);
95358
+ }
95359
+ else if (statement.get() instanceof Statements.Call) {
95360
+ chain = statement.findDirectExpression(Expressions.MethodCallChain);
95361
+ }
95362
+ if (chain === undefined) {
95363
+ return false;
95364
+ }
95365
+ const calls = chain.findDirectExpressions(Expressions.MethodCall);
95366
+ const receiver = chain.findDirectExpression(Expressions.FieldChain);
95367
+ if (calls.length !== 1 || (chain.getChildren().length !== 1 && chain.getChildren().length !== 3)
95368
+ || (receiver !== undefined && receiver.countTokens() !== 1)) {
95369
+ return false;
95370
+ }
95371
+ if (receiver === null || receiver === void 0 ? void 0 : receiver.getFirstToken().getStart().equals(read.getStart())) {
95372
+ // The receiver is evaluated first; even calls in its arguments stay after the CAST.
95373
+ return true;
95374
+ }
95375
+ // Named argument uses are limited to functional calls with a known signature.
95376
+ const method = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
95377
+ if (!(statement.get() instanceof Statements.Move) || method === undefined
95378
+ || !this.plainCastOperand(cast)
95379
+ || !knownMethods.has(this.identifierKey(new _identifier_1.Identifier(method, read.getFilename())))) {
95380
+ return false;
95381
+ }
95382
+ const parameters = (_c = (_b = calls[0].findDirectExpression(Expressions.MethodCallParam)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.ParameterListS)) === null || _c === void 0 ? void 0 : _c.findDirectExpressions(Expressions.ParameterS);
95383
+ return parameters !== undefined && parameters.some(p => { var _a; return (_a = p.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStart().equals(read.getStart()); })
95384
+ && parameters.every(p => this.plainSource(p.findDirectExpression(Expressions.Source)));
95385
+ }
95386
+ plainCastOperand(cast) {
95387
+ // Unlike receiver uses, argument uses can evaluate the receiver before the CAST operand.
95388
+ // Exclude calls, table expressions and computed offsets/lengths from the field chain.
95389
+ const source = cast.findDirectExpression(Expressions.Source);
95390
+ const field = source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.FieldChain);
95391
+ return (source === null || source === void 0 ? void 0 : source.getChildren().length) === 1 && field !== undefined
95392
+ && field.findFirstExpression(Expressions.MethodCall) === undefined
95393
+ && field.findFirstExpression(Expressions.TableExpression) === undefined
95394
+ && field.findFirstExpression(Expressions.FieldOffset) === undefined
95395
+ && field.findFirstExpression(Expressions.FieldLength) === undefined;
95396
+ }
95397
+ simpleTarget(target) {
95398
+ return target.countTokens() === 1 && target.findDirectExpression(Expressions.TargetField) !== undefined
95399
+ || target.getChildren().length === 1 && target.findDirectExpression(Expressions.InlineData) !== undefined;
95400
+ }
95401
+ plainSource(source) {
95402
+ if ((source === null || source === void 0 ? void 0 : source.getChildren().length) !== 1) {
95403
+ return false;
95404
+ }
95405
+ return source.findDirectExpression(Expressions.Constant) !== undefined
95406
+ || source.countTokens() === 1 && source.findDirectExpression(Expressions.FieldChain) !== undefined;
95407
+ }
95408
+ }
95409
+ exports.PreferInlineCast = PreferInlineCast;
95410
+ //# sourceMappingURL=prefer_inline_cast.js.map
95411
+
95412
+ /***/ },
95413
+
93791
95414
  /***/ "../core/build/src/rules/prefer_insert_into_table.js"
93792
95415
  /*!***********************************************************!*\
93793
95416
  !*** ../core/build/src/rules/prefer_insert_into_table.js ***!
@@ -95150,6 +96773,216 @@ exports.PrefixIsCurrentClass = PrefixIsCurrentClass;
95150
96773
 
95151
96774
  /***/ },
95152
96775
 
96776
+ /***/ "../core/build/src/rules/range_row_values.js"
96777
+ /*!***************************************************!*\
96778
+ !*** ../core/build/src/rules/range_row_values.js ***!
96779
+ \***************************************************/
96780
+ (__unused_webpack_module, exports, __webpack_require__) {
96781
+
96782
+ "use strict";
96783
+
96784
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
96785
+ if (k2 === undefined) k2 = k;
96786
+ var desc = Object.getOwnPropertyDescriptor(m, k);
96787
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
96788
+ desc = { enumerable: true, get: function() { return m[k]; } };
96789
+ }
96790
+ Object.defineProperty(o, k2, desc);
96791
+ }) : (function(o, m, k, k2) {
96792
+ if (k2 === undefined) k2 = k;
96793
+ o[k2] = m[k];
96794
+ }));
96795
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
96796
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
96797
+ }) : function(o, v) {
96798
+ o["default"] = v;
96799
+ });
96800
+ var __importStar = (this && this.__importStar) || (function () {
96801
+ var ownKeys = function(o) {
96802
+ ownKeys = Object.getOwnPropertyNames || function (o) {
96803
+ var ar = [];
96804
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
96805
+ return ar;
96806
+ };
96807
+ return ownKeys(o);
96808
+ };
96809
+ return function (mod) {
96810
+ if (mod && mod.__esModule) return mod;
96811
+ var result = {};
96812
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
96813
+ __setModuleDefault(result, mod);
96814
+ return result;
96815
+ };
96816
+ })();
96817
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
96818
+ exports.RangeRowValues = exports.RangeRowValuesConf = void 0;
96819
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
96820
+ const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
96821
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
96822
+ const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
96823
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
96824
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
96825
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
96826
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
96827
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
96828
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
96829
+ const RANGE_COMPONENTS = ["SIGN", "OPTION", "LOW", "HIGH"];
96830
+ const SIGNS = ["I", "E"];
96831
+ const OPTIONS = ["EQ", "NE", "BT", "NB", "CP", "NP", "GT", "GE", "LT", "LE"];
96832
+ class RangeRowValuesConf extends _basic_rule_config_1.BasicRuleConfig {
96833
+ }
96834
+ exports.RangeRowValuesConf = RangeRowValuesConf;
96835
+ class RangeRowValues {
96836
+ constructor() {
96837
+ this.conf = new RangeRowValuesConf();
96838
+ }
96839
+ getMetadata() {
96840
+ return {
96841
+ key: "range_row_values",
96842
+ title: "Range row values",
96843
+ shortDescription: `Checks the SIGN and OPTION of range rows built with VALUE`,
96844
+ extendedInformation: `A row of a range table, ie. a structure with exactly the components SIGN, OPTION, LOW and HIGH,
96845
+ is a selection structure to the syntax check. For a VALUE row of one, the system warns when SIGN or OPTION
96846
+ is missing, and when a literal is not a permitted value: SIGN must be I or E, OPTION one of
96847
+ EQ NE BT NB CP NP GT GE LT LE, in upper case.
96848
+
96849
+ Components given in the VALUE header count for the rows that follow, eg. VALUE #( sign = 'I' option = 'EQ' ( low = 1 ) ).
96850
+ Only literals are checked, a value from a variable, constant or expression is not.`,
96851
+ tags: [_irule_1.RuleTag.Syntax],
96852
+ badExample: `TYPES ty_range TYPE RANGE OF string.
96853
+ DATA(range) = VALUE ty_range( ( sign = 'I' option = 'eq' low = \`a\` )
96854
+ ( sign = 'I' low = \`b\` ) ).`,
96855
+ goodExample: `TYPES ty_range TYPE RANGE OF string.
96856
+ DATA(range) = VALUE ty_range( ( sign = 'I' option = 'EQ' low = \`a\` )
96857
+ ( sign = 'I' option = 'EQ' low = \`b\` ) ).`,
96858
+ };
96859
+ }
96860
+ getConfig() {
96861
+ return this.conf;
96862
+ }
96863
+ setConfig(conf) {
96864
+ this.conf = conf;
96865
+ }
96866
+ initialize(reg) {
96867
+ this.reg = reg;
96868
+ return this;
96869
+ }
96870
+ run(obj) {
96871
+ var _a, _b, _c;
96872
+ if (!(obj instanceof _abap_object_1.ABAPObject)) {
96873
+ return [];
96874
+ }
96875
+ const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
96876
+ if (syntax.issues.length > 0) {
96877
+ return [];
96878
+ }
96879
+ const issues = [];
96880
+ for (const file of obj.getABAPFiles()) {
96881
+ for (const source of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressionsRecursive(Expressions.Source)) || []) {
96882
+ if (source.getFirstToken().getStr().toUpperCase() !== "VALUE") {
96883
+ continue;
96884
+ }
96885
+ const typeToken = (_b = source.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
96886
+ const body = source.findDirectExpression(Expressions.ValueBody);
96887
+ if (typeToken === undefined || body === undefined) {
96888
+ continue;
96889
+ }
96890
+ const scope = syntax.spaghetti.lookupPosition(typeToken.getStart(), file.getFilename());
96891
+ const resolved = (_c = scope === null || scope === void 0 ? void 0 : scope.getData().references.find(r => r.referenceType === _reference_1.ReferenceType.InferredType
96892
+ && r.position.getStart().equals(typeToken.getStart()))) === null || _c === void 0 ? void 0 : _c.resolved;
96893
+ if (!(resolved instanceof _typed_identifier_1.TypedIdentifier)) {
96894
+ continue;
96895
+ }
96896
+ const type = resolved.getType();
96897
+ if (type instanceof basic_1.TableType && this.isRangeRow(type.getRowType())) {
96898
+ const header = new Map();
96899
+ for (const child of body.getChildren()) {
96900
+ if (!(child instanceof nodes_1.ExpressionNode)) {
96901
+ continue;
96902
+ }
96903
+ else if (child.get() instanceof Expressions.FieldAssignment) {
96904
+ this.addAssignment(header, child);
96905
+ }
96906
+ else if (child.get() instanceof Expressions.ValueBodyLine) {
96907
+ const assignments = child.findDirectExpressions(Expressions.FieldAssignment);
96908
+ if (assignments.length === 0) {
96909
+ continue;
96910
+ }
96911
+ const row = new Map(header);
96912
+ for (const a of assignments) {
96913
+ this.addAssignment(row, a);
96914
+ }
96915
+ issues.push(...this.checkRow(file, child, row));
96916
+ }
96917
+ }
96918
+ }
96919
+ else if (this.isRangeRow(type) && body.findDirectExpression(Expressions.ValueBase) === undefined) {
96920
+ const assignments = body.findDirectExpressions(Expressions.FieldAssignment);
96921
+ if (assignments.length === 0) {
96922
+ continue;
96923
+ }
96924
+ const row = new Map();
96925
+ for (const a of assignments) {
96926
+ this.addAssignment(row, a);
96927
+ }
96928
+ issues.push(...this.checkRow(file, body, row));
96929
+ }
96930
+ }
96931
+ }
96932
+ return issues;
96933
+ }
96934
+ ////////////////
96935
+ isRangeRow(type) {
96936
+ if (!(type instanceof basic_1.StructureType)) {
96937
+ return false;
96938
+ }
96939
+ const names = type.getComponents().map(c => c.name.toUpperCase());
96940
+ return names.length === RANGE_COMPONENTS.length && RANGE_COMPONENTS.every(c => names.includes(c));
96941
+ }
96942
+ addAssignment(row, assignment) {
96943
+ var _a;
96944
+ const name = (_a = assignment.findDirectExpression(Expressions.FieldSub)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
96945
+ const source = assignment.findDirectExpression(Expressions.Source);
96946
+ if (name && source) {
96947
+ row.set(name, source);
96948
+ }
96949
+ }
96950
+ checkRow(file, node, row) {
96951
+ const issues = [];
96952
+ for (const [component, allowed] of [["SIGN", SIGNS], ["OPTION", OPTIONS]]) {
96953
+ const source = row.get(component);
96954
+ if (source === undefined) {
96955
+ const message = `Specification ${component} is missing in the range row`;
96956
+ issues.push(issue_1.Issue.atToken(file, node.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
96957
+ continue;
96958
+ }
96959
+ const value = this.literal(source);
96960
+ if (value !== undefined && !allowed.includes(value)) {
96961
+ const message = `"${value}" is not a permitted value for ${component}, expected ${allowed.join(" ")}`;
96962
+ issues.push(issue_1.Issue.atToken(file, source.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
96963
+ }
96964
+ }
96965
+ return issues;
96966
+ }
96967
+ /** The content of a character literal, undefined for anything else */
96968
+ literal(source) {
96969
+ var _a, _b;
96970
+ if (source.getChildren().length !== 1) {
96971
+ return undefined;
96972
+ }
96973
+ const str = (_b = (_a = source.findDirectExpression(Expressions.Constant)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.ConstantString)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
96974
+ if (str === undefined) {
96975
+ return undefined;
96976
+ }
96977
+ const quote = str.charAt(0);
96978
+ return str.slice(1, -1).split(quote + quote).join(quote);
96979
+ }
96980
+ }
96981
+ exports.RangeRowValues = RangeRowValues;
96982
+ //# sourceMappingURL=range_row_values.js.map
96983
+
96984
+ /***/ },
96985
+
95153
96986
  /***/ "../core/build/src/rules/reduce_procedural_code.js"
95154
96987
  /*!*********************************************************!*\
95155
96988
  !*** ../core/build/src/rules/reduce_procedural_code.js ***!
@@ -96661,6 +98494,7 @@ class SelectionScreenNaming extends _abap_rule_1.ABAPRule {
96661
98494
  constructor() {
96662
98495
  super(...arguments);
96663
98496
  this.conf = new SelectionScreenNamingConf();
98497
+ this.regex = this.compile();
96664
98498
  }
96665
98499
  getMetadata() {
96666
98500
  return {
@@ -96680,6 +98514,15 @@ class SelectionScreenNaming extends _abap_rule_1.ABAPRule {
96680
98514
  }
96681
98515
  setConfig(conf) {
96682
98516
  this.conf = conf;
98517
+ this.regex = this.compile();
98518
+ }
98519
+ compile() {
98520
+ return {
98521
+ parameter: new RegExp(this.conf.parameter, "i"),
98522
+ selectOption: new RegExp(this.conf.selectOption, "i"),
98523
+ screenElement: new RegExp(this.conf.screenElement, "i"),
98524
+ ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
98525
+ };
96683
98526
  }
96684
98527
  runParsed(file) {
96685
98528
  const issues = [];
@@ -96703,8 +98546,8 @@ class SelectionScreenNaming extends _abap_rule_1.ABAPRule {
96703
98546
  || (stat.get() instanceof statements_1.SelectOption && !selectOptionDisabled)
96704
98547
  || (stat.get() instanceof statements_1.SelectionScreen && !screenElementDisabled)) {
96705
98548
  const fieldNode = this.getFieldForStatementNode(stat);
96706
- const regex = new RegExp(this.getPatternForStatement(stat.get()), "i");
96707
- if (fieldNode && name_validator_1.NameValidator.violatesRule(fieldNode.getFirstToken().getStr(), regex, this.conf)) {
98549
+ const regex = this.getRegexForStatement(stat.get());
98550
+ if (fieldNode && name_validator_1.NameValidator.violatesRule(fieldNode.getFirstToken().getStr(), regex, this.conf, this.regex.ignorePatterns)) {
96708
98551
  issues.push(issue_1.Issue.atToken(file, fieldNode.getFirstToken(), this.getDescription(this.getPatternForStatement(stat.get()), fieldNode.getFirstToken().getStr()), this.getMetadata().key, this.conf.severity));
96709
98552
  }
96710
98553
  }
@@ -96724,6 +98567,15 @@ class SelectionScreenNaming extends _abap_rule_1.ABAPRule {
96724
98567
  }
96725
98568
  return pattern;
96726
98569
  }
98570
+ getRegexForStatement(statement) {
98571
+ if (statement instanceof statements_1.Parameter) {
98572
+ return this.regex.parameter;
98573
+ }
98574
+ else if (statement instanceof statements_1.SelectOption) {
98575
+ return this.regex.selectOption;
98576
+ }
98577
+ return this.regex.screenElement;
98578
+ }
96727
98579
  getFieldForStatementNode(statNode) {
96728
98580
  if (statNode.get() instanceof statements_1.Parameter) {
96729
98581
  return statNode.findFirstExpression(expressions_1.FieldSub);
@@ -97126,8 +98978,7 @@ class SICFConsistency {
97126
98978
  if (this.conf.skipNames && this.conf.skipNames.some((a) => a.toUpperCase() === h.toUpperCase())) {
97127
98979
  continue;
97128
98980
  }
97129
- const pattern = new RegExp(this.reg.getConfig().getSyntaxSetttings().errorNamespace, "i");
97130
- if (pattern.test(h) === true) {
98981
+ if (this.reg.inErrorNamespace(h) === true) {
97131
98982
  const message = "Handler class " + h + " not found";
97132
98983
  const issue = issue_1.Issue.atPosition(obj.getFiles()[0], new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity);
97133
98984
  issues.push(issue);
@@ -97390,6 +99241,204 @@ exports.SMIMConsistency = SMIMConsistency;
97390
99241
 
97391
99242
  /***/ },
97392
99243
 
99244
+ /***/ "../core/build/src/rules/sort_empty_key.js"
99245
+ /*!*************************************************!*\
99246
+ !*** ../core/build/src/rules/sort_empty_key.js ***!
99247
+ \*************************************************/
99248
+ (__unused_webpack_module, exports, __webpack_require__) {
99249
+
99250
+ "use strict";
99251
+
99252
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
99253
+ if (k2 === undefined) k2 = k;
99254
+ var desc = Object.getOwnPropertyDescriptor(m, k);
99255
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
99256
+ desc = { enumerable: true, get: function() { return m[k]; } };
99257
+ }
99258
+ Object.defineProperty(o, k2, desc);
99259
+ }) : (function(o, m, k, k2) {
99260
+ if (k2 === undefined) k2 = k;
99261
+ o[k2] = m[k];
99262
+ }));
99263
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
99264
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
99265
+ }) : function(o, v) {
99266
+ o["default"] = v;
99267
+ });
99268
+ var __importStar = (this && this.__importStar) || (function () {
99269
+ var ownKeys = function(o) {
99270
+ ownKeys = Object.getOwnPropertyNames || function (o) {
99271
+ var ar = [];
99272
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
99273
+ return ar;
99274
+ };
99275
+ return ownKeys(o);
99276
+ };
99277
+ return function (mod) {
99278
+ if (mod && mod.__esModule) return mod;
99279
+ var result = {};
99280
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
99281
+ __setModuleDefault(result, mod);
99282
+ return result;
99283
+ };
99284
+ })();
99285
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
99286
+ exports.SortEmptyKey = exports.SortEmptyKeyConf = void 0;
99287
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
99288
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
99289
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
99290
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
99291
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
99292
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
99293
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
99294
+ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
99295
+ const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
99296
+ const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
99297
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
99298
+ class SortEmptyKeyConf extends _basic_rule_config_1.BasicRuleConfig {
99299
+ }
99300
+ exports.SortEmptyKeyConf = SortEmptyKeyConf;
99301
+ class SortEmptyKey {
99302
+ constructor() {
99303
+ this.conf = new SortEmptyKeyConf();
99304
+ }
99305
+ getMetadata() {
99306
+ return {
99307
+ key: "sort_empty_key",
99308
+ title: "SORT or DELETE ADJACENT DUPLICATES on a table with an empty key",
99309
+ shortDescription: `SORT without BY and DELETE ADJACENT DUPLICATES without COMPARING on a table with an empty primary key`,
99310
+ extendedInformation: `Without BY or COMPARING, both statements use the primary key of the table. For a table
99311
+ declared WITH EMPTY KEY there is nothing to sort or compare by, SORT does nothing.
99312
+
99313
+ The syntax check warns: "ITAB is a table with an empty primary key. Check the semantics of the statement."
99314
+
99315
+ Sorted and hashed tables, tables with a default or explicit key, and tables of unknown or generic type are not reported.
99316
+
99317
+ The quick fix adds BY table_line or COMPARING table_line, for tables with an elementary row type.`,
99318
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
99319
+ badExample: `DATA result TYPE STANDARD TABLE OF string WITH EMPTY KEY.
99320
+ SORT result.
99321
+ DELETE ADJACENT DUPLICATES FROM result.`,
99322
+ goodExample: `DATA result TYPE STANDARD TABLE OF string WITH EMPTY KEY.
99323
+ SORT result BY table_line.
99324
+ DELETE ADJACENT DUPLICATES FROM result COMPARING table_line.`,
99325
+ };
99326
+ }
99327
+ getConfig() {
99328
+ return this.conf;
99329
+ }
99330
+ initialize(reg) {
99331
+ this.reg = reg;
99332
+ return this;
99333
+ }
99334
+ setConfig(conf) {
99335
+ this.conf = conf;
99336
+ }
99337
+ run(obj) {
99338
+ if (!(obj instanceof _abap_object_1.ABAPObject) || obj.getType() === "INTF") {
99339
+ return [];
99340
+ }
99341
+ const issues = [];
99342
+ let spaghetti = undefined;
99343
+ for (const file of obj.getABAPFiles()) {
99344
+ for (const statement of file.getStatements()) {
99345
+ let addition;
99346
+ if (statement.get() instanceof Statements.Sort) {
99347
+ if (statement.findDirectTokenByText("BY") !== undefined) {
99348
+ continue;
99349
+ }
99350
+ addition = "BY";
99351
+ }
99352
+ else if (statement.get() instanceof Statements.DeleteInternal) {
99353
+ if (statement.findDirectTokenByText("ADJACENT") === undefined
99354
+ || statement.findDirectTokenByText("COMPARING") !== undefined
99355
+ || statement.findDirectTokenByText("USING") !== undefined) {
99356
+ continue;
99357
+ }
99358
+ addition = "COMPARING";
99359
+ }
99360
+ else {
99361
+ continue;
99362
+ }
99363
+ const target = statement.findDirectExpression(Expressions.Target);
99364
+ if (target === undefined) {
99365
+ continue;
99366
+ }
99367
+ if (spaghetti === undefined) {
99368
+ spaghetti = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti;
99369
+ }
99370
+ const type = this.findType(target, spaghetti, file);
99371
+ if (!(type instanceof basic_1.TableType)
99372
+ || type.getOptions().keyType !== basic_1.TableKeyType.empty
99373
+ || type.isGeneric()
99374
+ || (type.getAccessType() !== undefined && type.getAccessType() !== basic_1.TableAccessType.standard)) {
99375
+ continue;
99376
+ }
99377
+ const verb = addition === "BY" ? "SORT without BY" : "DELETE ADJACENT DUPLICATES without COMPARING";
99378
+ const message = `${verb} on "${target.concatTokens()}", a table with an empty primary key`;
99379
+ const fix = this.buildFix(file, statement, type.getRowType(), addition);
99380
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity, fix));
99381
+ }
99382
+ }
99383
+ return issues;
99384
+ }
99385
+ ////////////////
99386
+ /** The type of a target built from names, components and attributes only, else undefined */
99387
+ findType(target, spaghetti, file) {
99388
+ var _a;
99389
+ let type = undefined;
99390
+ for (const child of target.getChildren()) {
99391
+ const get = child.get();
99392
+ if (get instanceof Expressions.TargetField
99393
+ || get instanceof Expressions.TargetFieldSymbol
99394
+ || get instanceof Expressions.AttributeName) {
99395
+ type = (_a = this.findReference(child.getFirstToken().getStart(), spaghetti, file)) === null || _a === void 0 ? void 0 : _a.getType();
99396
+ }
99397
+ else if (get instanceof Expressions.ComponentName) {
99398
+ type = type instanceof basic_1.StructureType ? type.getComponentByName(child.concatTokens()) : undefined;
99399
+ }
99400
+ else if (!(get instanceof tokens_1.Dash)
99401
+ && !(get instanceof tokens_1.InstanceArrow)
99402
+ && !(get instanceof tokens_1.StaticArrow)
99403
+ && !(get instanceof Expressions.ClassName)) {
99404
+ return undefined;
99405
+ }
99406
+ if (type === undefined && !(get instanceof Expressions.ClassName) && !(get instanceof tokens_1.StaticArrow)) {
99407
+ return undefined;
99408
+ }
99409
+ }
99410
+ return type;
99411
+ }
99412
+ findReference(start, spaghetti, file) {
99413
+ const scope = spaghetti.lookupPosition(start, file.getFilename());
99414
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
99415
+ if (r.position.getStart().equals(start) && r.resolved instanceof _typed_identifier_1.TypedIdentifier) {
99416
+ return r.resolved;
99417
+ }
99418
+ }
99419
+ return undefined;
99420
+ }
99421
+ buildFix(file, statement, rowType, addition) {
99422
+ if (rowType instanceof basic_1.StructureType
99423
+ || rowType instanceof basic_1.TableType
99424
+ || rowType instanceof basic_1.VoidType
99425
+ || rowType instanceof basic_1.UnknownType
99426
+ || rowType.isGeneric()) {
99427
+ return undefined;
99428
+ }
99429
+ const tokens = statement.getTokens();
99430
+ let last = tokens[tokens.length - 1];
99431
+ if (last instanceof tokens_1.Punctuation) {
99432
+ last = tokens[tokens.length - 2];
99433
+ }
99434
+ return edit_helper_1.EditHelper.insertAt(file, last.getEnd(), ` ${addition} table_line`);
99435
+ }
99436
+ }
99437
+ exports.SortEmptyKey = SortEmptyKey;
99438
+ //# sourceMappingURL=sort_empty_key.js.map
99439
+
99440
+ /***/ },
99441
+
97393
99442
  /***/ "../core/build/src/rules/space_before_colon.js"
97394
99443
  /*!*****************************************************!*\
97395
99444
  !*** ../core/build/src/rules/space_before_colon.js ***!
@@ -98129,6 +100178,236 @@ exports.StrictSQL = StrictSQL;
98129
100178
 
98130
100179
  /***/ },
98131
100180
 
100181
+ /***/ "../core/build/src/rules/subrc_after_assign.js"
100182
+ /*!*****************************************************!*\
100183
+ !*** ../core/build/src/rules/subrc_after_assign.js ***!
100184
+ \*****************************************************/
100185
+ (__unused_webpack_module, exports, __webpack_require__) {
100186
+
100187
+ "use strict";
100188
+
100189
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
100190
+ if (k2 === undefined) k2 = k;
100191
+ var desc = Object.getOwnPropertyDescriptor(m, k);
100192
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
100193
+ desc = { enumerable: true, get: function() { return m[k]; } };
100194
+ }
100195
+ Object.defineProperty(o, k2, desc);
100196
+ }) : (function(o, m, k, k2) {
100197
+ if (k2 === undefined) k2 = k;
100198
+ o[k2] = m[k];
100199
+ }));
100200
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
100201
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
100202
+ }) : function(o, v) {
100203
+ o["default"] = v;
100204
+ });
100205
+ var __importStar = (this && this.__importStar) || (function () {
100206
+ var ownKeys = function(o) {
100207
+ ownKeys = Object.getOwnPropertyNames || function (o) {
100208
+ var ar = [];
100209
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
100210
+ return ar;
100211
+ };
100212
+ return ownKeys(o);
100213
+ };
100214
+ return function (mod) {
100215
+ if (mod && mod.__esModule) return mod;
100216
+ var result = {};
100217
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
100218
+ __setModuleDefault(result, mod);
100219
+ return result;
100220
+ };
100221
+ })();
100222
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
100223
+ exports.SubrcAfterAssign = exports.SubrcAfterAssignConf = void 0;
100224
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
100225
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
100226
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
100227
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
100228
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
100229
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
100230
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
100231
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
100232
+ const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
100233
+ class SubrcAfterAssignConf extends _basic_rule_config_1.BasicRuleConfig {
100234
+ constructor() {
100235
+ super(...arguments);
100236
+ this.severity = severity_1.Severity.Warning;
100237
+ }
100238
+ }
100239
+ exports.SubrcAfterAssignConf = SubrcAfterAssignConf;
100240
+ class SubrcAfterAssign extends _abap_rule_1.ABAPRule {
100241
+ constructor() {
100242
+ super(...arguments);
100243
+ this.conf = new SubrcAfterAssignConf();
100244
+ }
100245
+ getMetadata() {
100246
+ return {
100247
+ key: "subrc_after_assign",
100248
+ title: "sy-subrc checked after ASSIGN",
100249
+ shortDescription: `Reports a sy-subrc check directly after an ASSIGN, use IS [NOT] ASSIGNED instead`,
100250
+ extendedInformation: `On a 7.40 SP7 system sy-subrc was still 4 after a successful ASSIGN, left over from an earlier
100251
+ READ TABLE, see https://github.com/abap2UI5/abap2UI5/issues/1937. Current releases set sy-subrc here.
100252
+ IS [NOT] ASSIGNED asks the field symbol directly and does not depend on the release.
100253
+
100254
+ A failed ASSIGN keeps the previous binding of the field symbol. So inside a loop, or when the
100255
+ field symbol is bound earlier in the same method, IS ASSIGNED is true after a failed ASSIGN.
100256
+ There, add UNASSIGN <fs> before the ASSIGN. The quick fix is only offered when the field symbol
100257
+ is declared in the method, bound only by this ASSIGN, and the ASSIGN is not in a loop.
100258
+
100259
+ ASSIGN COMPONENT ... OF STRUCTURE is not reported.`,
100260
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
100261
+ badExample: `ASSIGN (lv_name) TO <attri>.
100262
+ IF sy-subrc = 0.
100263
+ WRITE <attri>.
100264
+ ENDIF.`,
100265
+ goodExample: `ASSIGN (lv_name) TO <attri>.
100266
+ IF <attri> IS ASSIGNED.
100267
+ WRITE <attri>.
100268
+ ENDIF.`,
100269
+ };
100270
+ }
100271
+ getConfig() {
100272
+ return this.conf;
100273
+ }
100274
+ setConfig(conf) {
100275
+ this.conf = conf;
100276
+ }
100277
+ runParsed(file) {
100278
+ var _a, _b;
100279
+ const issues = [];
100280
+ const statements = file.getStatements();
100281
+ for (let i = 0; i < statements.length; i++) {
100282
+ const statement = statements[i];
100283
+ if (!(statement.get() instanceof Statements.Assign)
100284
+ || ((_a = statement.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toUpperCase()) === "COMPONENT") {
100285
+ continue;
100286
+ }
100287
+ const target = statement.findDirectExpression(Expressions.FSTarget);
100288
+ const fs = (_b = target === null || target === void 0 ? void 0 : target.findFirstExpression(Expressions.FieldSymbol)) === null || _b === void 0 ? void 0 : _b.concatTokens();
100289
+ if (target === undefined || fs === undefined) {
100290
+ continue;
100291
+ }
100292
+ const check = this.nextCheck(i, statements, fs.toUpperCase());
100293
+ if (check === undefined) {
100294
+ continue;
100295
+ }
100296
+ let message = `sy-subrc checked after ASSIGN, use ${fs} IS [NOT] ASSIGNED`;
100297
+ let fix = undefined;
100298
+ if (this.insideLoop(i, statements) === true) {
100299
+ message += ` with UNASSIGN ${fs} before the ASSIGN, it is inside a loop`;
100300
+ }
100301
+ else if (this.boundEarlier(i, statements, fs.toUpperCase()) === true) {
100302
+ message += ` with UNASSIGN ${fs} before the ASSIGN, ${fs} is bound earlier`;
100303
+ }
100304
+ else if (target.findDirectExpression(Expressions.InlineFS) === undefined
100305
+ && this.declaredInBlock(i, statements, fs.toUpperCase()) === false) {
100306
+ message += ` with UNASSIGN ${fs} before the ASSIGN, ${fs} is not declared in this method`;
100307
+ }
100308
+ else {
100309
+ fix = this.buildFix(file, check, fs);
100310
+ }
100311
+ issues.push(issue_1.Issue.atStatement(file, check, message, this.getMetadata().key, this.conf.severity, fix));
100312
+ }
100313
+ return issues;
100314
+ }
100315
+ ////////////////
100316
+ /** the next statement, skipping comments and ENDIF like check_subrc does, if it reads sy-subrc */
100317
+ nextCheck(index, statements, fs) {
100318
+ for (let i = index + 1; i < statements.length; i++) {
100319
+ const statement = statements[i];
100320
+ if (statement.get() instanceof _statement_1.Comment
100321
+ || statement.get() instanceof Statements.EndIf
100322
+ || statement.get() instanceof Statements.EndTestSeam) {
100323
+ continue;
100324
+ }
100325
+ const concat = statement.concatTokens().toUpperCase();
100326
+ if (concat.includes(fs + " IS ASSIGNED") || concat.includes(fs + " IS NOT ASSIGNED")) {
100327
+ return undefined;
100328
+ }
100329
+ return concat.includes("SY-SUBRC") ? statement : undefined;
100330
+ }
100331
+ return undefined;
100332
+ }
100333
+ insideLoop(index, statements) {
100334
+ let depth = 0;
100335
+ for (let i = index - 1; i >= 0 && this.startsBlock(statements[i]) === false; i--) {
100336
+ const s = statements[i].get();
100337
+ if (s instanceof Statements.EndLoop || s instanceof Statements.EndDo || s instanceof Statements.EndWhile) {
100338
+ depth++;
100339
+ }
100340
+ else if (s instanceof Statements.Loop || s instanceof Statements.Do || s instanceof Statements.While) {
100341
+ if (depth === 0) {
100342
+ return true;
100343
+ }
100344
+ depth--;
100345
+ }
100346
+ }
100347
+ return false;
100348
+ }
100349
+ /** any earlier statement in the block with the field symbol as target, eg. ASSIGN, LOOP or READ TABLE ASSIGNING */
100350
+ boundEarlier(index, statements, fs) {
100351
+ var _a;
100352
+ for (let i = index - 1; i >= 0 && this.startsBlock(statements[i]) === false; i--) {
100353
+ for (const target of statements[i].findAllExpressions(Expressions.FSTarget)) {
100354
+ if (((_a = target.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === fs) {
100355
+ return true;
100356
+ }
100357
+ }
100358
+ }
100359
+ return false;
100360
+ }
100361
+ declaredInBlock(index, statements, fs) {
100362
+ var _a;
100363
+ for (let i = index - 1; i >= 0 && this.startsBlock(statements[i]) === false; i--) {
100364
+ if (statements[i].get() instanceof Statements.FieldSymbol
100365
+ && ((_a = statements[i].findDirectExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === fs) {
100366
+ return true;
100367
+ }
100368
+ }
100369
+ return false;
100370
+ }
100371
+ startsBlock(statement) {
100372
+ const s = statement.get();
100373
+ return s instanceof Statements.MethodImplementation
100374
+ || s instanceof Statements.Form
100375
+ || s instanceof Statements.FunctionModule
100376
+ || s instanceof Statements.Module
100377
+ || s instanceof Statements.EndMethod
100378
+ || s instanceof Statements.EndForm
100379
+ || s instanceof Statements.EndFunction
100380
+ || s instanceof Statements.EndModule;
100381
+ }
100382
+ /** replaces "sy-subrc = 0" or "sy-subrc <> 0" in place, also inside a longer condition */
100383
+ buildFix(file, statement, fs) {
100384
+ const tokens = statement.getTokens();
100385
+ for (let i = 0; i + 4 < tokens.length; i++) {
100386
+ if (tokens[i].getStr().toUpperCase() !== "SY"
100387
+ || tokens[i + 1].getStr() !== "-"
100388
+ || tokens[i + 2].getStr().toUpperCase() !== "SUBRC") {
100389
+ continue;
100390
+ }
100391
+ if (tokens[i + 4].getStr() !== "0") {
100392
+ return undefined;
100393
+ }
100394
+ const op = tokens[i + 3].getStr().toUpperCase();
100395
+ if (op === "=" || op === "EQ") {
100396
+ return edit_helper_1.EditHelper.replaceRange(file, tokens[i].getStart(), tokens[i + 4].getEnd(), `${fs} IS ASSIGNED`);
100397
+ }
100398
+ else if (op === "<>" || op === "NE") {
100399
+ return edit_helper_1.EditHelper.replaceRange(file, tokens[i].getStart(), tokens[i + 4].getEnd(), `${fs} IS NOT ASSIGNED`);
100400
+ }
100401
+ return undefined;
100402
+ }
100403
+ return undefined;
100404
+ }
100405
+ }
100406
+ exports.SubrcAfterAssign = SubrcAfterAssign;
100407
+ //# sourceMappingURL=subrc_after_assign.js.map
100408
+
100409
+ /***/ },
100410
+
98132
100411
  /***/ "../core/build/src/rules/superclass_final.js"
98133
100412
  /*!***************************************************!*\
98134
100413
  !*** ../core/build/src/rules/superclass_final.js ***!
@@ -99046,6 +101325,7 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
99046
101325
  constructor() {
99047
101326
  super(...arguments);
99048
101327
  this.conf = new TypesNamingConf();
101328
+ this.regex = new RegExp(this.conf.pattern, "i");
99049
101329
  }
99050
101330
  getMetadata() {
99051
101331
  return {
@@ -99063,10 +101343,10 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
99063
101343
  }
99064
101344
  setConfig(conf) {
99065
101345
  this.conf = conf;
101346
+ this.regex = new RegExp(this.conf.pattern, "i");
99066
101347
  }
99067
101348
  runParsed(file, obj) {
99068
101349
  const issues = [];
99069
- const testRegex = new RegExp(this.conf.pattern, "i");
99070
101350
  let nesting = 0;
99071
101351
  if (obj instanceof objects_1.TypePool) {
99072
101352
  return [];
@@ -99095,7 +101375,7 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
99095
101375
  continue;
99096
101376
  }
99097
101377
  const token = expr.getFirstToken();
99098
- if (testRegex.exec(token.getStr())) {
101378
+ if (this.regex.exec(token.getStr())) {
99099
101379
  continue;
99100
101380
  }
99101
101381
  else {
@@ -102414,6 +104694,8 @@ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/
102414
104694
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
102415
104695
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
102416
104696
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
104697
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
104698
+ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
102417
104699
  class WrongAbapdocPositionConf extends _basic_rule_config_1.BasicRuleConfig {
102418
104700
  }
102419
104701
  exports.WrongAbapdocPositionConf = WrongAbapdocPositionConf;
@@ -102433,10 +104715,13 @@ elsewhere is silently ignored, leaving the declaration undocumented.
102433
104715
  The following positions are reported,
102434
104716
  * in front of a chained keyword, ie. before "CONSTANTS:" instead of after the colon,
102435
104717
  * in the middle of a statement, ie. between the parameters of a METHODS definition,
102436
- * directly in front of ENDCLASS, ENDINTERFACE or a SECTION statement.
104718
+ * directly in front of ENDCLASS, ENDINTERFACE or a SECTION statement,
104719
+ * separated from its declaration by a blank line or a normal comment, the system reads both as the end of the block.
102437
104720
 
102438
- Only checks ABAP Doc inside class definitions and interfaces.`,
102439
- tags: [_irule_1.RuleTag.SingleFile],
104721
+ Only checks ABAP Doc inside class definitions and interfaces, and directly in front of them.
104722
+
104723
+ The quick fix for a blank line deletes the blank lines.`,
104724
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
102440
104725
  badExample: `CLASS zcl_foo DEFINITION PUBLIC.
102441
104726
  PUBLIC SECTION.
102442
104727
  "! Navigation modes
@@ -102462,6 +104747,7 @@ ENDCLASS.`,
102462
104747
  this.conf = conf;
102463
104748
  }
102464
104749
  runParsed(file) {
104750
+ var _a;
102465
104751
  const issues = [];
102466
104752
  const statements = file.getStatements();
102467
104753
  let definition = false;
@@ -102476,7 +104762,7 @@ ENDCLASS.`,
102476
104762
  definition = false;
102477
104763
  continue;
102478
104764
  }
102479
- else if (definition === false || this.isAbapdoc(statement) === false) {
104765
+ else if (this.isAbapdoc(statement) === false) {
102480
104766
  continue;
102481
104767
  }
102482
104768
  else if (this.isAbapdoc(statements[i - 1]) === true
@@ -102484,19 +104770,57 @@ ENDCLASS.`,
102484
104770
  continue; // only report the first row of each block
102485
104771
  }
102486
104772
  let next = undefined;
102487
- for (let j = i + 1; j < statements.length; j++) {
102488
- if (statements[j].get() instanceof _statement_1.Comment) {
102489
- continue;
104773
+ let j = i + 1;
104774
+ for (; j < statements.length; j++) {
104775
+ if (!(statements[j].get() instanceof _statement_1.Comment)) {
104776
+ next = statements[j];
104777
+ break;
102490
104778
  }
102491
- next = statements[j];
102492
- break;
102493
104779
  }
102494
104780
  if (next === undefined) {
102495
104781
  continue;
102496
104782
  }
102497
- const message = this.check(statement, next);
104783
+ else if (definition === false
104784
+ && !(next.get() instanceof Statements.ClassDefinition)
104785
+ && !(next.get() instanceof Statements.Interface)) {
104786
+ continue;
104787
+ }
104788
+ // comments inside "next" are listed in front of it, only look at the rows above it
104789
+ const nextRow = this.startRow(next);
104790
+ const trailing = ((_a = statements[i - 1]) === null || _a === void 0 ? void 0 : _a.getEnd().getRow()) === statement.getStart().getRow();
104791
+ let last = statement;
104792
+ let separator = undefined;
104793
+ let fix = undefined;
104794
+ for (const s of trailing ? [] : statements.slice(i + 1, j)) {
104795
+ if (s.getStart().getRow() >= nextRow) {
104796
+ break;
104797
+ }
104798
+ else if (s.getStart().getRow() > last.getEnd().getRow() + 1) {
104799
+ separator = "a blank line";
104800
+ if (this.isAbapdoc(s) === true) {
104801
+ fix = edit_helper_1.EditHelper.deleteRange(file, new position_1.Position(last.getEnd().getRow() + 1, 1), new position_1.Position(s.getStart().getRow(), 1));
104802
+ }
104803
+ break;
104804
+ }
104805
+ else if (this.isAbapdoc(s) === false) {
104806
+ separator = "a comment";
104807
+ break;
104808
+ }
104809
+ last = s;
104810
+ }
104811
+ if (separator === undefined && trailing === false && nextRow > last.getEnd().getRow() + 1) {
104812
+ separator = "a blank line";
104813
+ fix = edit_helper_1.EditHelper.deleteRange(file, new position_1.Position(last.getEnd().getRow() + 1, 1), new position_1.Position(nextRow, 1));
104814
+ }
104815
+ let message = this.check(statement, next);
102498
104816
  if (message !== undefined) {
102499
- issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
104817
+ fix = undefined;
104818
+ }
104819
+ else if (separator !== undefined) {
104820
+ message = "ABAP Doc is separated from its declaration by " + separator;
104821
+ }
104822
+ if (message !== undefined) {
104823
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity, fix));
102500
104824
  }
102501
104825
  }
102502
104826
  return issues;
@@ -102505,6 +104829,9 @@ ENDCLASS.`,
102505
104829
  return (statement === null || statement === void 0 ? void 0 : statement.get()) instanceof _statement_1.Comment
102506
104830
  && statement.getFirstToken().getStr().startsWith(`"!`);
102507
104831
  }
104832
+ startRow(statement) {
104833
+ return Math.min(statement.getStart().getRow(), ...statement.getPragmas().map(p => p.getRow()));
104834
+ }
102508
104835
  check(abapdoc, next) {
102509
104836
  const type = next.get();
102510
104837
  if (type instanceof Statements.EndClass
@@ -102645,6 +104972,10 @@ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../co
102645
104972
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
102646
104973
  const fast_xml_parser_1 = __webpack_require__(/*! fast-xml-parser */ "../core/node_modules/fast-xml-parser/lib/fxp.cjs");
102647
104974
  const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
104975
+ const ABAPGIT_ATTRIBUTES = [
104976
+ ["version", /<abapGit\b[^>]*\bversion="([^"]+)"/],
104977
+ ["serializer_version", /<abapGit\b[^>]*\bserializer_version="([^"]+)"/],
104978
+ ];
102648
104979
  class XMLConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
102649
104980
  constructor() {
102650
104981
  super(...arguments);
@@ -102700,8 +105031,8 @@ class XMLConsistency {
102700
105031
  issues.push(issue_1.Issue.atRow(file, 1, "XML parser error: " + res.err.msg, this.getMetadata().key, this.conf.severity));
102701
105032
  }
102702
105033
  else {
102703
- for (const attribute of ["version", "serializer_version"]) {
102704
- const value = (_a = xml.match(new RegExp(`<abapGit\\b[^>]*\\b${attribute}="([^"]+)"`))) === null || _a === void 0 ? void 0 : _a[1];
105034
+ for (const [attribute, regex] of ABAPGIT_ATTRIBUTES) {
105035
+ const value = (_a = xml.match(regex)) === null || _a === void 0 ? void 0 : _a[1];
102705
105036
  if (value !== undefined && value.match(/^v\d\.\d\.\d$/) === null) {
102706
105037
  issues.push(issue_1.Issue.atRow(file, 1, `Unexpected abapGit ${attribute} "${value}"`, this.getMetadata().key, this.conf.severity));
102707
105038
  }
@@ -104036,12 +106367,16 @@ exports.MethodLengthStats = MethodLengthStats;
104036
106367
  Object.defineProperty(exports, "__esModule", ({ value: true }));
104037
106368
  exports.NameValidator = void 0;
104038
106369
  class NameValidator {
104039
- static violatesRule(name, pattern, params) {
106370
+ /** compile the configured ignorePatterns, case insensitive */
106371
+ static compileIgnorePatterns(params) {
106372
+ return (params.ignorePatterns || []).map(ignored => new RegExp(ignored, "i"));
106373
+ }
106374
+ static violatesRule(name, pattern, params, ignorePatterns) {
104040
106375
  if (params.ignoreNames && params.ignoreNames.indexOf(name.toUpperCase()) >= 0) {
104041
106376
  return false;
104042
106377
  }
104043
- for (const ignored of params.ignorePatterns || []) {
104044
- if (new RegExp(ignored, "i").test(name)) {
106378
+ for (const ignored of ignorePatterns) {
106379
+ if (ignored.test(name)) {
104045
106380
  return false;
104046
106381
  }
104047
106382
  }