Introduction

First check the initial analysis scope of your SonarQube Cloud project. If necessary, you can adjust the analysis scope of your project as it develops.

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.

  • With the Enterprise plan, your organization admin can set up default analysis scope adjustments for all projects of the organization. See the Introduction page to Adjusting analysis scope for more details.

  • The new code definition of your project has an impact on the analysis scope. For more information, see Quality standards and new code.

  • Subscription plans are tiered according to the total number of lines of code (LOC) analyzed in your private repositories. This LOC calculation does not count code in excluded files nor does it count blank lines or comments. For more details, see LOC-based pricing in Subscription plans.

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 initial scope.

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 analysis scope for more details.

Last updated

Was this helpful?