Setting initial scope
The initial analysis scope of a SonarQube Cloud project is defined for source files (non-test files) on one side, and for the test files on the other side.
The initial analysis scope of a project must be defined for source code (also called main code) on one side and for test code on the other side.
The initial analysis scope of a project is controlled by the following sonar properties:
For source code (non-test code):
sonar.sources
For test code (test code):
sonar.tests
which define that:
Files outside the initial scope will not be analyzed at all.
Files within the initial scope will be analyzed unless excluded by further adjustments.
Each project’s initial scope is defined by default. If it doesn’t suit you, you can set it explicitly.
Default initial scope
If you are analyzing code using the SonarScanner for Maven, the sonar.sources
and sonar.tests
parameters are automatically determined based on information in your project configuration. You do not have to explicitly set the parameters.
If you do explicitly set the parameters, for example in your pom.xml file, they will override the automatically determined values.
See Adjusting the analysis scope for more details.
Setting the initial scope explicitely
If the default initial scope is not suitable (see example below), you must set the initial scope explicitely.
The parameters sonar.sources
and sonar.tests
are only settable by key on the CI/CD host (mainly in configuration files or on the command line), not in the SonarQube Cloud UI. For more information, see Analysis parameters.
To set sonar.sources
and sonar.tests
:
Use a comma-delimited list of directories or files.
The entries in the list are simple paths. Wildcard patterns are not allowed.
A directory in the list means that all analyzable files and directories recursively below it are included. An individual file in the list means that the file is included.
The paths are interpreted relative to the project base directory which is defined through the
sonar.projectBaseDir
property. In most cases, this is the root directory of the project. For more information about this property, see Analysis scope for more details.
The C/C++/Objective-C analyzer doesn’t currently support sonar.tests
. See Analyzing test files in Customizing the analysis.
Related pages
Introduction to Adjusting the analysis scope.
Last updated
Was this helpful?