This extension utilizes the cppcheck static code analyzer to provide C and C++ code analysis within Visual Studio Code.
- Run cppcheck for a single file.
- Run cppcheck for the entire workspace.
- On the fly linting within the code editor.
Cppcheck must be installed. Any version may be used. The extension will try to locate the cppcheck
executable if
possible. On Windows, it will search the 32-bit and 64-bit Program Files directories. On Linux and macOS, several
bin directories will be searched.
If cppcheck
is not found, cppcheck.cppcheckPath
must be set to the correct location of the executable.
Cppcheck is available for download at cppcheck.sourceforge.net
.
For Ubuntu users, Cppcheck is available via apt-get
.
sudo apt-get install cppcheck
For macOS users, Cppcheck can most easily be installed using Homebrew.
brew install cppcheck
The linter can be enabled by setting 'cppcheck.lintingEnabled' to true. This can be done either globally in user settings, or per-workspace in workspace settings. The current recommendation is to enable linting per-workspace.
cppcheck.enable
: Enable/disable the analyzer.cppcheck.cppcheckPath
: The path to the cppcheck executable.cppcheck.includePaths
: The paths to any include directories.cppcheck.platform
: The compilation platform. This determines data types and sizes (e.g. sizeof(int)).cppcheck.standard
: The language standard to use (e.g. c++11).cppcheck.define
: Symbols to define for the preprocessor.cppcheck.undefine
: Symbols to undefine for the preprocessor.cppcheck.suppressions
: Any cppcheck rules to suppress (see the cppcheck manual).cppcheck.verbose
: Enable verbose output from cppcheck.cppcheck.force
: Enable forcefully analyzing all possible configurations through cppcheck.cppcheck.showStatusBarItem
: Show/hide the status bar item for displaying analyzer commands.cppcheck.lintingEnabled
: Whether to enable automatic linting for C/C++ code. Linting runs on workspace changes and file saves.cppcheck.outputCommandLine
: Whether to output the command line used to invoke Cppcheck.cppcheck.language
: Force 'cppcheck' to check all files as the given language.cppcheck.inconclusive
: Allow reporting even though analysis is inconclusive. May lead to false positives.cppcheck.projectFile
: Analyzes CMake or Visual Studio projects.cppcheck.severityLevels
: Maps the severity levels of cppcheck to VSCode severity levels (Error, Warning, Information, Hint). Setting to 'None' will not show the severity type at all.cppcheck.hideProgressMessages
: Whether to hide analyzer progress messages.
When using the includePaths
setting, variables will be expanded once. Anything embedded will be used as is.
In addition to any environment variable being expanded, ${workspaceRoot}
will also be expanded.
- Issue #15 (option to suppress progress messages).
- Issue #16 (c++14 standard).
- Changed the 'Read the manual' command to go to the HTML manual instead of PDF.
- Fixed improper 'inconclusive' and 'verbose' parameter handling.
- Added 'allowInlineSuppressions' as an option, enabled by default.
- Brand new linting engine, with support for inline suppressions.
- Issue #13 (project support).
- Reverted pull #10 via pull #11.
- Merged in pull #12 (paths with spaces and special characters) (thanks to Roelof).
- Fix for issues #7 via pull #12.
- Cleaned up the README.
- Merged in pull #10.
- Feature request #9 (language parameter).
- Added the '--inconclusive' parameter.
- Merged in pull #6 (configurable severity levels) (thanks to Andreas Pazureck).
- Merged in pull #8 (force option) (thanks to Joseph Benden).
- Fix for issue #5 (environment variables).
- Fixed the linter not working when 'cppcheck.verbose' is true.
- Windows 64-bit executable detection (always looks in '%sytemdrive%\Program Files\Cppcheck').
- Actually changed 'cppcheck.enabled' to true instead of just saying it.
- macOS executable detection (thanks to Jason Dreyzehner).
- Changed 'cppcheck.enabled' to true.
- Better documentation about installation (thanks to Jason Dreyzehner).
- Documentation about enabling the linter.
- Added linting directly to the code editor (thanks to Andreas Pazureck).
- Linting is listed in the Problems view for all files in the workspace.
- Added a new setting to automatically show the output channel after running cppcheck (true by default).
- Fix for issue #1 (Doesn't do anything).
- Updated to use the logo from cppcheck (as generously provided by Daniel Marjamäki), instead of blue on white.
- Added links to the cppcheck website and manual.
- Added a command for opening the cppcheck manual on the web.
- Initial release of cppcheck extension.