4

What I want to do is to have a tool run by my CI server to scan the code and detect any coding standard violations present based on a defined guideline. I will use the output to prompt build "fails" until the issue is fixed.

The problem I have is that my engineers are spending most of their time in code reviews looking for coding standards violations and not looking for bugs (70-76% of defects found are standards related). My theory is if they don't need to look for violations of standards they will branch out as to what they are looking for.

Does anything like this exist?

  • 10
    Maybe your real problem is that your coding standards are too restrictive and counterproductive. – Mankarse Sep 09 '11 at 02:00
  • I disagree, but I have the benefit of knowing the team and the environment (not to mention what is actually covered by our standards). I do feel, however, that I am trying to relieve the team of a burden in favor of more effective code reviews while maintaining code consistency. – clamontagne Sep 09 '11 at 14:26
  • See also: http://stackoverflow.com/questions/93260/a-free-tool-to-check-c-c-source-code-against-a-set-of-coding-standards – jchl Oct 12 '11 at 20:41

2 Answers2

2

What you want is called static analysis

2 of them are free :

cppcheck — Open-source tool that checks for several types of errors, including use of STL. cpplint Open source, automated checker to make sure a C++ file follows Google's C++ style.

Then some comercial compilers include static analysis : Visual Studio (Team system and above) Intel compiler (I've heard it's very customizable, but I haven't personally used it yet)

Dinaiz
  • 2,123
  • 3
  • 21
  • 29
0

If issues related to code formatting - you can enforce invocation of code beautifiers on checkin to repository (astyle, indent, ...)

Next one is PC-lint/Flexelint tool, which also has rules to enforce various coding standard guidelines. But it is non-free. You have to familiarize with it and configure it properly to avoid false positives.

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

Sergei Nikulov
  • 4,812
  • 21
  • 34