From 07a4c26d4139f4b10cd6fe51f2e26f98eb064dbe Mon Sep 17 00:00:00 2001 From: Discookie Date: Thu, 4 Jul 2024 08:28:50 +0000 Subject: [PATCH 1/2] Separate `codechecker.executor` into log and analyze --- package.json | 28 ++++++++++++++++++++++++ src/backend/executor/bridge.ts | 39 ++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index f21bcbd..fc18cbc 100644 --- a/package.json +++ b/package.json @@ -121,12 +121,25 @@ "order": 3 }, "codechecker.executor.arguments": { + "type": "string", + "description": "Additional arguments to CodeChecker's analyze command. For example, if you want to use a config file for CodeChecker pass '--config '. For supported arguments, run `CodeChecker analyze --help`. The command `CodeChecker: Show full command line` command shows the resulting command line.", + "deprecationMessage": "This setting is deprecated. Use `codechecker.analyze.arguments` instead." + }, + "codechecker.analyze.arguments": { "type": "string", "description": "Additional arguments to CodeChecker analyze command. For example, if you want to use a config file for CodeChecker pass '--config '. For supported arguments, run `CodeChecker analyze --help`. The command `CodeChecker: Show full command line` command shows the resulting command line.", "default": "", "order": 4 }, "codechecker.executor.threadCount": { + "type": [ + "number", + "null" + ], + "description": "CodeChecker's thread count - leave empty to use all threads", + "deprecationMessage": "This setting is deprecated. Use `codechecker.analyze.threadCount` instead." + }, + "codechecker.analyze.threadCount": { "type": [ "number", "null" @@ -137,12 +150,22 @@ "order": 5 }, "codechecker.executor.logBuildCommand": { + "type": "string", + "description": "The build command passed to CodeChecker log.", + "deprecationMessage": "This setting is deprecated. Use `codechecker.log.buildCommand` instead." + }, + "codechecker.log.buildCommand": { "type": "string", "description": "The build command passed to CodeChecker log.", "default": "make", "order": 6 }, "codechecker.executor.logArguments": { + "type": "string", + "description": "Additional arguments to CodeChecker log command. For supported arguments, run `CodeChecker log --help`. The command `CodeChecker: Preview CodeChecker log in terminal` command shows the resulting command line.", + "deprecationMessage": "This setting is deprecated. Use `codechecker.log.arguments` instead." + }, + "codechecker.log.arguments": { "type": "string", "description": "Additional arguments to CodeChecker log command. For supported arguments, run `CodeChecker log --help`. The command `CodeChecker: Preview CodeChecker log in terminal` command shows the resulting command line.", "default": "", @@ -164,6 +187,11 @@ "default": true }, "codechecker.executor.runOnSave": { + "type": "boolean", + "description": "Controls auto-run of CodeChecker on save", + "deprecationMessage": "This setting is deprecated. Use `codechecker.analyze.runOnSave` instead." + }, + "codechecker.analyze.runOnSave": { "type": "boolean", "description": "Controls auto-run of CodeChecker on save", "default": true diff --git a/src/backend/executor/bridge.ts b/src/backend/executor/bridge.ts index 4962516..1864dc1 100644 --- a/src/backend/executor/bridge.ts +++ b/src/backend/executor/bridge.ts @@ -185,11 +185,16 @@ export class ExecutorBridge implements Disposable { const reportsFolder = this.getReportsFolder(); - const ccArgumentsSetting = workspace.getConfiguration('codechecker.executor').get('arguments'); + const executorConfig = workspace.getConfiguration('codechecker.executor'); + const analyzeConfig = workspace.getConfiguration('codechecker.analyze'); + + const ccArgumentsSetting = analyzeConfig.has('arguments') ? analyzeConfig.get('arguments') + : executorConfig.has('arguments') ? executorConfig.get('arguments') : undefined; const ccArguments = parseShellArgsAndReplaceVariables(ccArgumentsSetting ?? ''); - const ccThreads = workspace.getConfiguration('codechecker.executor').get('threadCount'); + const ccThreads = analyzeConfig.has('threadCount') ? analyzeConfig.get('threadCount') + : executorConfig.has('threadCount') ? executorConfig.get('threadCount') : undefined; // FIXME: Add support for selecting a specific workspace folder const args = [ @@ -274,17 +279,27 @@ export class ExecutorBridge implements Disposable { return undefined; } + const executorConfig = workspace.getConfiguration('codechecker.executor'); + const logConfig = workspace.getConfiguration('codechecker.log'); + if (buildCommand === undefined) { - buildCommand = getConfigAndReplaceVariables('codechecker.executor', 'logBuildCommand') ?? 'make'; + buildCommand = logConfig.has('buildCommand') + ? getConfigAndReplaceVariables('codechecker.log', 'buildCommand') + : executorConfig.has('logBuildCommand') + ? getConfigAndReplaceVariables('codechecker.executor', 'logBuildCommand') + : undefined; } else { - buildCommand = replaceVariables(buildCommand) ?? 'make'; + buildCommand = replaceVariables(buildCommand); } + buildCommand = buildCommand ?? 'make'; + const workspaceFolder = workspace.workspaceFolders[0].uri.fsPath; const ccFolder = getConfigAndReplaceVariables('codechecker.backend', 'outputFolder') ?? path.join(workspaceFolder, '.codechecker'); - const logArgumentsSetting = workspace.getConfiguration('codechecker.executor').get('logArguments'); + const logArgumentsSetting = logConfig.has('arguments') ? logConfig.get('arguments') + : executorConfig.has('logArguments') ? executorConfig.get('logArguments') : undefined; const logArguments = parseShellArgsAndReplaceVariables(logArgumentsSetting ?? ''); // Use a predefined path as fallback here @@ -326,7 +341,11 @@ export class ExecutorBridge implements Disposable { } private analyzeOnSave() { - const canAnalyzeOnSave = workspace.getConfiguration('codechecker.executor').get('runOnSave'); + const executorConfig = workspace.getConfiguration('codechecker.executor'); + const analyzeConfig = workspace.getConfiguration('codechecker.analyze'); + + const canAnalyzeOnSave = analyzeConfig.has('runOnSave') ? analyzeConfig.get('runOnSave') + : executorConfig.has('runOnSave') ? executorConfig.get('runOnSave') : undefined; // Analyze even if the comp.db doesn't exists, for multi-root workspaces if (!canAnalyzeOnSave) { @@ -402,9 +421,15 @@ export class ExecutorBridge implements Disposable { public async runLogCustomCommand(buildCommand?: string) { if (buildCommand === undefined) { + const executorConfig = workspace.getConfiguration('codechecker.executor'); + const logConfig = workspace.getConfiguration('codechecker.log'); + + const logArguments = logConfig.has('arguments') ? logConfig.get('arguments') + : executorConfig.has('logArguments') ? executorConfig.get('logArguments') : undefined; + buildCommand = await window.showInputBox({ prompt: 'Enter the build command to run with CodeChecker log', - value: getConfigAndReplaceVariables('codechecker.executor', 'logBuildCommand') ?? 'make' + value: logArguments ?? 'make' }); } From 6ea8d8e82d56da983b4f040154ef5793afebdc19 Mon Sep 17 00:00:00 2001 From: Discookie Date: Thu, 4 Jul 2024 08:30:57 +0000 Subject: [PATCH 2/2] Set "lean" config as default --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fc18cbc..c116ce8 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "codechecker.analyze.arguments": { "type": "string", "description": "Additional arguments to CodeChecker analyze command. For example, if you want to use a config file for CodeChecker pass '--config '. For supported arguments, run `CodeChecker analyze --help`. The command `CodeChecker: Show full command line` command shows the resulting command line.", - "default": "", + "default": "--analyzer-config clangsa:mode=shallow", "order": 4 }, "codechecker.executor.threadCount": { @@ -145,7 +145,7 @@ "null" ], "description": "CodeChecker's thread count - leave empty to use all threads", - "default": null, + "default": 4, "minimum": 1, "order": 5 },