Skip to content

Commit 3aff7b3

Browse files
committed
fix #33 show critical warnings with location other than checked file
1 parent faaa657 commit 3aff7b3

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/extension.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ enum SeverityNumber {
1010
Error = 2
1111
}
1212

13+
const criticalWarningTypes = [
14+
'cppcheckError',
15+
'cppcheckLimit',
16+
'includeNestedTooDeeply',
17+
'internalAstError',
18+
'instantiationError',
19+
'internalError',
20+
'missingFile',
21+
'premium-internalError',
22+
'premium-invalidArgument',
23+
'premium-invalidLicense',
24+
'preprocessorErrorDirective',
25+
'syntaxError',
26+
'unhandledChar',
27+
'unknownMacro'
28+
];
29+
1330
function parseSeverity(str: string): vscode.DiagnosticSeverity {
1431
const lower = str.toLowerCase();
1532
if (lower.includes("error")) {
@@ -257,9 +274,9 @@ async function runCppcheckOnFileXML(
257274
}
258275

259276
const mainLoc = locations[locations.length - 1].$;
260-
261-
// If main location is not current file, then skip displaying warning
262-
if (!filePath.endsWith(mainLoc.file)) {
277+
console.log('error id ', e.$.id, 'error', e);
278+
// If main location is not current file, then skip displaying warning unless it is critical
279+
if (!filePath.endsWith(mainLoc.file) && !criticalWarningTypes.includes(e.$.id)) {
263280
continue;
264281
}
265282

0 commit comments

Comments
 (0)