From 0cfd7e2ba8c06868d64ca44698675ee1507bcd7c Mon Sep 17 00:00:00 2001 From: davidramnero Date: Sun, 14 Dec 2025 12:56:10 +0100 Subject: [PATCH 1/2] fix / show checkers report warning --- src/extension.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 1c6a0e3..233b98e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -24,7 +24,8 @@ const criticalWarningTypes = [ 'preprocessorErrorDirective', 'syntaxError', 'unhandledChar', - 'unknownMacro' + 'unknownMacro', + 'checkersReport' ]; function parseSeverity(str: string): vscode.DiagnosticSeverity { @@ -270,11 +271,11 @@ async function runCppcheckOnFileXML( for (const e of errors) { const isCriticalError = criticalWarningTypes.includes(e.$.id); const locations = e.location || []; - if (!locations.length) { + if (!isCriticalError && !locations.length) { continue; } - const mainLoc = locations[locations.length - 1].$; + const mainLoc = locations.length ? locations[locations.length - 1]?.$ : []; // If main location is not current file, then skip displaying warning unless it is critical if (!isCriticalError && !filePath.endsWith(mainLoc.file)) { From f51dddce4e0ecf5e8008a69212a9c291e499ceb8 Mon Sep 17 00:00:00 2001 From: davidramnero Date: Sun, 14 Dec 2025 12:59:46 +0100 Subject: [PATCH 2/2] fixed some implicit null to zero conversions --- src/extension.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 233b98e..4c22832 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -278,12 +278,12 @@ async function runCppcheckOnFileXML( const mainLoc = locations.length ? locations[locations.length - 1]?.$ : []; // If main location is not current file, then skip displaying warning unless it is critical - if (!isCriticalError && !filePath.endsWith(mainLoc.file)) { + if (!isCriticalError && !filePath.endsWith(mainLoc?.file)) { continue; } // Cppcheck line number is 1-indexed, while VS Code uses 0-indexing - let line = Number(mainLoc.line) - 1; + let line = Number(mainLoc?.line ?? 0) - 1; // Invalid line number usually means non-analysis output if (isNaN(line) || line < 0 || line >= document.lineCount) { if (isCriticalError) { @@ -294,7 +294,7 @@ async function runCppcheckOnFileXML( } // Cppcheck col number is 1-indexed, while VS Code uses 0-indexing - let col = Number(mainLoc.column) - 1; + let col = Number(mainLoc?.column ?? 0) - 1; if (isNaN(col) || col < 0 || col > document.lineAt(line).text.length) { col = 0; }