From 490876baee0931348c43acbcbc3b7decf3fb825e Mon Sep 17 00:00:00 2001 From: davidramnero Date: Thu, 13 Nov 2025 14:35:12 +0100 Subject: [PATCH 1/2] feature #6: support for project file --- src/extension.ts | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index f449756..a6fce95 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -192,16 +192,28 @@ async function runCppcheckOnFileXML( return arg; }); - const args = [ - '--enable=all', - '--xml', - '--xml-version=2', - standardArg, - ...extraArgsParsed, - filePath.replace(/\\/g, '/') - ].filter(Boolean); - - const proc = cp.spawn(commandPath, args); + let proc; + if (extraArgs.includes("--project")) { + const args = [ + '--enable=all', + '--xml', + '--xml-version=2', + `--file-filter=${filePath.replace(/\\/g, '/')}`, + standardArg, + ...extraArgsParsed + ].filter(Boolean); + proc = cp.spawn(commandPath, args); + } else { + const args = [ + '--enable=all', + '--xml', + '--xml-version=2', + standardArg, + ...extraArgsParsed, + filePath.replace(/\\/g, '/') + ].filter(Boolean); + proc = cp.spawn(commandPath, args); + } // if spawn fails (e.g. ENOENT or permission denied) proc.on("error", (err) => { From 045d86b2fab508479821c0b35b501ae7ce5b260b Mon Sep 17 00:00:00 2001 From: davidramnero Date: Thu, 13 Nov 2025 14:41:15 +0100 Subject: [PATCH 2/2] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab2667d..9e65e18 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - **Configurable severity threshold**: Filter out messages below a chosen severity level (`info`, `warning`, or `error`). - **Set C/C++ standard**: Easily specify `--std=` (e.g. `c++17`, `c99`, etc.). - **Diagnostic cleanup**: When you close a file, its diagnostics are automatically cleared. - +- **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. ## Requirements **Cppcheck** must be installed on your system.