Skip to content

Commit 561cbc4

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Add config settings for 'codeQL.autofix.path' and 'codeQL.autofix.model'
1 parent 1d203a4 commit 561cbc4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

extensions/ql-vscode/src/config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,3 +954,17 @@ export class GitHubDatabaseConfigListener
954954
await GITHUB_DATABASE_UPDATE.updateValue(value, target);
955955
}
956956
}
957+
958+
const AUTOFIX_SETTING = new Setting("autofix", ROOT_SETTING);
959+
960+
const AUTOFIX_PATH = new Setting("path", AUTOFIX_SETTING);
961+
962+
export function getAutofixPath(): string | undefined {
963+
return AUTOFIX_PATH.getValue<string>() || undefined;
964+
}
965+
966+
const AUTOFIX_MODEL = new Setting("model", AUTOFIX_SETTING);
967+
968+
export function getAutofixModel(): string | undefined {
969+
return AUTOFIX_MODEL.getValue<string>() || undefined;
970+
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type { execFileSync } from "child_process";
2626
import { tryOpenExternalFile } from "../common/vscode/external-files";
2727
import type { VariantAnalysisManager } from "./variant-analysis-manager";
2828
import type { VariantAnalysisResultsManager } from "./variant-analysis-results-manager";
29+
import { getAutofixPath, getAutofixModel } from "../config";
2930

3031
// Limit to three repos when generating autofixes so not sending
3132
// too many requests to autofix. Since we only need to validate
@@ -123,7 +124,7 @@ export async function viewAutofixesForVariantAnalysisResults(
123124
* @throws Error if the AUTOFIX_PATH environment variable is not set or the path does not exist.
124125
*/
125126
async function findLocalAutofix(): Promise<string> {
126-
const localAutofixPath = process.env.AUTOFIX_PATH;
127+
const localAutofixPath = getAutofixPath();
127128
if (!localAutofixPath) {
128129
throw new Error(
129130
"Path to local autofix installation not found. Internal GitHub access required.",
@@ -635,14 +636,19 @@ async function runAutofixOnResults(
635636
workDir: string,
636637
alertNumber?: number, // Optional parameter for specific alert
637638
): Promise<void> {
639+
// Get autofix model from user settings.
640+
const autofixModel = getAutofixModel();
641+
if (!autofixModel) {
642+
throw new Error("Autofix model not found.");
643+
}
638644
// Set up args for autofix command.
639645
const autofixArgs = [
640646
"--sarif",
641647
sarifFile,
642648
"--source-root",
643649
srcRootPath,
644650
"--model",
645-
"capi-dev-4o", // may fail with older versions of cocofix
651+
autofixModel,
646652
"--dev",
647653
"--no-cache",
648654
"--format",

0 commit comments

Comments
 (0)