Sign inSign up

maykopetersen/cppcheck-docker

By maykopetersen

β€’Updated 4 months ago

A Cppcheck Docker image based on the official Cppcheck documentation and Docker best practices.

Image
Security
Developer tools
0

546

maykopetersen/cppcheck-docker repository overview

⁠cppcheck-docker

⁠🀷 What is this?

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⁠.

β πŸ§‘β€πŸ’» How to use?

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-docker:latest \
  --output-file=cppcheck-report.xml --xml-version=2 --enable=all --force --max-configs=1 .

πŸ’‘Tip

The report generated by cppcheck can be used by SonarScanner⁠ 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-docker: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-docker:latest --help

You can learn more about Cppcheck by reading the official documentation⁠.

β πŸ”Ž Details

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=yes Several Token matching patterns are converted into more efficient C++ code at compile time (requires Python 3.7 or later).
  • FILESDIR=/usr/share/cppcheck Specifies the folder where Cppcheck files (addons, cfg, platform) are installed to.
  • HAVE_RULES=yes For rules support (requires Perl Compatible Regular Expressions - PCRE)
  • CXXOPTS="-O2" Enables most compiler optimizations.
  • CPPOPTS="-DNDEBUG" Disables assertions.
  • HAVE_BOOST=yes Enables 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.

Tag summary

Content type

Image

Digest

sha256:bc2a2c993…

Size

44.3 MB

Last updated

4 months ago

docker pull maykopetersen/cppcheck-docker