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
When drilling down into measures, you will eventually reach the file level and will be able to browse the source code.
SonarQubeTM 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 new/modified source code or view the last committers, you need to install the SCM Activity Plugin.
The Coverage tab displays the source code decorated with information about code coverage (by unit tests and/or integration tests).
In the source code:
- The first column displays the number of unit tests covering the line (available since version 3.5, was the number of hits by unit tests in versions prior to 3.5)
- The second one displays the number of covered conditions by unit tests out of the total number of conditions to cover
The features described below are available since version 3.5.
When clicking on a figure displayed in the first column, the unit tests covering this specific line are listed:
When selecting Per test > Covered lines in the second dropdown list, a third dropdown list appears. In this latter list, it is possible to select a specific unit test. Then, only lines covered by this unit test are displayed in the source code viewer:
The Issues tab displays issues directly in the source code.
The issues to display can be filtered by coding rule, severity, etc.
Thanks to the Time changes... list box, you can only display new issues that have been added for a timespan. See Differential Views for more information.
Only the source code around the issue is displayed. If necessary, you can display the full source code by ticking the Full source box.
You can directly manage the issues: comment, assign, link to an action plan, etc. See the Issues documentation page for more details.
The Duplications tab shows every duplicated chunk of code within a class and the name of the other class it is duplicated with.
See Duplications for more information.
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 Test File
When drilling down into unit tests execution measures, you will eventually reach the unit test level:
The Source tab displays the source code of the unit test file:
The Tests tab displays the result of the unit tests belonging to the unit test class.
In case of a failure or an error, the reason is displayed:
Since version 3.5, it is also possible to the mapping of unit tests and covered code. The objective is to answer the following questions:
- Which files are covered by a given unit test?
- How many lines of code are covered by a given unit test?
- Which lines are covered by a given unit test?
- Which tests do cover a given line of code?
The Issues tab displays issues on unit tests: