When drilling down from the project dashboard, the resource viewer is the ultimate place to view detailed information on a given resource: file or unit tests file. The power of the tool comes from the fact that the resources can be viewed according to different axes of quality.
Viewing Source Code File
When drilling down into measures, you will eventually reach the file level and will be able to browse the source code.
Sonar is shipped with 6 default tabs. Depending on the plugins you have installed, other tabs may be displayed.
This tab displays source code with highlighted syntax.
To display the recently modified source code or view the last committers, you need to install the SCM Activity Plugin.
The Coverage tab shows the source code annotated with extra information and colors showing the code coverage. In the first column appears the number of hit of the line during execution of unit tests and in the second one the number of conditions covered on the line along with the number of conditions to cover.
When code coverage by integration tests is collected with help of JaCoCo, all IT coverage measures are displayed in this tab:
A drop down list enables to filter the information to show on the viewer:
The violations to display can be filtered by coding rule, severity, etc.
Thanks to the Time changes... list box, you can only display new violations that have been added for a timespan. See Differential Views for more information.
Only the source code around the violations is displayed. If necessary for investigation purpose, you can display the full source code by ticking the Full source box.
You can directly manage the violations and their related reviews: comment, assign, link o an action plan, etc. See Violations and Reviews for more information.
The Duplications tab shows every duplicated chunk of code within a class and the name of the other class it is duplicated with.
How to read the example above: There is duplication between two blocks of 89 lines. The first block in LinesFactory starts at line 50, the second block in DelphiLinesFactory starts at line 59.
The Dependencies tab shows all incoming and outgoing dependencies on the file:
The LCOM4 tab shows blocks of resources within a class that have tight relationship. Having more that one block here probably means that the class is assuming more than one responsibility.
Viewing Unit Tests File
When drilling down into unit tests execution measures, you will eventually reach the unit test class level:
This tab simply displays the source code of your unit test class:
This tab displays the result of the unit tests belonging to the unit tests class.
In case the test failed or was in error, the reason of the issue can be viewed.
This tab displays the violations on the unit tests: