Differential Services in Sonar for a Complete Support of Continuous Inspection

One of the main objective for Sonar in 2011 is to go a step further in the support of Continuous Inspection. Indeed, prior to version 2.5, Sonar could already take a snapshot of the overall quality of an application and view the evolution of quality measures across snapshots with the TimeMachine service. But this was not sufficient to provide at quick answers to some very valuable questions such as :

  • what changed in my application over last 30 days ?
  • did quality improve during version 2.7 software increment ?
  • which violations have been created since 1st of January and by who ?
  • how much is new code covered by unit tests ?
  • which projects have increased their technical debt during last 3 months ?


This is why we have decided to add support for what we call differential services in Sonar 2.5 (differential dashboards and new violations) and completed the job in Sonar 2.7 (new code coverage). With this latest version, you’re just two clicks away from those answers :

What changed over the past X days or since version X.Y.Z ?

On a project dashboard, simply pick the desired period in the drop down list “Time changes…” :

When a period is selected, the differential values will appear next to the project measures. So, it’s pretty easy to see for instance how the density of comments has changed in the last 30 days. In the following example, it has increased by 1.2% :

You can define up to five different periods for each projects. The three first periods can be defined in the global Settings page and are the same for all projects :

And two additional periods can be defined in the Settings page of each project.

Which violations have been created ?

In the Violations drilldown page, the same drop down list “Times changes…” is available and can be used to display only newly created violations over a period of time :

When clicking on a file, only newly created violations on this file are displayed :

How much is new code covered by unit tests ?

This functionality requires the SCM Activity plugin. In project dashboard, as soon as a period is selected, a new section appears :

In this example, to get for instance the list of lines of code which have been added over the past 30 days and which are not covered by unit tests, just click on “61.2% line coverage” :

Among projects, which ones have the highest number of new violations ?

In fact this is possible to track changes on any measure and in this examples we track evolution of number of violations, number of lines of code and unit test durations over the past 90 days :

These new services clearly add further control on technical debt management and this is now time to give them a try.

To extend all those tracking services, we are busy working on Sonar 2.8 to provide… the ability to perform manual code reviews !

  • Hi Freddie,

    I love this feature. For me, this feature turns Sonar from an interesting tool, to something that is useful for my teams to proactively manage their quality.

    I do think this feature needs a bit of extension. We need to be able to pick the two records we want to differentiate. By this I mean we need to pick last wednesdays record and compare it to this tuesday’s records to understand the differential created by this iteration’s work. This will ensure the team can know exactly how much things have changed since they started work on this project.

    We can talk later about how to “define teams” so that one teams changes are differentiated from another teams changes within an iteration. :) Happy to talk more about this.

  • Hi Denis, thanks for this feedback. In fact you can define a date in your project settings page if you want to compare your current snapshot with another one … but you still need to relaunch an analysis to get the differential view which is, I guess, what you wanted to avoid. Ability to define what is a team and to provide a team dashboard into Sonar is something we’ve started to thing about with Evgeny … Any input is welcome.

  • @Denis
    @Freddy
    I opened an issue earlier today to track this exact suggestion before I saw the suggestion Denis made. Here’s the issue:

    http://jira.codehaus.org/browse/SONAR-3174

    The use case is such that relaunching an analysis for the change to take effect is not a viable option (at least I wouldn’t say so). Feel free to vote for the issue if you would like Sonar to allow immediate period switching without having to run another analysis.

    I am aware it is quite likely that the request has implications to the underlying data processing engine and might be so difficult to implement that it might never be done, but I would say the requirement is nevertheless valid. I leave it up to others to judge.

Leave a reply


four × = 32