Skip to content
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
2 changes: 1 addition & 1 deletion SHA256.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ make sure that their SHA values match the values in the list below.
shasum -a 256 <location_of_the_downloaded_file>

3. Confirm that the SHA in your output matches the value in this list of SHAs.
86a417c38f40fec2f21bcafb12f418e0b982b2bf037181f7596797d6e5ae0bf7 ./extensions/sfdx-code-analyzer-vscode-1.12.0.vsix
e30c80e4f11990634c3a8dfe670063c8fc87dabced547375adf49dec8d01e88c ./extensions/sfdx-code-analyzer-vscode-1.13.0.vsix
4. Change the filename extension for the file that you downloaded from .zip to
.vsix.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 56 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"color": "#ECECEC",
"theme": "light"
},
"version": "1.13.0",
"version": "1.14.0",
"publisher": "salesforce",
"license": "BSD-3-Clause",
"engines": {
Expand Down Expand Up @@ -154,6 +154,61 @@
"markdownDescription": "Selection of rules used to scan your code with Code Analyzer.\n\nSelect rules using their name, engine name, severity level, tag, or a combination. Use commas for unions (such as \"Security,Performance\") and colons for intersections (such as \"pmd:Security\" or \"eslint:3\").\n\nThis setting is equivalent to the `--rule-selector` flag of the CLI commands. See [examples](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_code-analyzer_commands_unified.htm#cli_reference_code-analyzer_rules_unified)."
}
}
},
{
"title": "Diagnostic Levels",
"properties": {
"codeAnalyzer.severity 1": {
"type": "string",
"enum": [
"Error",
"Warning",
"Info"
],
"default": "Warning",
"markdownDescription": "Diagnostic level for severity 1 violations (highest severity)."
},
"codeAnalyzer.severity 2": {
"type": "string",
"enum": [
"Error",
"Warning",
"Info"
],
"default": "Warning",
"markdownDescription": "Diagnostic level for severity 2 violations."
},
"codeAnalyzer.severity 3": {
"type": "string",
"enum": [
"Error",
"Warning",
"Info"
],
"default": "Warning",
"markdownDescription": "Diagnostic level for severity 3 violations."
},
"codeAnalyzer.severity 4": {
"type": "string",
"enum": [
"Error",
"Warning",
"Info"
],
"default": "Warning",
"markdownDescription": "Diagnostic level for severity 4 violations."
},
"codeAnalyzer.severity 5": {
"type": "string",
"enum": [
"Error",
"Warning",
"Info"
],
"default": "Warning",
"markdownDescription": "Diagnostic level for severity 5 violations (lowest severity)."
}
}
}
],
"menus": {
Expand Down
19 changes: 16 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,20 @@ export async function activate(context: vscode.ExtensionContext): Promise<SFCAEx
const externalServiceProvider: ExternalServiceProvider = new ExternalServiceProvider(logger, context);
const telemetryService: TelemetryService = await externalServiceProvider.getTelemetryService();
const orgConnectionService: OrgConnectionService = await externalServiceProvider.getOrgConnectionService();
const diagnosticManager: DiagnosticManager = new DiagnosticManagerImpl(diagnosticCollection);
const diagnosticManager: DiagnosticManager = new DiagnosticManagerImpl(diagnosticCollection, settingsManager);
vscode.workspace.onDidChangeTextDocument(e => diagnosticManager.handleTextDocumentChangeEvent(e));

// Listen for severity setting changes and refresh diagnostics
vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('codeAnalyzer.severity 1') ||
e.affectsConfiguration('codeAnalyzer.severity 2') ||
e.affectsConfiguration('codeAnalyzer.severity 3') ||
e.affectsConfiguration('codeAnalyzer.severity 4') ||
e.affectsConfiguration('codeAnalyzer.severity 5')) {
diagnosticManager.refreshDiagnostics();
}
});

