简体   繁体   中英

Sonar Exclusions - Project properties file or General Settings

I am playing around with the ready to use Sonarqube Version 6.2 and sonar scanner with a sonar-project.properties file based on the tutorial @ https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner .

I am curious about the exclusions. I am still using the embedded databases (not a full install), and I have gone to Administration>Configuration>Exclusions and set the following converage exclusions - **/*.js , and **/target/** .

However when I run the project through sonar scanner the JS files are still being analyzed.

I saw on another page in an archive that there is a properties file parameter sonar.exclusions .

Question: Does sonar respect the general settings > Analysis scope when analyzing through the scanner or should I use the project properties file?

What is the proper approach?

Code coverage exclusions are useful when you want to exclude some files from being taken into account in code coverage computation by unit tests.

What you want to achieve is to completely exclude some files from the analysis. Thus you should have a look at file exclusions (it's just the section below code coverage).

We can also exclude the files using maven.

<properties>
<sonar.exclusions>org/binarytherapy/generated/**/*, 

Mostly we use the following(I recomend this approach) Administration > General Settings > Analysis Scope > Files

In rare cases we use sonar-project.properties for exclusions.

references: Configure Sonar to exclude files from Maven pom.xml https://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM