@abaplint/cli 2.93.0 → 2.93.3

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.
@@ -6,21 +6,36 @@ class ApplyFixes {
6
6
  constructor() {
7
7
  this.changedFiles = new Set();
8
8
  }
9
- applyFixes(inputIssues, reg, fs, bar) {
10
- let changed = [];
9
+ // Strategy:
10
+ // Execute one rule at a time and apply fixes for that rule
11
+ // Some rules are quite expensive to initialize(like downport),
12
+ // so running all rules every time is expensive.
13
+ async applyFixes(reg, fs, bar) {
11
14
  let iteration = 1;
12
- let issues = inputIssues;
13
15
  this.changedFiles.clear();
14
16
  const MAX_ITERATIONS = 50000;
15
17
  bar === null || bar === void 0 ? void 0 : bar.set(MAX_ITERATIONS, "Apply Fixes");
18
+ const objects = new core_1.RulesRunner(reg).objectsToCheck(reg.getObjects());
19
+ const rules = reg.getConfig().getEnabledRules();
16
20
  while (iteration <= MAX_ITERATIONS) {
17
- bar === null || bar === void 0 ? void 0 : bar.tick("Apply Fixes, iteration " + iteration + ", " + issues.length + " candidates");
18
- changed = this.applyList(issues, reg);
19
- if (changed.length === 0) {
21
+ bar === null || bar === void 0 ? void 0 : bar.tick("Apply Fixes, iteration " + iteration);
22
+ let changed = 0;
23
+ for (const rule of rules) {
24
+ rule.initialize(reg);
25
+ const issues = [];
26
+ for (const obj of objects) {
27
+ issues.push(...rule.run(obj));
28
+ }
29
+ const appliedCount = this.applyList(issues, reg).length;
30
+ if (appliedCount > 0) {
31
+ changed += appliedCount;
32
+ reg.parse();
33
+ }
34
+ }
35
+ if (changed === 0) {
20
36
  break;
21
37
  }
22
38
  iteration++;
23
- issues = reg.parse().findIssues();
24
39
  }
25
40
  this.writeChangesToFS(fs, reg);
26
41
  // always end the progress indicator at 100%
@@ -28,8 +43,8 @@ class ApplyFixes {
28
43
  bar === null || bar === void 0 ? void 0 : bar.tick("Fixes Applied");
29
44
  iteration++;
30
45
  }
31
- return issues;
32
46
  }
47
+ ///////////////////////////////////////////////////
33
48
  writeChangesToFS(fs, reg) {
34
49
  for (const filename of this.changedFiles.values()) {
35
50
  const file = reg.getFileByName(filename);
@@ -186,7 +186,7 @@ async function run(arg) {
186
186
  }
187
187
  let extra = "";
188
188
  if (arg.runFix === true && reg) {
189
- issues = new fixes_1.ApplyFixes().applyFixes(issues, reg, fs, progress);
189
+ await new fixes_1.ApplyFixes().applyFixes(reg, fs, progress);
190
190
  extra = "Fixes applied";
191
191
  }
192
192
  else if (arg.runRename === true && reg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.93.0",
3
+ "version": "2.93.3",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "bin": {
6
6
  "abaplint": "./abaplint"
@@ -39,12 +39,12 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.93.0",
42
+ "@abaplint/core": "^2.93.3",
43
43
  "@types/chai": "^4.3.3",
44
44
  "@types/glob": "^7.2.0",
45
45
  "@types/minimist": "^1.2.2",
46
46
  "@types/mocha": "^9.1.1",
47
- "@types/node": "^18.7.13",
47
+ "@types/node": "^18.7.14",
48
48
  "@types/progress": "^2.0.5",
49
49
  "chai": "^4.3.6",
50
50
  "chalk": "^5.0.1",