Jump to >

Cppcheck

Cppcheck is a tool that does static analysis on C and C++ code.

Supported File Types

The following are supported by this tool:

  • C/C++: *.c, *.cc, *.cpp, *.cxx, *.c++, *.h, *.hh, *.hpp, *.hxx, *.h++, *.tpp, *.txx

Installation

The cppcheck tool is available in most system package managers.

On Ubuntu/Debian:

$ sudo apt-get install cppcheck

On RHEL/CentOS/Fedora:

$ sudo yum install cppcheck

On macOS using Homebrew:

$ brew install cppcheck

See the Cppcheck downloads page for other options.

Configuration

Cppcheck Location

If the cppcheck command is in a non-standard location, and can’t be found in Review Bot’s PATH environment variable, then you’ll need to specify the path in the Review Bot worker config file:

exe_paths = {
    'cppcheck': '/path/to/cppcheck',
}

You will need to restart the Review Bot worker after making this change.

Enabling Cppcheck in Review Board

First, you’ll need to add a Review Bot configuration in Review Board (see Tool Configurations).

The following configuration options are available:

Enable standard style checks:

Enable this checkbox if you want to check for style-related issues, which will include code style, warning, and performance checks.

This is equivalent to cppcheck --enable=style.

Enable all error checks:

Enable this checkbox if you want to include all possible checks.

Note that this may include false positives.

This is equivalent to cppcheck --enable=all.

Force cppcheck to use a specific language (optional):

Force Cppcheck into a mode where it assumes all code is either C or C++. By default, the language is auto-detected.

This is equivalent to cppcheck --language=c or cppcheck --language=c++.