# Sonarscanner ignoring exlusions

**URL:** <https://community.sonarsource.com/t/sonarscanner-ignoring-exlusions/64281>\
**Category:** SonarQube Cloud\
**Tags:** dotnet, scanner, sonarqube-cloud\
**Created:** [June 3, 2022, 6:38am UTC](https://community.sonarsource.com/t/sonarscanner-ignoring-exlusions/64281 "2022-06-03T06:38:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cysiek](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cysiek](https://community.sonarsource.com/u/cysiek)\
**Post date:** [June 3, 2022, 6:38am UTC](https://community.sonarsource.com/t/sonarscanner-ignoring-exlusions/64281/1 "2022-06-03T06:38:50Z")

</div>

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](http://VB.Net), .NET 4.8, created pipeline:

```auto
- '& $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.

```auto
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?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [June 3, 2022, 9:41am UTC](https://community.sonarsource.com/t/sonarscanner-ignoring-exlusions/64281/2 "2022-06-03T09:41:05Z")

</div>

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** ).

---

<div class="post-metadata">

**Author:** ![cysiek](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cysiek](https://community.sonarsource.com/u/cysiek)\
**Post date:** [June 3, 2022, 12:02pm UTC](https://community.sonarsource.com/t/sonarscanner-ignoring-exlusions/64281/3 "2022-06-03T12:02:02Z")

</div>

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” 🙂

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [June 10, 2022, 12:02pm UTC](https://community.sonarsource.com/t/sonarscanner-ignoring-exlusions/64281/4 "2022-06-10T12:02:15Z")

</div>

Closed on June 10, 2022, 12:02pm UTC

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