Detecting standard coding violation for C ++

I want to make the tool launched by my CI server scan the code and detect the standard encoding violations present based on a specific guide. I will use the output to create the string β€œfail” until the problem is fixed.

The problem is that my engineers spend most of their time in code reviews looking for violations of coding standards and not looking for errors (70-76% of detected defects are related to standards). My theory is that they don’t need to look for violations of the standards that they will branch out depending on what they are looking for.

Is there anything similar?

+4
source share
2 answers

What you want is called static analysis.

2 of them are free:

cppcheck is an open source tool that checks for several types of errors, including the use of STL. cpplint Open source, an automatic check to make sure the C ++ file follows the Google C ++ style.

Then, some compilation compilers include static analysis: Visual Studio (Team System and higher) Intel compiler (I heard that it is very customizable, but I haven't used it yet)

+2
source

If there are problems with code formatting, you can force the call of code decoders in checkin to the repository (astyle, indent, ...)

The next PC-lint / Flexelint tool , which also has rules for applying various standard encoding rules. But he is not free. You should familiarize yourself with it and configure it correctly to avoid false positives.

You can also check Vera ++ , but I have no experience with it.

0
source

All Articles