Static analysis tools – one step closer to writing bugfree software

No developer can write bug-free software. It’s a fact. No matter how good at programming you are, there’s at least one bug per so many lines of your code. 

Concepts like continuous integration, unit test, pair programming and many more are there to aid in creating software that as bug free as possible. Ignoring these and relaying on developer to write bug-free software is plain stupid. The earlier the bug is spotted and fixed the less money it costs. It’s another fact that seems to be somehow overlooked in software writing business.  

Here’s another tool to put into your programming toolbox. Static analysis. An evolution and variation of Lint (Lint was a simple SA tool for C source code), only stronger and better.  You can use it to find common bugs right after piece of code is written. Before software is build and before any test are run. This is the earliest you can catch a possible bug. 

SA tools help you to find bugs by analyzing your source code and searching for bug patterns. Take this JAVA snippet for example:

  1. if ( c != null || c.length > 0 ) { //do stuff }

A very nasty null pointer bug that won’t be picked by compiler. Modern SA tools will pick it up and wave waring flags. 

Looking at what I can use for PHP I found these project interesting: 

PHP-SAT. Although it is still in early stages of development it can provide useful info on your code base. 

PHPLint looks promising too. I haven’t had time to test it, but just from reading documentation it can provide ways of making PHP a strongly typed language, a feature a miss a lot when working with legacy code. 

For JavaScript developers out there: JSLint

For C# development there’s FxCop tool from Microsoft

There’s a SA tool for any commonly used programming language. 

An ideal place to make use of this tools seems to be SVN repository. You can easily add SA to your commit hook and simply refuse to take back code that didn’t pass SA checks.

This entry was posted in Dev and tagged , , . Bookmark the permalink.

2 Responses to Static analysis tools – one step closer to writing bugfree software

  1. empi says:

    Hi. I recently wrote about same thing. It’s nice (and weird) to see that we are into same topics 😉

  2. countzero says:

    great minds think alike

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.