Skip to content

Commit 6028a4d

Browse files
CHANGE: @W-17272495@: Remove usage of RuleType and update dependencies
1 parent d4daca7 commit 6028a4d

File tree

8 files changed

+1061
-982
lines changed

8 files changed

+1061
-982
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
77
"dependencies": {
88
"@oclif/core": "^3.3.2",
9-
"@salesforce/code-analyzer-core": "0.16.0",
10-
"@salesforce/code-analyzer-engine-api": "0.13.0",
11-
"@salesforce/code-analyzer-eslint-engine": "0.13.0",
12-
"@salesforce/code-analyzer-pmd-engine": "0.13.0",
13-
"@salesforce/code-analyzer-regex-engine": "0.13.0",
14-
"@salesforce/code-analyzer-retirejs-engine": "0.13.0",
9+
"@salesforce/code-analyzer-core": "0.17.0",
10+
"@salesforce/code-analyzer-engine-api": "0.14.0",
11+
"@salesforce/code-analyzer-eslint-engine": "0.14.0",
12+
"@salesforce/code-analyzer-pmd-engine": "0.14.0",
13+
"@salesforce/code-analyzer-regex-engine": "0.14.0",
14+
"@salesforce/code-analyzer-retirejs-engine": "0.14.0",
1515
"@salesforce/core": "^5",
1616
"@salesforce/sf-plugins-core": "^5.0.4",
1717
"@salesforce/ts-types": "^2.0.9",

src/lib/viewers/RuleViewer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Ux} from '@salesforce/sf-plugins-core';
2-
import {Rule, RuleType, SeverityLevel} from '@salesforce/code-analyzer-core';
2+
import {Rule, SeverityLevel} from '@salesforce/code-analyzer-core';
33
import {Display} from '../Display';
44
import {toStyledHeaderAndBody} from '../utils/StylingUtil';
55
import {BundleName, getMessage} from '../messages';
@@ -41,12 +41,11 @@ export class RuleDetailDisplayer extends AbstractRuleDisplayer {
4141
const body = {
4242
engine: rule.getEngineName(),
4343
severity: `${severity.valueOf()} (${SeverityLevel[severity]})`,
44-
type: RuleType[rule.getType()],
4544
tags: rule.getTags().join(', '),
4645
resources: rule.getResourceUrls().join(', '),
4746
description: rule.getDescription()
4847
};
49-
const keys = ['severity', 'engine', 'type', 'tags', 'resources', 'description'];
48+
const keys = ['severity', 'engine', 'tags', 'resources', 'description'];
5049
styledRules.push(toStyledHeaderAndBody(header, body, keys));
5150
}
5251
this.display.displayLog(styledRules.join('\n\n'));

test/fixtures/comparison-files/lib/viewers/RuleViewer.test.ts/one-rule-details.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
=== 1. StubRule1
33
severity: 2 (High)
44
engine: FakeEngine1
5-
type: Standard
65
tags: Recommended, Security
76
resources: www.google.com
87
description: This is the description for a stub rule. Blah blah blah.

test/fixtures/comparison-files/lib/viewers/RuleViewer.test.ts/two-rules-details.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
=== 1. StubRule1
33
severity: 2 (High)
44
engine: FakeEngine1
5-
type: Standard
65
tags: Recommended, Security
76
resources: www.google.com
87
description: This is the description for a stub rule. Blah blah blah.
98

109
=== 2. StubRule2
1110
severity: 4 (Low)
1211
engine: FakeEngine1
13-
type: Flow
1412
tags: CodeStyle, Performance
1513
resources: www.bing.com, www.salesforce.com
1614
description: This is the description for a second stub rule. Blah blah blah.

