Skip to content

Commit ca38df9

Browse files
committed
working
1 parent e388108 commit ca38df9

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
- **On-save linting**: When you save a c/cpp file, `cppcheck` is automatically run on that file.
88
- **Per-file diagnostics**: Only diagnostics relevant to the saved file are displayed.
99
- **Configurable severity threshold**: Filter out messages below a chosen severity level (`info`, `warning`, or `error`).
10-
- **Set C/C++ standard**: Easily specify `--std=<id>` (e.g. `c++17`, `c99`, etc.).
1110
- **Diagnostic cleanup**: When you close a file, its diagnostics are automatically cleared.
1211
- **Project file support**: You can feed your project file to cppcheck through the `--project` flag in the `cppcheck-official.arguments` field in the extension settings.
1312
- **Warning notes**: Display notes for warnings when those are available
14-
13+
- **Dynamic config**: The extension can run scripts that outputs arguments to be used. The extension expects the script to output the value to set the argument to wrapped with \${}, so e.g. with the argument `--project=${path/to/script.sh}` the script will be run and expected to create a compile_commands.json file whose path will be output as such: `${path/to/compile_commands.json}`.
1514
## Requirements
1615

17-
**Cppcheck** must be installed on your system.
16+
**Cppcheck** must be installed on your system.
1817
- By default, this extension looks for `cppcheck` on the system PATH.
1918
- Alternatively, specify a custom executable path using the `cppcheck-official.path` setting.
2019

src/extension.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function activate(context: vscode.ExtensionContext) {
7676
const argType = arg.split("=")[0];
7777
const argValue = arg.split("=")[1];
7878
// Remove ${ from the beginning and slice } away from the end of argValue
79-
const scriptCommand = argValue.split("{")[1].slice(0, - 1);
79+
const scriptCommand = argValue.split("{")[1].split("}")[0];
8080
const scriptOutput = await runScript(scriptCommand);
8181
console.log('scriptOutput', scriptOutput);
8282
// We expect the script output that we are to set the argument to will be wrapped with ${}
@@ -196,7 +196,6 @@ async function runCppcheckOnFileXML(
196196
// Arguments specified with scripts are replaced with script output (dynamicArgs)
197197
const staticArgs = extraArgs.split("--").filter((arg) => !arg.includes("${"));
198198
const allArgs = staticArgs.concat(dynamicArgs);
199-
console.log('all args', allArgs);
200199
// Resolve paths for arguments where applicable
201200
const extraArgsParsed = allArgs.map((arg) => {
202201
if (arg.startsWith('project')) {

src/util/scripts.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ function runScript(scriptCommand: string): Promise<string> {
55
const commandSplit = scriptCommand.split(" ");
66
const scriptLang = commandSplit[0];
77
const scriptPath = resolvePath(commandSplit[1]);
8-
console.log(`executing script ${scriptPath} with language ${scriptLang}`);
98
const workspaceFolder = resolvePath('${workspaceFolder}');
10-
console.log('workspaceFolder', workspaceFolder);
119
// Additional args could be added here, i.e. name of output file if applicable
1210
return new Promise((resolve, reject) => {
1311
execFile(scriptLang, [scriptPath], { cwd: workspaceFolder }, (error, stdout, stderr) => {

0 commit comments

Comments
 (0)