Static Code Analysers: Keeping necks out of the hangman's noose.

Bugs get introduced into source code in a variety of ways, even by the most experienced of developers.  Let’s face it, people are imperfect; so can be the code, especially if that developer is using languages that grant a lot of rope to hang yourself such as C/C++.  Due to this problem companies pay millions of dollars every year to whole Quality Assurance teams to test whatever one developer may write.  Developers themselves spend thousands of hours writing code that is never meant to be releasable to customers, but whose sole purpose in life is to test other code (unit tests).  Even then, bugs can be found in the field damaging a company’s reputation in a hurry, many of which just needed a very simple fix.  What else can be done to stop this?  Thankfully, in recent years a new tool has been added to the development tool belt: Static Code Analysis.

 
Static Code AnalysisStatic Code Analysis consists of special software that runs on source code to look for potential problems, weaknesses, and security threats.  It can point out problems that compilers will miss.  For example, use of possible NULL pointers, divide by zero, and memory corruption.  Another bonus is that the analyzing software can be run on an automated basis like unit tests.  Thereby helping to point out problems soon after then have been committed into the source.

 
Now-a-days there are many different analyzer products.  In fact, Wikipedia provides a whole wiki page dedicated to simply list them (http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis).  Here at Adaptive Computing we are using Coverity which is a great analyzer.  It’s web based interface makes pulling up source from anywhere quick and easy.  Plus, the description for the problem is usually simple to understand and easily filterable.  The biggest problem is its price.  The pricing model is on a per-line basis, so licenses for large software can be higher than what a start-up business could probably afford.  Knowing that, what are some other analysis programs people use that provide good coverage without breaking the bank?

Facebook Twitter Email
  • http://twitter.com/dhh1128 Daniel Hardman

    I’ve had great success just dialing up the warning levels of the compiler. Those warnings often tell you useful things!

  • http://www.facebook.com/Minhenkoj Julia Minchenko

    Very informative!

  • Vladimir Starostenkov

    Here are some nice options:
    cppcheck
    cpplint (google coding style)
    clang static analyzer

    Valgrind for dynamic analysis.