Search code examples
antsonarqube

SonarQube code coverage - exclude some classes


Is there any way to purposefully increase Code Coverage value in SonarQube by excluding some classes.


Solution

  • Try to use sonar.coverage.exclusions.

    As sonar.coverage.exclusions is Comma-delimited list of file path patterns to be excluded from coverage calculations. Your pattern should be like this:

    sonar.coverage.exclusions=com/abc/demo/presentation/beans/**/*, com/abc/demo/presentation/interfaces/**/*, com/abc/demo/presentation/validator/**/*, com/abc/utility/**/*
    

    Note: Documentation for this option was removed in 7.3 (Google: site:docs.sonarqube.org "sonar.coverage.exclusions"). But you can still see them when you open the administration pages for the project on Sonar -> "General Settings" -> "Analysis Scope". Look for the values after "Key:"