I am trying to specify “sonar.sources” and “sonar.tests” in order to get a better sonarqube performance but I get this error:
##[error]File Wke.Partners.Crosscutting/Contracts/IConfigurationRestServices.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
I understand this error but I don t know how can I fix it without remove this two properties of the analysis parameters.
Specifying one parameter doesn’t mean you have to specify them all. What happens if you retain sonar.exclusions but comment out sonar.sources and sonar.tests?
If I comment the parameters sonar.sources and sonar.tests it works fine.
So, I don’t understand well when I have to use them because any test I did with any of these arguments gave me the indexing problems. Instead of these parameters, would you recommend me to use sonar.exclusions and sonar.inclusions? Or just use one of them for avoid indexing problems?
How I say before, it’s important for me understand well how/what scanner are going to index in order to gain performance.
These are fair questions and I fully appreciate the need to understand. The answers vary depending on which scanner you’re using. Three of the scanners sit on top of deeply integrated build systems: SonarScanner for .NET, SonarScanner for Maven, & SonarScanner for Gradle. For these three the build system knows pretty much everything about your project, so the scanner just harvests that data to do its job. That’s why it worked fine for you when you stopped overriding the default sonar.scanner and sonar.tests values provided by the build system.
On top of that, you used sonar.exclusions to tune that sources value to omit some source files the build knows about but that you don’t want analyzed. There’s a decent overview of it all in the docs.