/ OPEN SOURCE, OPENSOURCE, QUALITY, SONAR

Manage the quality of your projects with Sonar

Sonar is a free OpenSource product that provides you with a general dashboard displaying information about the codebase of each configured project, such as:

  • Number of failed tests,
  • % of code coverage,
  • % of rules compliance (more later),
  • % of duplicated lines,
  • and much more.

Then you get an additional graphical information showing:

  • a square for the size of your project’s codebase relative to the entire codebase’s size,
  • a color (from red to green) for the % of rules compliance.

Sonar Dashboard screenshot

Yet, what are considered rules compliance? These are rules defined by products you (may) already know:

Sonar provides you with the means to configure these rules in 3 categories: mandatory _(error), _optional (warning) or inactive. Some rules can even be configured with parameters, i.e: the maximum number of lines of a method. In this case, you can override the default value.

Sonar uses two modules:

  • a Maven plugin that does the real analysis,
  • a web application for configuring rules and displaying information.

Analysis results are saved in a database. This enables to you to display the trend of your projects. In Sonar, it is called the Time Machine: if codebase’size stays the same, are there more violations? Or if the codebase’s size increases, does the number of violations increases too?

Sonar Dashboard screenshot

By default, Sonar uses a Derby (sorry, JavaDB) database but it can easily be configured with a 3rd party database such as Sun MySQL.

Sonar is very simple to use. Just type this line on your Maven2 project directory to do the analysis:

mvn clean install org.codehaus.sonar:sonar-maven-plugin:1.5.1:sonar

The web application must be separately installed but the install process is on par with the analysis. You can have a running Sonar instance in less than 2 minutes (I did it, so anyone can do!).

Since Sonar is a Maven plugin, it should be a breeze to integrate the analysis on a Continuous Integration platform.

All in all, Sonar is a nice easy-to-use product intended for quality managers, project managers and architects alike. Some features, such as the Time Machine, are not provided by any other OpenSource projects that I know of. If you already use one of Checkstyle / PMD / Findbugs, I can’t recommend enough taking a very thorough look at Sonar, you won’t regret it.

Nicolas Fränkel

Nicolas Fränkel

Developer Advocate with 15+ years experience consulting for many different customers, in a wide range of contexts (such as telecoms, banking, insurances, large retail and public sector). Usually working on Java/Java EE and Spring technologies, but with focused interests like Rich Internet Applications, Testing, CI/CD and DevOps. Also double as a trainer and triples as a book author.

Read More
Manage the quality of your projects with Sonar
Share this