@abaplint/cli 2.93.1 → 2.93.4

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.
@@ -1,35 +1,59 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApplyFixes = void 0;
4
+ /* eslint-disable max-len */
4
5
  const core_1 = require("@abaplint/core");
5
6
  class ApplyFixes {
6
7
  constructor() {
7
8
  this.changedFiles = new Set();
8
9
  }
9
- applyFixes(inputIssues, reg, fs, bar) {
10
- let changed = [];
10
+ // Strategy:
11
+ // Execute one rule at a time and apply fixes for that rule
12
+ // Some rules are quite expensive to initialize(like downport),
13
+ // so running all rules every time is expensive.
14
+ async applyFixes(reg, fs, quiet) {
11
15
  let iteration = 1;
12
- let issues = inputIssues;
13
16
  this.changedFiles.clear();
14
17
  const MAX_ITERATIONS = 50000;
15
- 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
+ let changed = 0;
22
+ for (const rule of rules) {
23
+ while (iteration <= MAX_ITERATIONS) {
24
+ const before = Date.now();
25
+ rule.initialize(reg);
26
+ const issues = [];
27
+ for (const obj of objects) {
28
+ issues.push(...rule.run(obj));
29
+ }
30
+ iteration++;
31
+ const appliedCount = this.applyList(issues, reg).length;
32
+ const runtime = Date.now() - before;
33
+ if (quiet !== true) {
34
+ process.stderr.write(`\tIteration ${iteration.toString().padEnd(3, " ")}, ${appliedCount} fixes applied, ${runtime}ms, rule ${rule.getMetadata().key}\n`);
35
+ }
36
+ if (appliedCount > 0) {
37
+ changed += appliedCount;
38
+ const before = Date.now();
39
+ reg.parse();
40
+ const runtime = Date.now() - before;
41
+ if (quiet !== true) {
42
+ process.stderr.write(`\tParse, ${runtime}ms\n`);
43
+ }
44
+ }
45
+ else {
46
+ break;
47
+ }
48
+ }
49
+ }
50
+ if (changed === 0) {
20
51
  break;
21
52
  }
22
- iteration++;
23
- issues = reg.parse().findIssues();
24
53
  }
25
54
  this.writeChangesToFS(fs, reg);
26
- // always end the progress indicator at 100%
27
- while (iteration <= MAX_ITERATIONS) {
28
- bar === null || bar === void 0 ? void 0 : bar.tick("Fixes Applied");
29
- iteration++;
30
- }
31
- return issues;
32
55
  }
56
+ ///////////////////////////////////////////////////
33
57
  writeChangesToFS(fs, reg) {
34
58
  for (const filename of this.changedFiles.values()) {
35
59
  const file = reg.getFileByName(filename);
@@ -186,7 +186,8 @@ 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
+ issues = [];
190
+ await new fixes_1.ApplyFixes().applyFixes(reg, fs);
190
191
  extra = "Fixes applied";
191
192
  }
192
193
  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.1",
3
+ "version": "2.93.4",
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.1",
42
+ "@abaplint/core": "^2.93.4",
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",