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

FIX (Extension) @W-16993912@ Implement Doc Review suggestions + fix partial runs setting bug #146

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
},
{
"command": "sfca.runDfa",
"title": "***SFDX: Run Graph-Engine Based Analysis***"
"title": "SFDX: Scan Project with Graph Engine Path-Based Analysis"
},
{
"command": "sfca.runApexGuruAnalysisOnSelectedFile",
Expand Down Expand Up @@ -169,10 +169,10 @@
"default": false,
"description": "Discover critical problems and performance issues in your Apex code with ApexGuru, which analyzes your Apex files for you. This feature is in a closed pilot; contact your account representative to learn more."
},
"codeAnalyzer.deltaRuns.enabled": {
"codeAnalyzer.partialGraphEngineScans.enabled": {
"type": "boolean",
"default": false,
"description": "***Enable delta run of Salesforce Graph Engine***"
"description": "Partial Salesforce Graph Engine Scans: Enabled"
jag-j marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
Expand All @@ -192,7 +192,7 @@
},
{
"command": "sfca.runDfa",
"when": "true"
"when": "sfca.partialRunsEnabled"
},
{
"command": "sfca.removeDiagnosticsOnActiveFile",
Expand Down
15 changes: 9 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
}

if (SettingsManager.getSfgeDeltaRunsEnabled()) {
await vscode.commands.executeCommand('setContext', 'sfca.partialRunsEnabled', true);
const runDfaOnWorkspaceCmd = vscode.commands.registerCommand(Constants.COMMAND_RUN_DFA, async () => {
await _runDfa(context);
savedFilesCache.clear();
Expand Down Expand Up @@ -212,26 +213,28 @@ export function createTempDirectory(): string {

async function _runDfa(context: vscode.ExtensionContext) {
if (violationsCacheExists()) {
const partialScanText = 'Partial scan: Scan only the code that you changed since the previous scan.';
const fullScanText = 'Full scan: Scan all the code in this project again.';
const choice = await vscode.window.showQuickPick(
['***Yes***', '***No***'],
[partialScanText, fullScanText],
{
placeHolder: '***We identified a previous Salesforce Graph Engine run. Do you want to only run the previously failed violations from that run?***',
placeHolder: 'You previously scanned this code using Salesforce Graph Engine. What kind of scan do you want to run now?',
canPickMany: false,
ignoreFocusOut: true
}
);

// Default to "Yes" if no choice is made
const rerunChangedOnly = choice == '***Yes***';
const rerunChangedOnly = choice == partialScanText;
if (rerunChangedOnly) {
const deltaRunTargets = DeltaRunFunctions.getDeltaRunTarget(sfgeCachePath, savedFilesCache);
if (deltaRunTargets.length == 0) {
void vscode.window.showInformationMessage('***No local changes found that would change the outcome of previous SFGE full run.***');
void vscode.window.showInformationMessage("Your local changes didn't change the outcome of the previous full Salesforce Graph Engine scan.");
return
}
await runDfaOnSelectMethods(context, deltaRunTargets);
} else {
void vscode.window.showWarningMessage('***A full run of the graph engine will happen in the background. You can cancel this by clicking on the status progress.***');
void vscode.window.showWarningMessage('A full Salesforce Graph Engine scan is running in the background. You can cancel it by clicking the progress bar.');
await runDfaOnWorkspace(context);
}
} else {
Expand All @@ -252,7 +255,7 @@ async function runDfaOnSelectMethods(context: vscode.ExtensionContext, selectedM
customCancellationToken.token.onCancellationRequested(async () => {
customCancellationToken?.dispose();
customCancellationToken = null;
await vscode.window.showInformationMessage(messages.graphEngine.noViolationsFound);
await vscode.window.showInformationMessage(messages.graphEngine.noViolationsFoundForPartialRuns);
return;
});

Expand Down
1 change: 1 addition & 0 deletions src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const messages = {
},
graphEngine: {
noViolationsFound: "Scan was completed. No violations found.",
noViolationsFoundForPartialRuns: "Partial Salesforce Graph Engine scan of the changed code completed, and no violations found. IMPORTANT: You might still have violations in the code that you haven't changed since the previous full scan.",
resultsTab: "Graph Engine Results",
spinnerText: 'Running Graph Engine analysis...',
statusBarName: "Graph Engine Analysis",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ export class SettingsManager {
}

public static getSfgeDeltaRunsEnabled(): boolean {
return vscode.workspace.getConfiguration('codeAnalyzer.deltaRuns').get('enabled');
return vscode.workspace.getConfiguration('codeAnalyzer.partialGraphEngineScans').get('enabled');
}
}
Loading