21

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:

  • Out of bounds checking
  • Memory leaks checking
  • Detect possible null pointer dereferences
  • Check for uninitialized variables
  • Check for invalid usage of STL
  • Checking exception safety
  • Warn if obsolete or unsafe functions are used
  • Warn about unused or redundant code
  • Detect various suspicious code indicating bugs

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tas
  • 7,023
  • 3
  • 36
  • 51

1 Answers1

22

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
wovano
  • 4,543
  • 5
  • 22
  • 49
HairyFotr
  • 1,453
  • 1
  • 15
  • 28