i've read the documentation about exclusions, tried several combinations, but still Sonar is analyzing code that it was not supposed to. The following is a sample of my sonar-runner.properties file:
#----- Required metadata
sonar.projectKey=ProjectKey
sonar.projectName=ProjectName
sonar.projectVersion=1.0
sonar.sources=MySourceFolder
sonar.build-stability.url=-
sonar.language=cs
sonar.dotnet.visualstudio.solution.file=MySourceFolder\\Solution.sln
sonar.donet.visualstudio.testProjectPattern=*.Tests*
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#----- Default Sonar server
sonar.host.url=http://myserver
#----- MySQL
sonar.jdbc.url=jdbc:mysql://myserver:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.driver=com.mysql.jdbc.Driver
#----- Global database settings
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
#----- Static analysis
sonar.fxcop.installDirectory=C:/Program Files (x86)/Microsoft Fxcop 10.0
Last option i used was to configure the exclusions through the Sonar UI (Project Settings > Exclusions > Source File Exclusions) and set a value like the following:
MySourceFolder/FolderA/FolderB/*.cs
In the logs i see the following message:
[17:27:10][Step 7/9] 17:27:10.919 INFO - Excluded sources:
[17:27:10][Step 7/9] 17:27:10.919 INFO - MySourceFolder/FolderA/FolderB/*.cs
Still, i the code is being analyzed as it appears in sonar violations and duplications plugins info.
Any idea on what might be causing this behaviour or how to correctly configure exclusions for C# files ?
Thanks a lot!
Ricardo
As specified on the SonarQube analysis parameters page, the property to specify exclusions is "sonar.exclusions".
So here's what you can specify in your "sonar-project.properties" file:
sonar.exclusions=FolderA/FolderB/*.cs
Actually, for me it worked the opposite.
sonar.exclusion didn't excluded the file from analysis but adding the file name to exclusion list through Sonar GUI worked fine.
I used it for JavaScript analysis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With