@abaplint/cli 2.120.53 → 2.120.54

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 +150 -3
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -12387,7 +12387,7 @@ class CallTransaction {
12387
12387
  getMatcher() {
12388
12388
  const options = (0, combi_1.seq)("OPTIONS FROM", expressions_1.Source);
12389
12389
  const messages = (0, combi_1.seq)("MESSAGES INTO", expressions_1.Target);
12390
- const auth = (0, combi_1.seq)((0, combi_1.altPrio)("WITH", "WITHOUT"), "AUTHORITY-CHECK");
12390
+ const auth = (0, combi_1.ver)(version_1.Release.v740sp02, (0, combi_1.seq)((0, combi_1.altPrio)("WITH", "WITHOUT"), "AUTHORITY-CHECK"));
12391
12391
  const perm = (0, combi_1.per)((0, combi_1.seq)("UPDATE", expressions_1.Source), "AND SKIP FIRST SCREEN", options, messages, (0, combi_1.seq)("MODE", expressions_1.Source));
12392
12392
  const ret = (0, combi_1.seq)("CALL TRANSACTION", expressions_1.Source, (0, combi_1.optPrio)(auth), (0, combi_1.optPrio)((0, combi_1.seq)("USING", expressions_1.Source)), (0, combi_1.opt)(perm));
12393
12393
  return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
@@ -70644,7 +70644,7 @@ class Registry {
70644
70644
  }
70645
70645
  static abaplintVersion() {
70646
70646
  // magic, see build script "version.js"
70647
- return "2.120.53";
70647
+ return "2.120.54";
70648
70648
  }
70649
70649
  getDDICReferences() {
70650
70650
  return this.ddicReferences;
@@ -78104,7 +78104,11 @@ Make sure to test the downported code, it might not always be completely correct
78104
78104
  return found;
78105
78105
  }
78106
78106
  */
78107
- let found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
78107
+ let found = this.stripCallTransactionAuthorityCheck(high, lowFile);
78108
+ if (found) {
78109
+ return found;
78110
+ }
78111
+ found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
78108
78112
  if (found) {
78109
78113
  return found;
78110
78114
  }
@@ -80598,6 +80602,27 @@ ${indentation} output = ${uniqueName}.\n`;
80598
80602
  }
80599
80603
  return false;
80600
80604
  }
80605
+ /** WITH/WITHOUT AUTHORITY-CHECK on CALL TRANSACTION requires v740sp02, so the statement is
80606
+ * Unknown in the low version, note that only WITHOUT is handled here */
80607
+ stripCallTransactionAuthorityCheck(high, lowFile) {
80608
+ if (!(high.get() instanceof Statements.CallTransaction)) {
80609
+ return undefined;
80610
+ }
80611
+ const tokens = high.getTokens();
80612
+ // the lexer splits "AUTHORITY-CHECK" into three tokens: AUTHORITY, -, CHECK
80613
+ for (let i = 1; i < tokens.length - 3; i++) {
80614
+ if (tokens[i].getStr().toUpperCase() === "WITHOUT"
80615
+ && tokens[i + 1].getStr().toUpperCase() === "AUTHORITY"
80616
+ && tokens[i + 2].getStr() === "-"
80617
+ && tokens[i + 3].getStr().toUpperCase() === "CHECK") {
80618
+ // also remove the preceding space so no double space is left behind
80619
+ const fix = edit_helper_1.EditHelper.deleteRange(lowFile, tokens[i - 1].getEnd(), tokens[i + 3].getEnd());
80620
+ const message = "Remove WITHOUT AUTHORITY-CHECK from CALL TRANSACTION";
80621
+ return issue_1.Issue.atToken(lowFile, tokens[i], message, this.getMetadata().key, this.conf.severity, fix);
80622
+ }
80623
+ }
80624
+ return undefined;
80625
+ }
80601
80626
  replaceXsdBool(node, lowFile, highSyntax) {
80602
80627
  if (this.lowReg.getConfig().isOpenABAP()) {
80603
80628
  return undefined;
@@ -85007,6 +85032,7 @@ __exportStar(__webpack_require__(/*! ./parser_missing_space */ "../core/build/sr
85007
85032
  __exportStar(__webpack_require__(/*! ./pragma_style */ "../core/build/src/rules/pragma_style.js"), exports);
85008
85033
  __exportStar(__webpack_require__(/*! ./prefer_corresponding */ "../core/build/src/rules/prefer_corresponding.js"), exports);
85009
85034
  __exportStar(__webpack_require__(/*! ./prefer_inline */ "../core/build/src/rules/prefer_inline.js"), exports);
85035
+ __exportStar(__webpack_require__(/*! ./prefer_insert_into_table */ "../core/build/src/rules/prefer_insert_into_table.js"), exports);
85010
85036
  __exportStar(__webpack_require__(/*! ./prefer_is_not */ "../core/build/src/rules/prefer_is_not.js"), exports);
85011
85037
  __exportStar(__webpack_require__(/*! ./prefer_pragmas */ "../core/build/src/rules/prefer_pragmas.js"), exports);
85012
85038
  __exportStar(__webpack_require__(/*! ./prefer_raise_exception_new */ "../core/build/src/rules/prefer_raise_exception_new.js"), exports);
@@ -92686,6 +92712,127 @@ exports.PreferInline = PreferInline;
92686
92712
 
92687
92713
  /***/ },
92688
92714
 
92715
+ /***/ "../core/build/src/rules/prefer_insert_into_table.js"
92716
+ /*!***********************************************************!*\
92717
+ !*** ../core/build/src/rules/prefer_insert_into_table.js ***!
92718
+ \***********************************************************/
92719
+ (__unused_webpack_module, exports, __webpack_require__) {
92720
+
92721
+ "use strict";
92722
+
92723
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
92724
+ if (k2 === undefined) k2 = k;
92725
+ var desc = Object.getOwnPropertyDescriptor(m, k);
92726
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
92727
+ desc = { enumerable: true, get: function() { return m[k]; } };
92728
+ }
92729
+ Object.defineProperty(o, k2, desc);
92730
+ }) : (function(o, m, k, k2) {
92731
+ if (k2 === undefined) k2 = k;
92732
+ o[k2] = m[k];
92733
+ }));
92734
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
92735
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
92736
+ }) : function(o, v) {
92737
+ o["default"] = v;
92738
+ });
92739
+ var __importStar = (this && this.__importStar) || (function () {
92740
+ var ownKeys = function(o) {
92741
+ ownKeys = Object.getOwnPropertyNames || function (o) {
92742
+ var ar = [];
92743
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
92744
+ return ar;
92745
+ };
92746
+ return ownKeys(o);
92747
+ };
92748
+ return function (mod) {
92749
+ if (mod && mod.__esModule) return mod;
92750
+ var result = {};
92751
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
92752
+ __setModuleDefault(result, mod);
92753
+ return result;
92754
+ };
92755
+ })();
92756
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
92757
+ exports.PreferInsertIntoTable = exports.PreferInsertIntoTableConf = void 0;
92758
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
92759
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
92760
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
92761
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
92762
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
92763
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
92764
+ class PreferInsertIntoTableConf extends _basic_rule_config_1.BasicRuleConfig {
92765
+ }
92766
+ exports.PreferInsertIntoTableConf = PreferInsertIntoTableConf;
92767
+ class PreferInsertIntoTable extends _abap_rule_1.ABAPRule {
92768
+ constructor() {
92769
+ super(...arguments);
92770
+ this.conf = new PreferInsertIntoTableConf();
92771
+ }
92772
+ getMetadata() {
92773
+ return {
92774
+ key: "prefer_insert_into_table",
92775
+ title: "Prefer INSERT INTO TABLE over APPEND",
92776
+ shortDescription: `Prefer INSERT INTO TABLE over APPEND`,
92777
+ extendedInformation: `INSERT INTO TABLE respects the table type, while APPEND always adds to the end regardless of table type.
92778
+
92779
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md`,
92780
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
92781
+ badExample: `APPEND row TO itab.`,
92782
+ goodExample: `INSERT row INTO TABLE itab.`,
92783
+ };
92784
+ }
92785
+ getConfig() { return this.conf; }
92786
+ setConfig(conf) { this.conf = conf; }
92787
+ runParsed(file) {
92788
+ const issues = [];
92789
+ for (const stat of file.getStatements()) {
92790
+ if (!(stat.get() instanceof Statements.Append)) {
92791
+ continue;
92792
+ }
92793
+ if (stat.concatTokens().toUpperCase().includes(" SORTED BY ")) {
92794
+ continue;
92795
+ }
92796
+ const fix = this.buildFix(file, stat);
92797
+ const message = "Prefer INSERT INTO TABLE over APPEND";
92798
+ issues.push(issue_1.Issue.atStatement(file, stat, message, this.getMetadata().key, this.conf.severity, fix));
92799
+ }
92800
+ return issues;
92801
+ }
92802
+ buildFix(file, stat) {
92803
+ const tokens = stat.getTokens();
92804
+ // Find the APPEND token (first token)
92805
+ const appendToken = tokens[0];
92806
+ if (appendToken.getStr().toUpperCase() !== "APPEND") {
92807
+ return undefined;
92808
+ }
92809
+ // Find the last "TO" token that precedes the table target.
92810
+ // In all fixable forms the table target follows the last standalone "TO":
92811
+ // APPEND row TO itab
92812
+ // APPEND LINES OF itab2 TO itab
92813
+ // APPEND LINES OF itab2 FROM 1 TO 3 TO itab <- last TO is the table
92814
+ // APPEND INITIAL LINE TO itab
92815
+ let lastToIndex = -1;
92816
+ for (let i = tokens.length - 1; i >= 0; i--) {
92817
+ if (tokens[i].getStr().toUpperCase() === "TO") {
92818
+ lastToIndex = i;
92819
+ break;
92820
+ }
92821
+ }
92822
+ if (lastToIndex < 0) {
92823
+ return undefined;
92824
+ }
92825
+ const toToken = tokens[lastToIndex];
92826
+ const fix1 = edit_helper_1.EditHelper.replaceToken(file, appendToken, "INSERT");
92827
+ const fix2 = edit_helper_1.EditHelper.replaceToken(file, toToken, "INTO TABLE");
92828
+ return edit_helper_1.EditHelper.merge(fix1, fix2);
92829
+ }
92830
+ }
92831
+ exports.PreferInsertIntoTable = PreferInsertIntoTable;
92832
+ //# sourceMappingURL=prefer_insert_into_table.js.map
92833
+
92834
+ /***/ },
92835
+
92689
92836
  /***/ "../core/build/src/rules/prefer_is_not.js"
92690
92837
  /*!************************************************!*\
92691
92838
  !*** ../core/build/src/rules/prefer_is_not.js ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.53",
3
+ "version": "2.120.54",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.53",
42
+ "@abaplint/core": "^2.120.54",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",