# Introduction

There are many cases where you do not want to analyze every aspect of every source file in your project. For example, your project may contain generated code, source code from libraries, or intentionally duplicated code.

In such cases, it makes sense to skip some or all aspects of analysis for these files, thus removing noise and narrowing the focus to issues that really matter. To help narrow the focus, SonarQube Server gives you several options to precisely configure what will be analyzed and how.

{% hint style="info" %}
The new code definition of your project has an impact on the analysis scope. For more information, see [about-new-code](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/about-new-code "mention").
{% endhint %}

## Step 1: Check your project’s default initial scope <a href="#check-initial-scope" id="check-initial-scope"></a>

Check your project’s default initial scope. If it doesn’t suit you, you must set the initial scope explicitly.

See [setting-initial-scope](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/setting-initial-scope "mention").

## Step 2: If necessary, adjust the initial scope <a href="#adjust-initial-scope" id="adjust-initial-scope"></a>

You may have to adjust the initial scope mainly in the following cases:

* If the directory structure of your project does not cleanly separate source code from test code at the top level. In that case, you can exclude files based on path-matching patterns or file extensions by programming language.
* To exclude specific files from duplication check.
* To exclude specific files from coverage reporting.

You can also perform other exclusions, such as excluding files over a certain size limit or disabling the SCM’s file ignore patterns. In very few situations, you may have to use advanced exclusion features.

To exclude code from the analysis, you define exclusion parameters for the project. You can define most exclusion parameters:

* In SonarQube Server UI\
  This requires that you have the Administer permission for the project.\
  When possible, it is the recommended method since it allows a centralized, reliable, and user-friendly configuration.
* On the CI/CD host\
  With this method, you configure the respective sonar properties on the CI/CD host. Note that a parameter set through this method has precedence over any UI setting of the same parameter.

See:

* [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")
* [exclude-from-coverage-duplication](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/exclude-from-coverage-duplication "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")

{% hint style="info" %}
Some exclusions can be [introduction](https://docs.sonarsource.com/sonarqube-server/2025.2/instance-administration/analysis-functions/analysis-scope/introduction "mention") for all projects.
{% endhint %}

## Step3: Verify the settings <a href="#verify-settings" id="verify-settings"></a>

After the first project analysis run, you can verify that the configured analysis scope is correct. See [verifying-analysis-scope](https://docs.sonarsource.com/sonarqube-server/2025.2/project-administration/setting-analysis-scope/verifying-analysis-scope "mention")
