When I write
<sonar.jacoco.excludes>*.model.*</sonar.jacoco.excludes>
The package is not excluded from instrumentation / reporting and coverage shows as 0%
Why is this ?
Sonar version 3.6
Yes, presumably. SonarQube reads the report that JaCoCo gives it. If JaCoCo excludes certain classes, then SonarQube shouldn't get any data on them.
Ignore Code Coverage To do so, go to Project Settings > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property.
Starting from JaCoCo 0.8. 2, we can exclude classes and methods by annotating them with a custom annotation with the following properties: The name of the annotation should include Generated. The retention policy of annotation should be runtime or class.
SonarQube has a broader approval, being mentioned in 163 company stacks & 271 developers stacks; compared to JaCoCo, which is listed in 5 company stacks and 11 developer stacks.
Common pitfall to use the wrong pattern to exclude. Notice the .
Bad :
<sonar.jacoco.excludes>*.model.*</sonar.jacoco.excludes>
Good:
<sonar.jacoco.excludes>*model*</sonar.jacoco.excludes>
Documentation for weary travellers.
I am using SonarQube version 4.5 and setting sonar.coverage.exclusions property worked in my case. Official documentation is here.
In your case I suggest to use the following property
sonar.coverage.exclusions=**/model/**/*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With