Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonar exclusions not preventing C# code from being analyzed

Tags:

sonarqube

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

like image 824
Ricardo Guerra Avatar asked Jul 29 '13 17:07

Ricardo Guerra


2 Answers

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
like image 94
Fabrice - SonarSource Team Avatar answered Oct 19 '22 22:10

Fabrice - SonarSource Team


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.

like image 21
San7988 Avatar answered Oct 19 '22 22:10

San7988