# Excluding from coverage or duplication

You can exclude specific files from your project’s [overview](https://docs.sonarsource.com/sonarqube-server/2025.2/analyzing-source-code/test-coverage/overview "mention") or duplication check analysis (detection of identical lines of code).

{% hint style="info" %}
As system administrator, you can perform this setting as the default setting for all projects. See [exclude-from-coverage-duplication](https://docs.sonarsource.com/sonarqube-server/2025.2/instance-administration/analysis-functions/analysis-scope/exclude-from-coverage-duplication "mention").
{% endhint %}

## Excluding specific files from the code coverage analysis <a href="#from-coverage" id="from-coverage"></a>

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.

<details>

<summary>In the UI</summary>

1. [retrieving-projects](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/viewing-projects/retrieving-projects "mention").
2. Go to **Administration > General Settings > Analysis scope**.
3. In **Code coverage > Coverage Exclusions**, enter and save a [defining-matching-patterns](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/defining-matching-patterns "mention") to define files to be excluded from the code coverage analysis.

</details>

<details>

<summary>On the CI/CD host</summary>

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](https://docs.sonarsource.com/sonarqube-server/2025.2/analyzing-source-code/analysis-parameters "mention").

| **Property key**          | **Description**                                                                                                                                                                                                                   |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sonar.coverage.exclusions | <p>Defines the source files to be excluded from the code coverage analysis.</p><p><strong>Possible values</strong>: comma-separated list of <a data-mention href="defining-matching-patterns">defining-matching-patterns</a>.</p> |

</details>

## Excluding specific files from the duplication check <a href="#from-duplication" id="from-duplication"></a>

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.

<details>

<summary>In the UI</summary>

1. [retrieving-projects](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/viewing-projects/retrieving-projects "mention").
2. Go to **Administration > General Settings > Analysis scope**.
3. In **Duplication > Duplication Exclusions**, enter and save a [defining-matching-patterns](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/defining-matching-patterns "mention") to define files to be excluded from the duplication check.

</details>

<details>

<summary>On the CI/CD host</summary>

The table below lists the sonar properties you can use to exclude specific files from the duplication check. For more information, see [analysis-parameters](https://docs.sonarsource.com/sonarqube-server/2025.2/analyzing-source-code/analysis-parameters "mention").

|                      |                                                                                                                                                                                                                              |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Property key**     | **Description**                                                                                                                                                                                                              |
| sonar.cpd.exclusions | <p>Defines the source files to be excluded from the duplication check.</p><p><strong>Possible values</strong>: comma-separated list of <a data-mention href="defining-matching-patterns">defining-matching-patterns</a>.</p> |

</details>

## Related pages <a href="#related-pages" id="related-pages"></a>

* [excluding-files-based-on-patterns](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/excluding-files-based-on-patterns "mention")
* [excluding-based-on-file-extension](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/excluding-based-on-file-extension "mention")
* [advanced-exclusions](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/advanced-exclusions "mention")
* [other-adjustments](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/other-adjustments "mention")
* [setting-initial-scope](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/setting-initial-scope "mention")
* [verifying-analysis-scope](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/verifying-analysis-scope "mention")
* [introduction](https://docs.sonarsource.com/sonarqube-server/2025.2/instance-administration/analysis-functions/analysis-scope/introduction "mention")
