I want to investigate how certain rules and issues have been violated in a certain package, however, from what I have seen in the Components-interface in SonarQube, it is only possible to view leaf node-directories and I am interested in viewing the entire folder, including sub-folders and files in that folder.
E.g.
Project
src
package1
subdirectoryone
done
code-a.java
dtwo
code-x.java
dthree
code-i.java
code-1.java
code-2.java
subdirectorytwo
package2
subdirone
subdirtwo
In this example I would like to investigate the issues and rule violations in subdirectoryone
including the code files at all levels in the directory.
Is there a way I can do this?
In SonarQube 4.5 if you start from the dashboard and click the Issues link you will see all the issues for every module. In the left box below the lists of Severities and Rules is a list of all the modules and sub-modules in your project. If you select from that list it will narrow down the centre and right boxes to just the packages and files within that module. Unfortunately it doesn't filter the rules or severities in the top boxes.
In SonarQube 5.3 if you go to the issues tab you can select the module checkbox on the left side and select from your high runners. Near the top of the page is a hierarchy for the module you selected which you can click on to see the dashboard for that module or sub-module and then click issues for just that part. Then if you want a sub-module that isn't in high runners note that the URL is editable if you are careful and know your target hierarchy.
I haven't found a better way than that yet in 5.3, but after only a few days playing with a recent 5.3 upgrade I am generally liking the UI changes.
I use something like this:
<sonar.projectName>Some project name (com/your-directory only)</sonar.projectName>
<sonar.exclusions>org/**/*, com/acme/**/*</sonar.exclusions>
<sonar.test.exclusions>org/**/*, com/acme/**/*</sonar.test.exclusions>
<sonar.sources>${project.build.sourceDirectory}/com/your-directory</sonar.sources>
This excludes everything but the code I want to be analyzed (exclusions properties) and define my source dir as ${project.build.sourceDirectory}/com/your-directory
(this is where the code I want to be analyzed is)
Then the analysis is run using maven:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package -Dtest=com/your-directory/**/*Test.java
(note the -Dtest=
restriction for the tests)
Some reading: http://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus