Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as cp from 'child_process';
import * as path from "path";
import * as xml2js from 'xml2js';

import { documentationLinkMap } from './util/documentation';
import { runCommand } from './util/scripts';
import { resolvePath, findWorkspaceRoot } from './util/path';

Expand Down Expand Up @@ -294,7 +295,11 @@ async function runCppcheckOnFileXML(
const range = new vscode.Range(line, col, line, document.lineAt(line).text.length);
const diagnostic = new vscode.Diagnostic(range, e.$.msg, severity);
diagnostic.source = "cppcheck";
diagnostic.code = e.$.id;
// If we have a link to documentation, include it
diagnostic.code = documentationLinkMap[e.$.id] ? {
value: e.$.id,
target: vscode.Uri.parse(documentationLinkMap[e.$.id])
} : e.$.id;

// Related Information
const relatedInfos: vscode.DiagnosticRelatedInformation[] = [];
Expand Down
16 changes: 16 additions & 0 deletions src/util/documentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const documentationLinkMap : Record<string, string> = {
'constParameterPointer': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/constParameterPointer.md',
'cstyleCast': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/cstyleCast.md',
'dangerousTypeCast': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/dangerousTypeCast.md',
'duplicateExpressionTernary': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/duplicateExpressionTernary.md',
'duplicateValueTernary': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/duplicateValueTernary.md',
'fcloseInLoopCondition': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/fcloseInLoopCondition.md',
'functionConst': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/functionConst.md',
'functionStatic': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/functionStatic.md',
'premium-misra-config': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/premium-misra-config.md',
'preprocessorErrorDirective': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/preprocessorErrorDirective.md',
'truncLongCast': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/truncLongCast.md',
'unknownMacro': 'https://github.com/cppcheck-opensource/cppcheck/blob/main/man/checkers/unknownMacro.md',
};

export { documentationLinkMap };
Loading