Add Ceedling task for analyzing code with Cppcheck.
Clone this into Ceedling's plugin folder of your current project.
$ cd <your-project>/vendor/ceedling/plugins
$ git clone https://github.com/deltalejo/cppcheck-ceedling-plugin.git cppcheckAdd the plugins path to your project.yml if you have not done it yet.
Then add cppcheck plugin to the enabled plugins list:
:plugins:
:load_paths:
- vendor/ceedling/plugins
:enabled:
- cppcheckAdd cppcheck section to your project.yml specifying configuration options.
e.g:
:cppcheck:
:reports:
- html
:addons:
- misraThree types of reports are available:
- text
- xml
- html
They can be enabled by listing them on the :reports list:
:cppcheck:
:reports:
- text
- htmlArtifact file and output format can be configured:
:cppcheck:
:text_artifact_filename: CppcheckResults.txt
:template: gcc:template can be any of the ones included with Cppcheck or custom format string.
Artifact file can be configured:
:cppcheck:
:xml_artifact_filename: CppcheckResults.xmlHTML title can be configured:
:cppcheck:
:html_title: Awesome ProjectNotes:
- This report requires the
cppcheck-htmlreporttool to be available. - This report implies the
xmlreport.
You can import some project files and build configurations into Cppcheck. Some of compatible files are:
- Cppcheck GUI project (*.cppcheck)
- Compile Commands (compile_commands.json)
- Visual Studio projects (*.vcxproj, *.sln)
:cppcheck:
:project: path/to/compile_commands.jsonNote: If configured, Cppcheck won't look for sources and includes paths from Ceedling configuration files.
:cppcheck:
:defines:
- A
- B
- C=1:cppcheck:
:undefines:
- A
- B
- CNote: By default TEST is undefined so the analysis is performed against production code.
Force inclusion of files before checked files.
:cppcheck:
:includes:
- file1.h
- file2.hExclude files from the analysis.
:cppcheck:
:excludes:
- file1.c
- file2.cSpecify platform to use for the analysis, can be any of the ones included with Cppcheck, e.g.: unix64, or the path of the platform XML file.
:cppcheck:
:platform: unix64Specify C/C++ language standard.
:cppcheck:
:standard: c99Specify the check level to be used.
- normal
- exhaustive
:cppcheck:
:check_level: exhaustiveAddons to be run.
:cppcheck:
:addons:
- misra
- path/to/addon.pyLocate your rules text file or copy it to your project.
e.g.: <your-project>/misra.txt and create the addon file misra.json inside
your project:
{
"script": "misra",
"args": ["--rule-texts=misra.txt"]
}Enable the addon:
:cppcheck:
:addons:
- misra.jsonEnable additional checks. Default is style.
:cppcheck:
:enable_checks:
- performance
- portabilityNote: These are only used for single file analysis. Whole project analysis always enable all checks.
Disable individual checks:
:cppcheck:
:disable_checks:
- style
- informationInline suppressions are disabled by default, they can be enabled with:
:cppcheck:
:inline_suppressions: trueSuppressions files can be used by giving the search paths and/or files in the
:paths and :files sections of your project.yml respectively.
e.g.:
:paths:
:cppcheck:
- suppressions/
- source/*/suppressions/
:files:
:cppcheck:
- suppressions.xmlBoth XML and text files are supported, and for the latter, the file extension
can be configured. The default is .txt.
e.g.:
:extension:
:cppcheck: .txtThe files that will ultimately be used can be verified with:
$ ceedling files:cppcheckCommand line suppressions can also be added:
:cppcheck:
:suppressions:
- memleak:src/file1.cpp
- exceptNew:src/file1.cppAdd library configuration files:
:cppcheck:
:libraries:
- lib1.cfg
- lib2.cfgRegular expression rules:
:cppcheck:
:rules:
- if \( p \) { free \( p \) ; }For things not covered above, add extra command line options:
:cppcheck:
:options:
- --max-configs=<limit>
- --suppressions-list=<file>Run analysis for all project sources:
$ ceedling cppcheck:allNote: Analysis is run with all checks enabled.
Run analysis for single source file:
$ ceedling cppcheck:<filename>Note: Analysis will run with the checks in :enable_checks list enabled.