SONAR - How to exclude packages defined in the "sonar.test" section

I have projects in JAVA that I analyze using sonar. Some of the java packages that I have are under the source folder. I also have a test file that I have in different folders. Now, in Sonar, I organize my projects under a different structure, that is, for the search project, I want to include the search package. This exception is fairly easy to accomplish using the sonar.exclusion properties. My question, however, how about a test? How can I exclude some of the packages? Because from my testing, although my source and test folder uses the same structure, test packages are not automatically excluded when I specified "sonar.exclusions".

my folder structure:

/src/com/domain/ -- search/ -- utils/ -- pooling/ -- category/ /test/src/com/domain/ -- utils/ -- pooling/ 

Sonar Properties:

 <property name="sonar.sources" value="${path}/src" /> <property name="sonar.tests" value="${path}/test/src" /> <property name="sonar.exclusions" value="com/domain/utils/**/*,com/domain/pooling/**/*,com/domain/category/**/*" /> 

So, I am trying to include only a search package. The code above works in such a way that it forces SONAR to parse only my search package. This package can be seen on the SONAC Components tab. Unfortunately, in addition to the search component, I also see the util and pooling components. I did some testing and I am sure that these two components (utils and union) are the result of the sonar.tests properties. Just a note, although despite the fact that “components” and “merging” are displayed in the components, SONAR shows zero files under both of them. Therefore, returning to my question, is there anyway what I can do to exclude “use” and “merging” into “Components”? Perhaps using properties (e.g. exceptions to test sonar)?

Btw, I use SONAR 2.11 and it works under Linux. I am using SONAR-TASK 1.2.

Any help is appreciated and appreciated! Thanks!

+4
source share
2 answers

You can define exceptions in the configurations for the project directly in sonar.

exclusions

+7
source

From the documentation:

Starting with version 3.3, it is also possible: To exclude a test file from analysis: go to Configuration> Settings> Exclusions and set> Property sonar.tests.exclusions

+1
source

Source: https://habr.com/ru/post/1382593/


All Articles