Reputation: 101
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
Upvotes: 10
Views: 6456
Reputation: 106
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.
Upvotes: 1
Reputation: 26843
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
Upvotes: 4