Skip to content

Commit 5dfaf3f

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Set up to run autofix on repo results
1 parent 4d5437f commit 5dfaf3f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

extensions/ql-vscode/src/variant-analysis/view-autofixes.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { spawn } from "child_process";
2929
// a handle of autofixes for each query, this should be sufficient.
3030
// Consider increasing this in the future if needed.
3131
const MAX_NUM_REPOS: number = 3;
32+
// Similarly, limit to three fixes per repo.
33+
const MAX_NUM_FIXES: number = 3;
3234

3335
/**
3436
* Generates autofixes for the results of a variant analysis.
@@ -490,6 +492,31 @@ async function runAutofixForRepository(
490492
transcriptFilePath,
491493
fixDescriptionFilePath,
492494
} = await getRepoStoragePaths(autofixOutputStoragePath, nwo);
495+
496+
// Get autofix binary.
497+
// Switch to Go binary in the future and have user pass full path
498+
// in an environment variable instead of hardcoding part here.
499+
const cocofixBin = join(process.cwd(), localAutofixPath, "bin", "cocofix.js");
500+
501+
// Limit number of fixes generated.
502+
const limitFixesBoolean: boolean = resultCount > MAX_NUM_FIXES;
503+
if (limitFixesBoolean) {
504+
void Window.showInformationMessage(
505+
`Only generating autofixes for the first ${MAX_NUM_FIXES} alerts for ${nwo}.`,
506+
);
507+
508+
// Run autofix in a loop for the first MAX_NUM_FIXES alerts.
509+
// Not an ideal solution, but avoids modifying the input SARIF file.
510+
for (let i = 0; i < MAX_NUM_FIXES; i++) {
511+
// TODO: run autofix for the i-th alert.
512+
}
513+
} else {
514+
// TODO: run autofix once for all alerts.
515+
}
516+
517+
// Save output text files from each repo to later merge
518+
// into a single markdown file containing all results.
519+
outputTextFiles.push(outputTextFilePath);
493520
}
494521

495522
/**

0 commit comments

Comments
 (0)