@abaplint/cli 2.108.1 → 2.108.2

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 +47 -15
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -51483,7 +51483,7 @@ class Registry {
51483
51483
  }
51484
51484
  static abaplintVersion() {
51485
51485
  // magic, see build script "version.sh"
51486
- return "2.108.1";
51486
+ return "2.108.2";
51487
51487
  }
51488
51488
  getDDICReferences() {
51489
51489
  return this.ddicReferences;
@@ -52518,6 +52518,8 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./
52518
52518
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
52519
52519
  const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
52520
52520
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/_statement.js");
52521
+ const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
52522
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
52521
52523
  class AlignPseudoCommentsConf extends _basic_rule_config_1.BasicRuleConfig {
52522
52524
  }
52523
52525
  exports.AlignPseudoCommentsConf = AlignPseudoCommentsConf;
@@ -52531,7 +52533,7 @@ class AlignPseudoComments extends _abap_rule_1.ABAPRule {
52531
52533
  key: "align_pseudo_comments",
52532
52534
  title: "Align pseudo comments",
52533
52535
  shortDescription: `Align code inspector pseudo comments in statements`,
52534
- tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace],
52536
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
52535
52537
  badExample: `WRITE 'sdf'. "#EC sdf`,
52536
52538
  goodExample: `WRITE 'sdf'. "#EC sdf`,
52537
52539
  };
@@ -52558,16 +52560,22 @@ class AlignPseudoComments extends _abap_rule_1.ABAPRule {
52558
52560
  else if (previousEnd === undefined) {
52559
52561
  continue;
52560
52562
  }
52561
- else if (commentLength > 10) {
52562
- const expectedColumn = 72 - commentLength;
52563
- if (previousEnd.getCol() < expectedColumn && firstCommentToken.getStart().getCol() !== expectedColumn) {
52564
- const message = "Align pseudo comment to column " + expectedColumn;
52565
- issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
52566
- }
52563
+ let expectedColumn = 61;
52564
+ if (commentLength > 10) {
52565
+ expectedColumn = 72 - commentLength;
52567
52566
  }
52568
- else if (previousEnd.getCol() < 61 && firstCommentToken.getStart().getCol() !== 61) {
52569
- const message = "Align pseudo comment to column 61";
52570
- issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
52567
+ const col = firstCommentToken.getStart().getCol();
52568
+ if (previousEnd.getCol() < expectedColumn && col !== expectedColumn) {
52569
+ let fix = undefined;
52570
+ if (col < expectedColumn) {
52571
+ fix = edit_helper_1.EditHelper.insertAt(file, firstCommentToken.getStart(), " ".repeat(expectedColumn - col));
52572
+ }
52573
+ else {
52574
+ const from = new position_1.Position(firstCommentToken.getStart().getRow(), expectedColumn);
52575
+ fix = edit_helper_1.EditHelper.deleteRange(file, from, firstCommentToken.getStart());
52576
+ }
52577
+ const message = "Align pseudo comment to column " + expectedColumn;
52578
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity, fix));
52571
52579
  }
52572
52580
  }
52573
52581
  return issues;
@@ -59672,6 +59680,8 @@ class EmptyStructureConf extends _basic_rule_config_1.BasicRuleConfig {
59672
59680
  super(...arguments);
59673
59681
  /** Checks for empty LOOP blocks */
59674
59682
  this.loop = true;
59683
+ /** Allow empty LOOP if subrc is checked after the loop */
59684
+ this.loopAllowIfSubrc = true;
59675
59685
  /** Checks for empty IF blocks */
59676
59686
  this.if = true;
59677
59687
  /** Checks for empty WHILE blocks */
@@ -59704,6 +59714,14 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
59704
59714
  shortDescription: `Checks that the code does not contain empty blocks.`,
59705
59715
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#no-empty-if-branches`,
59706
59716
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
59717
+ badExample: `IF foo = bar.
59718
+ ENDIF.
59719
+
59720
+ DO 2 TIMES.
59721
+ ENDDO.`,
59722
+ goodExample: `LOOP AT itab WHERE qty = 0 OR date > sy-datum.
59723
+ ENDLOOP.
59724
+ result = xsdbool( sy-subrc = 0 ).`,
59707
59725
  };
59708
59726
  }
59709
59727
  getDescription(name) {
@@ -59721,15 +59739,13 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
59721
59739
  if (stru === undefined) {
59722
59740
  return [];
59723
59741
  }
59724
- for (const statement of file.getStatements()) {
59742
+ const statements = file.getStatements();
59743
+ for (const statement of statements) {
59725
59744
  if (statement.get() instanceof _statement_1.Unknown) {
59726
59745
  return []; // contains parser errors
59727
59746
  }
59728
59747
  }
59729
59748
  const candidates = [];
59730
- if (this.getConfig().loop === true) {
59731
- candidates.push(...stru.findAllStructuresRecursive(Structures.Loop));
59732
- }
59733
59749
  if (this.getConfig().while === true) {
59734
59750
  candidates.push(...stru.findAllStructuresRecursive(Structures.While));
59735
59751
  }
@@ -59765,6 +59781,22 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
59765
59781
  }
59766
59782
  }
59767
59783
  }
59784
+ if (this.getConfig().loop === true) {
59785
+ const loops = stru.findAllStructuresRecursive(Structures.Loop);
59786
+ for (const loop of loops) {
59787
+ if (loop.getChildren().length === 2) {
59788
+ const endloopStatement = loop.getLastChild();
59789
+ const endloopIndex = statements.findIndex((s) => s === endloopStatement);
59790
+ const afterEndloop = statements[endloopIndex + 1];
59791
+ if (afterEndloop !== undefined && afterEndloop.concatTokens().toUpperCase().includes("SY-SUBRC")) {
59792
+ continue;
59793
+ }
59794
+ const token = loop.getFirstToken();
59795
+ const issue = issue_1.Issue.atToken(file, token, this.getDescription(loop.get().constructor.name), this.getMetadata().key, this.conf.severity);
59796
+ issues.push(issue);
59797
+ }
59798
+ }
59799
+ }
59768
59800
  if (this.getConfig().if === true) {
59769
59801
  const tries = stru.findAllStructuresRecursive(Structures.If)
59770
59802
  .concat(stru.findAllStructuresRecursive(Structures.Else))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.108.1",
3
+ "version": "2.108.2",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.108.1",
41
+ "@abaplint/core": "^2.108.2",
42
42
  "@types/chai": "^4.3.16",
43
43
  "@types/glob": "^8.1.0",
44
44
  "@types/minimist": "^1.2.5",