We are running SonarQube Developer Edition 10.1 and I would like to set sonar.source and sonar.tests globally so that every project can benefit from this without having to configure single projects in their sonar-project.properties file.
It’s not possible to set these globally for projects. These properties are specifically designed to be configurable on a per-project basis to allow for the unique characteristics of each project.
There are also many project types that configure these automatically (Maven, Gradle, .NET) and should not be adjusted outside the defaults the build system configures.
Can you describe the projects in your organization and when the defaults don’t work as expected?
At the moment all the metrics are attributed to the “Main code” scope and I’d like to differentiate between “Main code” and “Test code” (see screenshot). For us, it would be inconvenient to edit the sonar-project.properties file for all our projects (60+) to get the scope correctly tracked.
I noticed that one can pass configuration parameters to the sonarscanner command line. Would they be merged with the ones from the sonar-project.properties file. This would be a more viable solution for us, since the sonarscanner docker image call is in a centralized piece of infrastructure code.
Yes, it can be passed as an analysis parameter to the command line! Take note that it will override any other place sonar.tests might be set (command line analysis parameters always take precedence)
Thanks, I tested the configuration and it seems to work. However, the total issue count is much lower with the new configuration. From a quick check, it seems that it is not a problem with included files, rather some rules are not applied for test files.
Is this correct?
If so, can you point me to where in the rules definition it says if they are applied or not to test code?
Very few rules are applied to test files today (and mostly involve rules that are actually about writing tests). Applying more rules to test code is on our roadmap.
The data about which rules apply to test sources isn’t well structured – what language(s) are you analyzing?