context.subscriptions.push(diagnosticManager);
const scanManager: ScanManager = new ScanManager(); // TODO: We will be moving more of scanning stuff into the scan manager soon
context.subscriptions.push(scanManager);
Expand All @@ -100,7 +112,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<SFCAEx
const fileHandler: FileHandler = new FileHandlerImpl();
const codeAnalyzer: CodeAnalyzer = new CodeAnalyzerImpl(cliCommandExecutor, settingsManager, display, fileHandler);

const codeAnalyzerRunAction: CodeAnalyzerRunAction = new CodeAnalyzerRunAction(taskWithProgressRunner, codeAnalyzer, diagnosticManager, telemetryService, logger, display, windowManager);
const diagnosticFactory = (diagnosticManager as DiagnosticManagerImpl).diagnosticFactory;
const codeAnalyzerRunAction: CodeAnalyzerRunAction = new CodeAnalyzerRunAction(taskWithProgressRunner, codeAnalyzer, diagnosticManager, diagnosticFactory, telemetryService, logger, display, windowManager);

// For performance reasons, it's best to kick this off in the background instead of await the promise.
void performValidationAndCaching(codeAnalyzer, display);
Expand Down Expand Up @@ -244,7 +257,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<SFCAEx
// == Apex Guru Integration Functionality
// =================================================================================================================
const apexGuruService: ApexGuruService = new LiveApexGuruService(orgConnectionService, fileHandler, logger);
const apexGuruRunAction: ApexGuruRunAction = new ApexGuruRunAction(taskWithProgressRunner, apexGuruService, diagnosticManager, telemetryService, display);
const apexGuruRunAction: ApexGuruRunAction = new ApexGuruRunAction(taskWithProgressRunner, apexGuruService, diagnosticManager, diagnosticFactory, telemetryService, display);
apexGuruService.onAccessChange((access: ApexGuruAccess) => {
logger.debug(`Access to ApexGuru has been set '${access}'.`);
void vscode.commands.executeCommand('setContext', Constants.CONTEXT_VAR_SHOULD_SHOW_APEX_GURU_BUTTONS,
Expand Down
10 changes: 6 additions & 4 deletions src/lib/apexguru/apex-guru-run-action.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import * as Constants from "../constants"
import { ProgressReporter, TaskWithProgressRunner } from "../progress";
import { CodeAnalyzerDiagnostic, DiagnosticManager, Violation } from "../diagnostics";
import { CodeAnalyzerDiagnostic, DiagnosticFactory, DiagnosticManager, Violation } from "../diagnostics";
import { TelemetryService } from "../external-services/telemetry-service";
import { Display } from "../display";
import { messages } from "../messages";
Expand All @@ -12,17 +12,19 @@ export class ApexGuruRunAction {
private readonly taskWithProgressRunner: TaskWithProgressRunner;
private readonly apexGuruService: ApexGuruService;
private readonly diagnosticManager: DiagnosticManager;
private readonly diagnosticFactory: DiagnosticFactory;
private readonly telemetryService: TelemetryService;
private readonly display: Display;

constructor(taskWithProgressRunner: TaskWithProgressRunner, apexGuruService: ApexGuruService, diagnosticManager: DiagnosticManager, telemetryService: TelemetryService, display: Display) {
constructor(taskWithProgressRunner: TaskWithProgressRunner, apexGuruService: ApexGuruService, diagnosticManager: DiagnosticManager, diagnosticFactory: DiagnosticFactory, telemetryService: TelemetryService, display: Display) {
this.taskWithProgressRunner = taskWithProgressRunner;
this.apexGuruService = apexGuruService;
this.diagnosticManager = diagnosticManager;
this.diagnosticFactory = diagnosticFactory;
this.telemetryService = telemetryService;
this.display = display;
}

/**
* Runs apex guru analysis against the specified file and displays the results.
* @param commandName The command being run
Expand Down Expand Up @@ -54,7 +56,7 @@ export class ApexGuruRunAction {
increment: 90
});

const diagnostics: CodeAnalyzerDiagnostic[] = violations.map(v => CodeAnalyzerDiagnostic.fromViolation(v));
const diagnostics: CodeAnalyzerDiagnostic[] = violations.map(v => this.diagnosticFactory.fromViolation(v));

const oldApexGuruDiagnostics: CodeAnalyzerDiagnostic[] = this.diagnosticManager.getDiagnosticsForFile(fileUri)
.filter(d => d.violation.engine === APEX_GURU_ENGINE_NAME);
Expand Down
16 changes: 9 additions & 7 deletions src/lib/code-analyzer-run-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import {Logger} from "./logger";
import {CodeAnalyzerDiagnostic, DiagnosticManager, normalizeViolation, Violation} from "./diagnostics";
import {CodeAnalyzerDiagnostic, DiagnosticFactory, DiagnosticManager, normalizeViolation, Violation} from "./diagnostics";
import {messages} from "./messages";
import {TelemetryService} from "./external-services/telemetry-service";
import * as Constants from './constants';
Expand All @@ -18,16 +18,18 @@ export class CodeAnalyzerRunAction {
private readonly taskWithProgressRunner: TaskWithProgressRunner;
private readonly codeAnalyzer: CodeAnalyzer;
private readonly diagnosticManager: DiagnosticManager;
private readonly diagnosticFactory: DiagnosticFactory;
private readonly telemetryService: TelemetryService;
private readonly logger: Logger;
private readonly display: Display;
private readonly windowManager: WindowManager;
private suppressedErrors: Set<string> = new Set();

constructor(taskWithProgressRunner: TaskWithProgressRunner, codeAnalyzer: CodeAnalyzer, diagnosticManager: DiagnosticManager, telemetryService: TelemetryService, logger: Logger, display: Display, windowManager: WindowManager) {
constructor(taskWithProgressRunner: TaskWithProgressRunner, codeAnalyzer: CodeAnalyzer, diagnosticManager: DiagnosticManager, diagnosticFactory: DiagnosticFactory, telemetryService: TelemetryService, logger: Logger, display: Display, windowManager: WindowManager) {
this.taskWithProgressRunner = taskWithProgressRunner;
this.codeAnalyzer = codeAnalyzer;
this.diagnosticManager = diagnosticManager;
this.diagnosticFactory = diagnosticFactory;
this.telemetryService = telemetryService;
this.logger = logger;
this.display = display;
Expand Down Expand Up @@ -90,18 +92,18 @@ export class CodeAnalyzerRunAction {
// past the length of the line in the editor window).
const diagnostics: CodeAnalyzerDiagnostic[] = violationsWithFileLocation
.map(v => normalizeViolation(v)) // <-- Maybe in the future we'll pass in the lineLengths for the primary file
.map(v => CodeAnalyzerDiagnostic.fromViolation(v));
.map(v => this.diagnosticFactory.fromViolation(v));
const targetedFiles: string[] = await workspace.getTargetedFiles();
// Before adding in the new code analyzer diagnostics, we clear all the old code analyzer diagnostics

// Before adding in the new code analyzer diagnostics, we clear all the old code analyzer diagnostics
// except for ApexGuru based diagnostics which are handled separately.
for (const file of targetedFiles) {
const diagsToClear: CodeAnalyzerDiagnostic[] =
const diagsToClear: CodeAnalyzerDiagnostic[] =
this.diagnosticManager.getDiagnosticsForFile(vscode.Uri.file(file))
.filter(d => d.violation.engine !== APEX_GURU_ENGINE_NAME);
this.diagnosticManager.clearDiagnostics(diagsToClear);
}

this.diagnosticManager.addDiagnostics(diagnostics);
void this.displayResults(targetedFiles.length, violationsWithFileLocation);

Expand Down
Loading
Loading