Start Free
SonarQube Community Build | Instance administration | Global analysis setup | Analysis scope | Excluding files based on file paths

Excluding files from analysis based on path-matching patterns at the global level

On this page

As a system administrator, you can adjust the initial analysis scope at the global level by excluding files based on path-matching patterns. To exclude files, you define file exclusion parameters based on directory and file name patterns. This analysis scope adjustment applies to all projects in your instance. However, they can be overridden at the project level in the UI or through analysis parameters set on the CI/CD host.

Example of an initial scope adjustment

We consider the following repository example where test files are contained in both test/ directories. Source and test code files are contained in the same ancestor directory: src/ which is chosen as the initial analysis scope for both source and test code. Therefore, a scope adjustment is necessary.

We adjust the initial scope as follows:

  • For source files: by defining an exclusion parameter with the pattern src/**/test/**/*
  • For test files: by defining an inclusion parameter with the pattern src/**/test/**/*

Principles governing the use of file exclusion parameters

Defining a file exclusion parameter

  1. Go to Administration > Configuration > General Settings > Analysis Scope.
  2. In A. File Exclusions, choose the parameter to configure (source or test code; exclusion or inclusion patterns; forced global (indicated by the Global prefix) or not), and enter and save the first pattern. See Defining path-matching patterns.
  3. Add additional patterns to the parameter if necessary.
  4. Define other parameters if necessary. Make sure you use either  (Global) Source File Exclusions or Source File Inclusions, and either (Global) Test File Exclusions or Test File Inclusions.

Global Source File Exclusions and Global Test File Exclusions are forced global parameters. A forced global parameter applies to all projects and cannot be overridden by any other setting. 


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