Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHANGE: @W-17272495@: Remove usage of RuleType and update dependencies #1677

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.yarnpkg.com
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
"dependencies": {
"@oclif/core": "^3.3.2",
"@salesforce/code-analyzer-core": "0.16.0",
"@salesforce/code-analyzer-engine-api": "0.13.0",
"@salesforce/code-analyzer-eslint-engine": "0.13.0",
"@salesforce/code-analyzer-pmd-engine": "0.13.0",
"@salesforce/code-analyzer-regex-engine": "0.13.0",
"@salesforce/code-analyzer-retirejs-engine": "0.13.0",
"@salesforce/code-analyzer-core": "0.17.0",
"@salesforce/code-analyzer-engine-api": "0.14.0",
"@salesforce/code-analyzer-eslint-engine": "0.14.0",
"@salesforce/code-analyzer-pmd-engine": "0.14.0",
"@salesforce/code-analyzer-regex-engine": "0.14.0",
"@salesforce/code-analyzer-retirejs-engine": "0.14.0",
"@salesforce/core": "^5",
"@salesforce/sf-plugins-core": "^5.0.4",
"@salesforce/ts-types": "^2.0.9",
Expand Down
5 changes: 2 additions & 3 deletions src/lib/viewers/RuleViewer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Ux} from '@salesforce/sf-plugins-core';
import {Rule, RuleType, SeverityLevel} from '@salesforce/code-analyzer-core';
import {Rule, SeverityLevel} from '@salesforce/code-analyzer-core';
import {Display} from '../Display';
import {toStyledHeaderAndBody} from '../utils/StylingUtil';
import {BundleName, getMessage} from '../messages';
Expand Down Expand Up @@ -41,12 +41,11 @@ export class RuleDetailDisplayer extends AbstractRuleDisplayer {
const body = {
engine: rule.getEngineName(),
severity: `${severity.valueOf()} (${SeverityLevel[severity]})`,
type: RuleType[rule.getType()],
tags: rule.getTags().join(', '),
resources: rule.getResourceUrls().join(', '),
description: rule.getDescription()
};
const keys = ['severity', 'engine', 'type', 'tags', 'resources', 'description'];
const keys = ['severity', 'engine', 'tags', 'resources', 'description'];
styledRules.push(toStyledHeaderAndBody(header, body, keys));
}
this.display.displayLog(styledRules.join('\n\n'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
=== 1. StubRule1
severity: 2 (High)
engine: FakeEngine1
type: Standard
tags: Recommended, Security
resources: www.google.com
description: This is the description for a stub rule. Blah blah blah.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
=== 1. StubRule1
severity: 2 (High)
engine: FakeEngine1
type: Standard
tags: Recommended, Security
resources: www.google.com
description: This is the description for a stub rule. Blah blah blah.

=== 2. StubRule2
severity: 4 (Low)
engine: FakeEngine1
type: Flow
tags: CodeStyle, Performance
resources: www.bing.com, www.salesforce.com
description: This is the description for a second stub rule. Blah blah blah.
10 changes: 0 additions & 10 deletions test/lib/actions/ConfigAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,56 +655,48 @@ class StubEngine1 extends EngineApi.Engine {
return Promise.resolve([{
name: 'Stub1Rule1',
severityLevel: EngineApi.SeverityLevel.Info,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "CodeStyle"],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule2',
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: ["CodeStyle"],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule3',
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["BestPractices"],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule4',
severityLevel: EngineApi.SeverityLevel.High,
type: EngineApi.RuleType.Standard,
tags: ["CodeStyle"],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule5',
severityLevel: EngineApi.SeverityLevel.High,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "CodeStyle"],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule6',
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["Recommended"],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule7',
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: [],
description: 'Generic description',
resourceUrls: []
}, {
name: 'Stub1Rule8',
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: ['Recommended'],
description: 'Generic description',
resourceUrls: []
Expand All @@ -731,7 +723,6 @@ class StubEngine2 extends EngineApi.Engine {
return Promise.resolve([{
name: 'Stub2Rule1',
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: ['Security'],
description: 'Generic description',
resourceUrls: []
Expand All @@ -758,7 +749,6 @@ class StubEngine3 extends EngineApi.Engine {
return Promise.resolve([{
name: 'Stub3Rule1',
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: ['CodeStyle'],
description: 'Generic description',
resourceUrls: []
Expand Down
19 changes: 4 additions & 15 deletions test/stubs/StubEnginePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,39 +93,34 @@ export class StubEngine1 extends EngineApi.Engine {
{
name: "stub1RuleA",
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "CodeStyle"],
description: "Some description for stub1RuleA",
resourceUrls: ["https://example.com/stub1RuleA"]
},
{
name: "stub1RuleB",
severityLevel: EngineApi.SeverityLevel.High,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "Security"],
description: "Some description for stub1RuleB",
resourceUrls: ["https://example.com/stub1RuleB"]
},
{
name: "stub1RuleC",
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "Performance", "Custom"],
description: "Some description for stub1RuleC",
resourceUrls: ["https://example.com/stub1RuleC"]
},
{
name: "stub1RuleD",
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["CodeStyle"],
description: "Some description for stub1RuleD",
resourceUrls: ["https://example.com/stub1RuleD"]
},
{
name: "stub1RuleE",
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.Standard,
tags: ["Performance"],
description: "Some description for stub1RuleE",
resourceUrls: ["https://example.com/stub1RuleE", "https://example.com/stub1RuleE_2"]
Expand Down Expand Up @@ -178,23 +173,20 @@ export class StubEngine2 extends EngineApi.Engine {
{
name: "stub2RuleA",
severityLevel: EngineApi.SeverityLevel.Moderate,
type: EngineApi.RuleType.DataFlow,
tags: ["Recommended", "Security"],
description: "Some description for stub2RuleA",
resourceUrls: ["https://example.com/stub2RuleA"]
},
{
name: "stub2RuleB",
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.DataFlow,
tags: ["Performance", "Custom"],
description: "Some description for stub2RuleB",
resourceUrls: ["https://example.com/stub2RuleB"]
},
{
name: "stub2RuleC",
severityLevel: EngineApi.SeverityLevel.High,
type: EngineApi.RuleType.DataFlow,
tags: ["Recommended", "BestPractice"],
description: "Some description for stub2RuleC",
resourceUrls: [] // Purposely putting in nothing here
Expand Down Expand Up @@ -267,7 +259,7 @@ abstract class BaseTimeableEngine extends EngineApi.Engine {
private selectionWaitTime: number;
private executionWaitTime: number;

constructor(config: EngineApi.ConfigObject) {
constructor(_config: EngineApi.ConfigObject) {
super();
this.selectionWaitTime = 0;
this.executionWaitTime = 0;
Expand Down Expand Up @@ -306,15 +298,14 @@ abstract class BaseTimeableEngine extends EngineApi.Engine {
{
name: "stub1RuleA",
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "CodeStyle"],
description: "Some description for stub1RuleA",
resourceUrls: ["https://example.com/stub1RuleA"]
}
];
}

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

constructor(config: EngineApi.ConfigObject) {
constructor(_config: EngineApi.ConfigObject) {
super();
}

Expand All @@ -384,15 +375,14 @@ export class EventConfigurableEngine1 extends EngineApi.Engine {
{
name: "stub1RuleA",
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["Recommended", "CodeStyle"],
description: "Some description for stub1RuleA",
resourceUrls: ["https://example.com/stub1RuleA"]
}
]);
}

async runRules(ruleNames: string[], runOptions: EngineApi.RunOptions): Promise<EngineApi.EngineRunResults> {
async runRules(_ruleNames: string[], _runOptions: EngineApi.RunOptions): Promise<EngineApi.EngineRunResults> {
for (const {logLevel, message} of this.events) {
this.emitEvent<EngineApi.LogEvent>({
type: EngineApi.EventType.LogEvent,
Expand Down Expand Up @@ -447,7 +437,6 @@ export class TargetDependentEngine1 extends EngineApi.Engine {
return {
name: `ruleFor${fileOrFolder}`,
severityLevel: EngineApi.SeverityLevel.Low,
type: EngineApi.RuleType.Standard,
tags: ["Recommended"],
description: `Rule synthesized for target "${fileOrFolder}`,
resourceUrls: [`https://example.com/${fileOrFolder}`]
Expand Down
10 changes: 1 addition & 9 deletions test/stubs/StubRules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Rule, RuleType, SeverityLevel} from '@salesforce/code-analyzer-core';
import {Rule, SeverityLevel} from '@salesforce/code-analyzer-core';

export class StubRule1 implements Rule {
public getName(): string {
Expand All @@ -17,10 +17,6 @@ export class StubRule1 implements Rule {
return `2 (High)`;
}

public getType(): RuleType {
return RuleType.Standard;
}

public getFormattedType(): string {
return "Standard";
}
Expand Down Expand Up @@ -63,10 +59,6 @@ export class StubRule2 implements Rule {
return `4 (Low)`;
}

public getType(): RuleType {
return RuleType.Flow;
}

public getFormattedType(): string {
return "Flow";
}
Expand Down
Loading