# 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 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](/sonarqube-cloud/administering-sonarcloud/managing-organization/setting-config-at-org-level/adjusting-analysis-scope/exclude-from-coverage-duplication.md).
{% 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 your project. See [Retrieving projects](/sonarqube-cloud/managing-your-projects/retrieving-projects.md) 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](/sonarqube-cloud/appendices/defining-matching-patterns.md) for details.

</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](/sonarqube-cloud/analyzing-source-code/analysis-parameters.md).

| **Property**              | **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="/pages/U8jXv7Hkn5N7LcYwBZhk">/pages/U8jXv7Hkn5N7LcYwBZhk</a> for details.</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 your project. See [Retrieving projects](/sonarqube-cloud/managing-your-projects/retrieving-projects.md) 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](/sonarqube-cloud/appendices/defining-matching-patterns.md) for details.

</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](/sonarqube-cloud/analyzing-source-code/analysis-parameters.md).

|                      |                                                                                                                                                                                                                                                                       |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Property**         | **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="/pages/U8jXv7Hkn5N7LcYwBZhk">/pages/U8jXv7Hkn5N7LcYwBZhk</a> for details.</p> |

</details>

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

* [Setting initial scope](/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope/setting-initial-scope.md)
* [Excluding based on path-matching patterns](/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope/excluding-files-based-on-patterns.md)
* [Excluding based on file extension](/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope/excluding-based-on-file-extension.md)
* [Advanced exclusions](/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope/advanced-exclusions.md)
* [Other analysis scope adjustments](/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope/other-adjustments.md)
* [Verifying analysis scope](/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope/verifying-analysis-scope.md)
* [Introduction](/sonarqube-cloud/administering-sonarcloud/managing-organization/setting-config-at-org-level/adjusting-analysis-scope/introduction.md) to Adjusting analysis scope


---

# 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-cloud/managing-your-projects/project-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.
