static-analysiscppcheck

Is there a list of Cppcheck messages?


Our team previously used Lint as a static code analyser, but it became too cluttered and had too much noise.

We are using C++03 with frequent use of Boost, and Lint didn't seem to like Boost (I hear this has become better in later versions). I started looking at other static code analysers and came across Cppcheck and tried it out. I'm very impressed at what it warns about (I've seen about a dozen informationals and style problems).

What I'm interested in is: Is there are a list of all Cppcheck messages that Cppcheck issues, similar to how Lint and PVS-Studio both have a list of their messages? The official Cppcheck website lists:

But I'm more interested in something similar to Lint and PVS-Studio, and similar to how the results are displayed in Visual Studio:

ID | Category/Severity | Text

Solution

  • A list of Cppcheck checks is available at the project's wiki, and as stated there, you can also get the list from the command-line by running:

    $ cppcheck --doc
    

    or

    $ cppcheck --errorlist
    

    The errorlist outputs an XML file with all three things you want. Here's a small example from it:

    <error id="unnecessaryForwardDeclaration" severity="style" msg="The variable &apos;name&apos; forward declaration is unnecessary. Type variable is already declared earlier."/>
    <error id="variableHidingEnum" severity="style" msg="variable &apos;name&apos; hides enumerator with same name"/>
    <error id="unnecessaryQualification" severity="style" msg="The extra qualification &apos;type&apos; is unnecessary and is considered an error by many compilers."/>
    

    To save the output to a file rather than the command window, use:

    cppcheck --errorlist > errorlist.xml