Excluding specific files from your project's code coverage analysis or duplication check
You can exclude specific files from your project's code coverage analysis or duplication check analysis (detection of identical lines of code).
As system administrator, you can perform this setting as the default setting for all projects. See Excluding specific files from code coverage or duplication check at the global level.
Excluding specific files from the code coverage analysis
You can perform the setup in SonarQube UI (this requires that you have the project's Administer permission) or on the CI/CD host. A parameter set on the CI/CD host has precedence over any UI setting of the same parameter.
In the UI
- Retrieve the project.
- Go to Administration > General Settings > Analysis scope.
- In Code coverage > Coverage Exclusions, enter and save a path-matching pattern to define files to be excluded from the code coverage analysis.
On the CI/CD host
The table below lists the sonar properties you can use to exclude specific files from the code coverage analysis. For more information, see Analysis parameters.
Property key | Description |
---|---|
sonar.coverage.exclusions | Defines the source files to be excluded from the code coverage analysis. Possible values: comma-separated list of path-matching patterns. |
Excluding specific files from the duplication check
You can perform the setup in SonarQube UI (this requires that you have the project's Administer permission) or on the CI/CD host. A parameter set on the CI/CD host has precedence over any UI setting of the same parameter.
In the UI
- Retrieve the project.
- Go to Administration > General Settings > Analysis scope.
- In Duplication > Duplication Exclusions, enter and save a path-matching pattern to define files to be excluded from the duplication check.
On the CI/CD host
The table below lists the sonar properties you can use to exclude specific files from the duplication check. For more information, see Analysis parameters.
Property key | Description |
sonar.cpd.exclusions | Defines the source files to be excluded from the duplication check. Possible values: comma-separated list of path-matching patterns. |
Related pages
- Excluding files from your project analysis based on path-matching patterns
- Excluding files from your project analysis based on file extension
- Applying advanced exclusions to your project analysis
- Performing other analysis scope adjustments
- Setting the initial scope of your project
- Verifying the analysis scope of your project
- Adjusting the analysis scope at the global level
Was this page helpful?