Friday, August 27, 2010

Killer tool: Sonar

Today a colleague at work showed Sonar to me, and I must say that I was really impressed! Sonar is an open source code quality analysis tool that uses a number of popular Java code analyzers like PMD, CheckStyle, FindBugs and Cobertura under the hood, and presents the metrics calculated by all of these in a consistent and integrated way. It also keeps track of all the metrics data in a database so you can see how your code quality evolves.

One part of Sonar is a Web front-end for the metrics database, and the other part is a Maven plugin that runs all code analyzers and pumps the collected data into that database. (As an aside: imagine how much harder it would be to develop a tool like this if there wasn't a dominant build solution in the Java space like Maven.)


As a package Sonar just ticks all the right boxes. It's really easy to get up and running (starting its DB/Web server and running mvn clean install sonar:sonar in your Maven project is all there is to it), feels absolutely solid, has a friendly UI and looks very polished overall.

Warmly recommended!

3 comments:

  1. I couldn't agree more!

    Sometimes it would be a pain in the *ss to setup a Hudson machine and get all the plugins like PMD, Cobertura, etc.. to work correctly and show the correct results. Now it's just a matter of adding the sonar dependency to your Maven project and simply adding it in the Hudson configuration. The result: a very polished and user-friendly web page including all the results you would ever require for reporting. It could easily be used by Project managers to monitor progress or to include in weekly/monthly progress reports, especially the motion chart! :-)

    ReplyDelete
  2. Is there a reason why one should perform clean install before running the sonar plugin, should 'mvn sonar:sonar' not be enough?

    ReplyDelete
  3. Good point.
    I guess that indeed 'mvn sonar:sonar' should suffice. However, the sonar 2 minutes tutorial also instructs you to do a clean install first: http://docs.codehaus.org/display/SONAR/Install+Sonar#InstallSonar-The2minutestutorial

    ReplyDelete