Start FreeLog in
SonarQube Cloud | Managing your project | Setting up project analysis | Analysis scope | Introduction

Setting the analysis scope of your project

On this page

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. 

Step 1: Check your project's default initial scope

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

See Setting the initial analysis scope of a project

Step 2: If necessary, adjust the initial scope

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 Cloud 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: 

Step3: Verify the settings

After the first project analysis run, you can verify that the configured analysis scope is correct. See Verifying the analysis scope of a project.


Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License