Archive for March, 2010
Sonar: Understanding your codebase
Large code bases can be difficult to understand, particularly for a new joiner to a team. Reading code is a great way to get the detail, but getting a high-level view can sometimes be hard. There are a range of open source tools that can provide Information about code coverage, design attributes and complexity, but it is often hard to extract the useful information from the volume of data produced by these tools. Critically it can sometimes be hard to visualise how this key information changes over time, and so get an idea of how your codebase is evolving.
I’ve been experimenting recently with Sonar. Sonar provides a neat dashboard for viewing data about your project generated by tools such as PMD and Findbugs. It is fed by a build task that runs these tools in your build and uploads data in to the Sonar database. The really cool part of this, is that over time you can use Sonar to see trends in your codebase.
Take a look at this demo site for an example http://nemo.sonarsource.org/timemachine/index/14 showing Tapestry 5 metrics:

Between January and March you can see an increase in complexity but a decrease in code coverage. Through Sonar’s different views, you can look at projects from a module, package or class level and understand hotspots that are contributing to the trend. It really is quite a valuable tool.
How do I set it up
If you use Maven then it is easy, just set up a server and then run:
mvn sonar:sonar
Non Maven users aren’t left out, check out Sonar Light mode.