# Excluding from coverage or duplication

You can exclude specific files from your project’s code coverage analysis 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.6/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. Retrieve the project. See[retrieving-projects](https://docs.sonarsource.com/sonarqube-server/2025.6/user-guide/viewing-projects/retrieving-projects "mention") for more information.
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.

</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.6/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 path-matching patterns. See<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. Retrieve the project. See[retrieving-projects](https://docs.sonarsource.com/sonarqube-server/2025.6/user-guide/viewing-projects/retrieving-projects "mention") for more information.
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.

</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.6/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 path-matching patterns. See <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.6/project-administration/adjusting-analysis/setting-analysis-scope/excluding-files-based-on-patterns "mention")
* [excluding-based-on-file-extension](https://docs.sonarsource.com/sonarqube-server/2025.6/project-administration/adjusting-analysis/setting-analysis-scope/excluding-based-on-file-extension "mention")
* [advanced-exclusions](https://docs.sonarsource.com/sonarqube-server/2025.6/project-administration/adjusting-analysis/setting-analysis-scope/advanced-exclusions "mention")
* [other-adjustments](https://docs.sonarsource.com/sonarqube-server/2025.6/project-administration/adjusting-analysis/setting-analysis-scope/other-adjustments "mention") for analysis scope
* [setting-initial-scope](https://docs.sonarsource.com/sonarqube-server/2025.6/project-administration/adjusting-analysis/setting-analysis-scope/setting-initial-scope "mention")
* [verifying-analysis-scope](https://docs.sonarsource.com/sonarqube-server/2025.6/project-administration/adjusting-analysis/setting-analysis-scope/verifying-analysis-scope "mention")
* Adjusting the analysis scope[introduction](https://docs.sonarsource.com/sonarqube-server/2025.6/instance-administration/analysis-functions/analysis-scope/introduction "mention")


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/2025.6/project-administration/adjusting-analysis/setting-analysis-scope/exclude-from-coverage-duplication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
