A Cppcheck Docker image based on the official Cppcheck documentation and Docker best practices.
342
A Cppcheck Docker image based on the official Cppcheck documentation and Docker best practices.
The Official Cppcheck repository is https://github.com/cppcheck-opensource/cppcheckβ .
You can analyze your code by mounting the source-code directory into the container at /workspace and passing Cppcheck options directly:
docker run --rm -it \
-v .:/workspace \
maykopetersen/cppcheck:latest \
--output-file=cppcheck-report.xml --xml-version=2 --enable=all --force --max-configs=1 .
π‘Tip
The report generated by
cppcheckcan be used bySonarScannerβ to analyze the code and send the results to SonarQubeβ . If you use SonarQube Community Editionβ you should install the SonarQube C++ Community plugin (cxx plugin)β .
To speed up Cppcheck analysis, run something like this (it is recommended to use /opt/build-dir as the build folder):
docker run --rm -it \
-v .:/workspace/ \
maykopetersen/cppcheck:latest \
--output-file=cppcheck --xml-version=2 --enable=all --force --max-configs=1 --cppcheck-build-dir=/opt/build-dir -j $(nproc) .
You can see all available options by running the --help command:
docker run --rm maykopetersen/cppcheck:latest --help
You can learn more about Cppcheck by reading the official documentationβ .
Cppcheck was built according to the official documentationβ , which says:
The recommended release build is:
make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes CXXOPTS="-O2" CPPOPTS="-DNDEBUG"
Flags
MATCHCOMPILER=yesSeveralTokenmatching patterns are converted into more efficient C++ code at compile time (requires Python 3.7 or later).FILESDIR=/usr/share/cppcheckSpecifies the folder where Cppcheck files (addons, cfg, platform) are installed to.HAVE_RULES=yesFor rules support (requires Perl Compatible Regular Expressions - PCRE)CXXOPTS="-O2"Enables most compiler optimizations.CPPOPTS="-DNDEBUG"Disables assertions.HAVE_BOOST=yesEnables usage of more efficient container from Boost (requires Boost to be installed).
These build options were configured in the CMake build system to match the recommended release build.
Content type
Image
Digest
sha256:0a0848dabβ¦
Size
44.3 MB
Last updated
4 months ago
docker pull maykopetersen/cppcheck