Excluding from coverage or duplication

This page explains how SonarQube Cloud can exclude 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 the admin an Enterprise plan organization, you can perform this setting as the default setting for all projects of your organization. See Excluding from coverage or duplication.

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
  1. Retrieve your project. See Retrieving projects for more details.

  2. Go to Administration > General Settings > Analysis scope.

  3. In Code coverage > Coverage Exclusions, enter and save a path-matching pattern to define files to be excluded from the code coverage analysis. See Defining matching patterns for details.

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

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. See Defining matching patterns for details.

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
  1. Retrieve your project. See Retrieving projects for more details.

  2. Go to Administration > General Settings > Analysis scope.

  3. In Duplication > Duplication Exclusions, enter and save a path-matching pattern to define files to be excluded from the duplication check. See Defining matching patterns for details.

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

Description

sonar.cpd.exclusions

Defines the source files to be excluded from the duplication check.

Possible values: comma-separated list of path-matching patterns. SeeDefining matching patterns for details.

Last updated

Was this helpful?