Skip to content

Commit 0cfd7e2

Browse files
committed
fix / show checkers report warning
1 parent 4a518c5 commit 0cfd7e2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/extension.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const criticalWarningTypes = [
2424
'preprocessorErrorDirective',
2525
'syntaxError',
2626
'unhandledChar',
27-
'unknownMacro'
27+
'unknownMacro',
28+
'checkersReport'
2829
];
2930

3031
function parseSeverity(str: string): vscode.DiagnosticSeverity {
@@ -270,11 +271,11 @@ async function runCppcheckOnFileXML(
270271
for (const e of errors) {
271272
const isCriticalError = criticalWarningTypes.includes(e.$.id);
272273
const locations = e.location || [];
273-
if (!locations.length) {
274+
if (!isCriticalError && !locations.length) {
274275
continue;
275276
}
276277

277-
const mainLoc = locations[locations.length - 1].$;
278+
const mainLoc = locations.length ? locations[locations.length - 1]?.$ : [];
278279

279280
// If main location is not current file, then skip displaying warning unless it is critical
280281
if (!isCriticalError && !filePath.endsWith(mainLoc.file)) {

0 commit comments

Comments
 (0)