test/lib/actions/ConfigAction.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -655,56 +655,48 @@ class StubEngine1 extends EngineApi.Engine {
655655
return Promise.resolve([{
656656
name: 'Stub1Rule1',
657657
severityLevel: EngineApi.SeverityLevel.Info,
658-
type: EngineApi.RuleType.Standard,
659658
tags: ["Recommended", "CodeStyle"],
660659
description: 'Generic description',
661660
resourceUrls: []
662661
}, {
663662
name: 'Stub1Rule2',
664663
severityLevel: EngineApi.SeverityLevel.Moderate,
665-
type: EngineApi.RuleType.Standard,
666664
tags: ["CodeStyle"],
667665
description: 'Generic description',
668666
resourceUrls: []
669667
}, {
670668
name: 'Stub1Rule3',
671669
severityLevel: EngineApi.SeverityLevel.Low,
672-
type: EngineApi.RuleType.Standard,
673670
tags: ["BestPractices"],
674671
description: 'Generic description',
675672
resourceUrls: []
676673
}, {
677674
name: 'Stub1Rule4',
678675
severityLevel: EngineApi.SeverityLevel.High,
679-
type: EngineApi.RuleType.Standard,
680676
tags: ["CodeStyle"],
681677
description: 'Generic description',
682678
resourceUrls: []
683679
}, {
684680
name: 'Stub1Rule5',
685681
severityLevel: EngineApi.SeverityLevel.High,
686-
type: EngineApi.RuleType.Standard,
687682
tags: ["Recommended", "CodeStyle"],
688683
description: 'Generic description',
689684
resourceUrls: []
690685
}, {
691686
name: 'Stub1Rule6',
692687
severityLevel: EngineApi.SeverityLevel.Low,
693-
type: EngineApi.RuleType.Standard,
694688
tags: ["Recommended"],
695689
description: 'Generic description',
696690
resourceUrls: []
697691
}, {
698692
name: 'Stub1Rule7',
699693
severityLevel: EngineApi.SeverityLevel.Moderate,
700-
type: EngineApi.RuleType.Standard,
701694
tags: [],
702695
description: 'Generic description',
703696
resourceUrls: []
704697
}, {
705698
name: 'Stub1Rule8',
706699
severityLevel: EngineApi.SeverityLevel.Moderate,
707-
type: EngineApi.RuleType.Standard,
708700
tags: ['Recommended'],
709701
description: 'Generic description',
710702
resourceUrls: []
@@ -731,7 +723,6 @@ class StubEngine2 extends EngineApi.Engine {
731723
return Promise.resolve([{
732724
name: 'Stub2Rule1',
733725
severityLevel: EngineApi.SeverityLevel.Moderate,
734-
type: EngineApi.RuleType.Standard,
735726
tags: ['Security'],
736727
description: 'Generic description',
737728
resourceUrls: []
@@ -758,7 +749,6 @@ class StubEngine3 extends EngineApi.Engine {
758749
return Promise.resolve([{
759750
name: 'Stub3Rule1',
760751
severityLevel: EngineApi.SeverityLevel.Moderate,
761-
type: EngineApi.RuleType.Standard,
762752
tags: ['CodeStyle'],
763753
description: 'Generic description',
764754
resourceUrls: []

test/stubs/StubEnginePlugins.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,34 @@ export class StubEngine1 extends EngineApi.Engine {
9393
{
9494
name: "stub1RuleA",
9595
severityLevel: EngineApi.SeverityLevel.Low,
96-
type: EngineApi.RuleType.Standard,
9796
tags: ["Recommended", "CodeStyle"],
9897
description: "Some description for stub1RuleA",
9998
resourceUrls: ["https://example.com/stub1RuleA"]
10099
},
101100
{
102101
name: "stub1RuleB",
103102
severityLevel: EngineApi.SeverityLevel.High,
104-
type: EngineApi.RuleType.Standard,
105103
tags: ["Recommended", "Security"],
106104
description: "Some description for stub1RuleB",
107105
resourceUrls: ["https://example.com/stub1RuleB"]
108106
},
109107
{
110108
name: "stub1RuleC",
111109
severityLevel: EngineApi.SeverityLevel.Moderate,
112-
type: EngineApi.RuleType.Standard,
113110
tags: ["Recommended", "Performance", "Custom"],
114111
description: "Some description for stub1RuleC",
115112
resourceUrls: ["https://example.com/stub1RuleC"]
116113
},
117114
{
118115
name: "stub1RuleD",
119116
severityLevel: EngineApi.SeverityLevel.Low,
120-
type: EngineApi.RuleType.Standard,
121117
tags: ["CodeStyle"],
122118
description: "Some description for stub1RuleD",
123119
resourceUrls: ["https://example.com/stub1RuleD"]
124120
},
125121
{
126122
name: "stub1RuleE",
127123
severityLevel: EngineApi.SeverityLevel.Moderate,
128-
type: EngineApi.RuleType.Standard,
129124
tags: ["Performance"],
130125
description: "Some description for stub1RuleE",
131126
resourceUrls: ["https://example.com/stub1RuleE", "https://example.com/stub1RuleE_2"]
@@ -178,23 +173,20 @@ export class StubEngine2 extends EngineApi.Engine {
178173
{
179174
name: "stub2RuleA",
180175
severityLevel: EngineApi.SeverityLevel.Moderate,
181-
type: EngineApi.RuleType.DataFlow,
182176
tags: ["Recommended", "Security"],
183177
description: "Some description for stub2RuleA",
184178
resourceUrls: ["https://example.com/stub2RuleA"]
185179
},
186180
{
187181
name: "stub2RuleB",
188182
severityLevel: EngineApi.SeverityLevel.Low,
189-
type: EngineApi.RuleType.DataFlow,
190183
tags: ["Performance", "Custom"],
191184
description: "Some description for stub2RuleB",
192185
resourceUrls: ["https://example.com/stub2RuleB"]
193186
},
194187
{
195188
name: "stub2RuleC",
196189
severityLevel: EngineApi.SeverityLevel.High,
197-
type: EngineApi.RuleType.DataFlow,
198190
tags: ["Recommended", "BestPractice"],
199191
description: "Some description for stub2RuleC",
200192
resourceUrls: [] // Purposely putting in nothing here
@@ -267,7 +259,7 @@ abstract class BaseTimeableEngine extends EngineApi.Engine {
267259
private selectionWaitTime: number;
268260
private executionWaitTime: number;
269261

270-
constructor(config: EngineApi.ConfigObject) {
262+
constructor(_config: EngineApi.ConfigObject) {
271263
super();
272264
this.selectionWaitTime = 0;
273265
this.executionWaitTime = 0;
@@ -306,15 +298,14 @@ abstract class BaseTimeableEngine extends EngineApi.Engine {
306298
{
307299
name: "stub1RuleA",
308300
severityLevel: EngineApi.SeverityLevel.Low,
309-
type: EngineApi.RuleType.Standard,
310301
tags: ["Recommended", "CodeStyle"],
311302
description: "Some description for stub1RuleA",
312303
resourceUrls: ["https://example.com/stub1RuleA"]
313304
}
314305
];
315306
}
316307

317-
async runRules(ruleNames: string[], runOptions: EngineApi.RunOptions): Promise<EngineApi.EngineRunResults> {
308+
async runRules(_ruleNames: string[], _runOptions: EngineApi.RunOptions): Promise<EngineApi.EngineRunResults> {
318309
await new Promise(res => setTimeout(res, this.executionWaitTime));
319310
this.emitEvent<EngineApi.RunRulesProgressEvent>({
320311
type: EngineApi.EventType.RunRulesProgressEvent,
@@ -367,7 +358,7 @@ export class TimeableEngine2 extends BaseTimeableEngine {
367358
export class EventConfigurableEngine1 extends EngineApi.Engine {
368359
private events: {logLevel: LogLevel, message: string}[] = [];
369360

370-
constructor(config: EngineApi.ConfigObject) {
361+
constructor(_config: EngineApi.ConfigObject) {
371362
super();
372363
}
373364

@@ -384,15 +375,14 @@ export class EventConfigurableEngine1 extends EngineApi.Engine {
384375
{
385376
name: "stub1RuleA",
386377
severityLevel: EngineApi.SeverityLevel.Low,
387-
type: EngineApi.RuleType.Standard,
388378
tags: ["Recommended", "CodeStyle"],
389379
description: "Some description for stub1RuleA",
390380
resourceUrls: ["https://example.com/stub1RuleA"]
391381
}
392382
]);
393383
}
394384

395-
async runRules(ruleNames: string[], runOptions: EngineApi.RunOptions): Promise<EngineApi.EngineRunResults> {
385+
async runRules(_ruleNames: string[], _runOptions: EngineApi.RunOptions): Promise<EngineApi.EngineRunResults> {
396386
for (const {logLevel, message} of this.events) {
397387
this.emitEvent<EngineApi.LogEvent>({
398388
type: EngineApi.EventType.LogEvent,
@@ -447,7 +437,6 @@ export class TargetDependentEngine1 extends EngineApi.Engine {
447437
return {
448438
name: `ruleFor${fileOrFolder}`,
449439
severityLevel: EngineApi.SeverityLevel.Low,
450-
type: EngineApi.RuleType.Standard,
451440
tags: ["Recommended"],
452441
description: `Rule synthesized for target "${fileOrFolder}`,
453442
resourceUrls: [`https://example.com/${fileOrFolder}`]

test/stubs/StubRules.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Rule, RuleType, SeverityLevel} from '@salesforce/code-analyzer-core';
1+
import {Rule, SeverityLevel} from '@salesforce/code-analyzer-core';
22

33
export class StubRule1 implements Rule {
44
public getName(): string {
@@ -17,10 +17,6 @@ export class StubRule1 implements Rule {
1717
return `2 (High)`;
1818
}
1919

20-
public getType(): RuleType {
21-
return RuleType.Standard;
22-
}
23-
2420
public getFormattedType(): string {
2521
return "Standard";
2622
}
@@ -63,10 +59,6 @@ export class StubRule2 implements Rule {
6359
return `4 (Low)`;
6460
}
6561

66-
public getType(): RuleType {
67-
return RuleType.Flow;
68-
}
69-
7062
public getFormattedType(): string {
7163
return "Flow";
7264
}

0 commit comments

Comments
 (0)