SonarCloud doesn't exclude specific folder

I have used sonar.exclusions property before and it works as expected. Although in a recent project I can’t find a way to exclude a folder that is a system folder that contains more than 25k lines of CSS code.

The folder path that I need to exclude is: src/CommerceApp.Web/_SystemResources

I have tried setting up the sonar.exclusions in:

  • Prepare analysis on SonarCloud pipeline task.
  • In SonarCloud UI (Analysis Scope).

But none of the above options work.

I have even tried to exclude everything with **/** to test but not even that pattern works.

Do you have any suggestions? Is the folder name _SystemResources a keyword that is preventing SonarCloud to exclude that folder?

Any help is appreciated.

Hi @caraujo84

Just to be clear, to exclude all files and sub-directories under this folder, the setting should be:

sonar.exclusions = src/CommerceApp.Web/_SystemResources/**

Just to be clear by “does not work”, I assume you mean that the files you are trying to exclude from the analysis are still visible when you browse the Code tab of your project on SonarCloud UI. If you mean something else, please clarify!

Since sonar.exclusions = **/** should indeed exclude everything from sources (do not analyze, and will not show up on Code tab), I suspect we’re missing something.

I think it may be useful to review the effective settings related to the analysis. Please go to Administration / Background Tasks page of your project, pick a task where you tried to apply sonar.exclusions = src/CommerceApp.Web/_SystemResources/**, and from the dropdown menu at the right, select Show SonarScanner Context, and copy-paste from it the content of “Project server settings” and “Project scanner properties” sections. I’m mainly interested in the sonar.sources, sonar.exclusions and sonar.inclusions settings. If you prefer to share privately, just let me know and I’ll start a private thread. Here’s an example extract:

Project server settings:
  - sonar.autoscan.enabled=true
  - sonar.exclusions=src/CommerceApp.Web/_SystemResources/**
Project scanner properties:
  - sonar.coverage.exclusions=**/*
  - sonar.exclusions=**/,**/*.cs,**/*.c,**/*.h,**/*.cc,**/*.cpp,**/*.cxx,**/*.c++,**/*.hh,**/*.hpp,**/*.hxx,**/*.h++,**/*.ipp,**/*.m,**/*.java,**/*.jav,**/*sql,**/*tab,**/*pkb,**/*.vb,src/CommerceApp.Web/_SystemResources/**
  - sonar.sources=.
  - sonar.test.exclusions=**/*.cs,**/*.c,**/*.h,**/*.cc,**/*.cpp,**/*.cxx,**/*.c++,**/*.hh,**/*.hpp,**/*.hxx,**/*.h++,**/*.ipp,**/*.m,**/*.java,**/*.jav,**/*sql,**/*tab,**/*pkb,**/*.vb