Sonarscanner ignoring exlusions

We started to use SonarCloud with Bitbucket cloud. For build server we use Windows Server VM, because some of the projects are still .net framework.

Recently I added new project in VB.Net, .NET 4.8, created pipeline:

- '& $env:SONAR_PATH begin /o:"xxx" /k:"xxx" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login=$env:SONAR_TOKEN'
- .\xxx\.nuget\nuget.exe restore '.\xxx\xxx.sln'
- '& $env:MSBUILD_PATH ".\xxx\xxx.sln" -t:Rebuild -p:Configuration=Release'
- '& $env:SONAR_PATH end /d:sonar.login=$env:SONAR_TOKEN'

Where SONAR_PATH is “E:\Sonar\SonarScanner.MSBuild.exe”, version SonarScanner 4.6.2.2472

In test project we have huge json files with fake data. I wanted to exclude them, so in Administration → General Settings → Analysis Scope I have added Source File Exclusion: “**/*.json”

Unfortunatelly it is not working. Tried adding direct path to the biggest json file - also no luck. What is strange, it works for css files.

Below is part of the log downloaded from bitbucket, looks like configuration is loaded properly.

INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/build-wrapper-dump.json, **/xxx.Business.Tests/Data/**, **/xxx/Scripts/polyfil/**/*, **/xxx/Scripts/test/**/*, **/xxx/Scripts/tests/**/*, **/xxx/Scripts/SyncFusion/**/*, **/xxx/Scripts/jquery*, **/xxx/Scripts/knockout*, **/xxx/Scripts/boostrap*, **/xxx/Scripts/moment*, **/xxx/Content/sass/**, **/*.css, **/*.json, xxx.Business.Tests/Data/CustomJson/bigfile.json

How can I force SonarCloud to ignore these json files?

Hey there.

Because your JSON file is being indexed as a test file (because it is in a test project), you will need to pass your exclusion to sonar.test.exclusions (Test File Exclusions).

Thanks, it works. Maybe the description of Source File Exclusions should be changed to: “Configure the files that should be completely ignored by the analysis, except Test projects” :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.