Configure inclusions for coverage reports


is there a way to configure inclusions for code coverage reporting on sonarqube?

I’m trying to aggregate quality metrics for a large and aged project on sonarqube. The project has huge amounts of legacy code without proper code coverage but there is also newer code that has to meet certain coverage criteria. To track the latter, I need to restrict the code coverage report to classes in certain packages and with certain naming patterns.

With Maven, JaCoCo and Jenkins it is possible to do so simply by setting coverage inclusions.

Sonarqube only seems to have an option to exclude files from the coverage report (sonar.coverage.exclusions) which means way to much different patterns to manage in my case.

Is there something I’m missing or should this be a feature-request?

Thanks a lot!


Sonarqube: 7.1 (build 11001) Community
surefire-plugin: 2.22.0
jacoco-maven-plugin 0.8.1


I don’t believe it’s possible to include files for code coverage, only exclude.

I would ask you to instead consider taking advantage of the leak period functionality to measure coverage on new code, instead of trying to fudge overall coverage metrics. You can set your quality gate to only take into account code coverage over the leak period (on “new code”, whatever it’s being called these days).


1 Like

Hi Colin,

thanks for your feedback.

I agree, fudging the metrics isn’t ideal.

Nevertheless I need specific coverage reports (or quality gate conditions) for certain filesets - not only for newly added code, but also to to ensure near 100% coverage only for the most critical parts of the software.

Thinking about it - gathering a complete coverage report and having additional metrics/quality gates for certain filesets would be even better than filtering the fileset beforehand. But I suppose thats even harder to achieve?


If that is your steadfast goal, you may need to create seperate projects and manage the inclusion/exclusion of files from analysis for each.

If your organization uses the Enterprise Edition, you might be able to take away some of the pain of doing this by having those seperate projects roll up into an “application” – so you’d still be getting the full picture on some metrics.


Hi @carsten.rohde

did you manage to just include some paths for coverage reports? I’m struggling with it too.

Thank you,

If you have another problem, please open another thread.