# Sonar.exclusions not working?

**URL:** <https://community.sonarsource.com/t/sonar-exclusions-not-working/22365>\
**Category:** SonarQube Cloud\
**Created:** [March 30, 2020, 9:43pm UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365 "2020-03-30T21:43:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![andersbl](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andersbl/32/10509_2.png) [@andersbl](https://community.sonarsource.com/u/andersbl)\
**Post date:** [March 30, 2020, 9:43pm UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/1 "2020-03-30T21:43:07Z")

</div>

I’m facing an issue with sonarcloud that I’m not facing when I’m running sonarcube locally. The problem is the sonar.exclusions, which seems to be completely ignored. Sonar.inclusions are working well on sonarcloud, which is the weird part

My directory path is as such:

application\_front/controllers/files  
application\_front/views/files  
application\_admin/controller/files  
application\_admin/views/files  
application\_admin/third\_party/files

I would like to exclude the folder: Application\_admin/third\_party/  
I have tried the following sonar.exclusions values:

sonar.exclusions = application\_admin/third\_party/\*\*  
sonar.exclusions = \*\*/third\_party/\*\*  
sonar.exclusions = \*\*third\_party\*\*

However the files in the third\_party folder is still included.

However if I specify the inclusion filter as such:  
sonar.inclusions = Application\_front/\*\*

Then it works as intended and the Application\_admin folder is excluded. However, I want to only exclude the Application\_admin/third\_party/ folder and I do not want add a new folder to the inclusion filter evertime a new folder is added to the source.

Is there something wrong with the sonar.exclusions filter on sonarcloud?

- ALM used: GitHub
- Languages of the repository: PHP
- Your analysis with ID “AXEtW\_NI\_gvX44VAKq6H” has failed.

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [March 31, 2020, 6:23am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/2 "2020-03-31T06:23:33Z")

</div>

Hi @andersbl and welcome to the community !

Exclusions (with relative paths provided), even if you can exclude directories, are based on files. (See the doc [here](https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/#patterns))

For example, i think this one might work :  
sonar.exclusions = Application\_admin/third\_party/\*\*/\*

Let us know if it works.

Thanks.  
Mickaël

---

<div class="post-metadata">

**Author:** ![andersbl](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andersbl/32/10509_2.png) [@andersbl](https://community.sonarsource.com/u/andersbl)\
**Post date:** [March 31, 2020, 7:21am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/3 "2020-03-31T07:21:01Z")

</div>

Hi Mickael,

Thanks a lot for your suggestion. I had to try it immediately when I saw the post but sadly it didn’t work. I checked in the scan context to see if the filter was set and it was.

I tried the coverage.exclusions filter because i got desperate but did not help either.

Project server settings:

- sonar.autoscan.enabled=true
- sonar.coverage.exclusions=application\_admin/third\_party/\*\*,\*\*third\_party\*\*,\*\*/third\_party/\*\*
- sonar.exclusions=application\_admin/third\_party/\*\*/\*
- sonar.inclusions=application\_front/\*\*,application\_admin/\*\*
- sonar.test.exclusions=application\_admin/third\_party/\*\*

Your analysis with ID “AXEvbnhTrwvFd9BVOU-h” has failed: your number of lines exceeds your organization plan.

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [March 31, 2020, 7:47am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/5 "2020-03-31T07:47:24Z")

</div>

Thank for your answer.

It appears that we have (maybe) the same sort of issues in this thread : [Issue in file scope excluded still showing. Counted also in number of lines](https://community.sonarsource.com/t/issue-in-file-scope-excluded-still-showing-counted-also-in-number-of-lines/22097/9)

We are currently looking into it, and let you know if some fixes have to be made on our side.

Mickaël

---

<div class="post-metadata">

**Author:** ![andersbl](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andersbl/32/10509_2.png) [@andersbl](https://community.sonarsource.com/u/andersbl)\
**Post date:** [March 31, 2020, 8:46am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/6 "2020-03-31T08:46:49Z")

</div>

Okay that makes sense, it was also a strange behavior 🙂

I can see that the issue you referred to has been open for only 4 days. I’m wondering if this issue has been open for a long time in general or if this is an “Easy fix”.

The reason I’m asking is because that I am still on my trial period and I don’t want to pay for a service that I cannot use.

---

<div class="post-metadata">

**Author:** ![janos](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/janos/32/60_2.png) [@janos](https://community.sonarsource.com/u/janos)\
**Post date:** [March 31, 2020, 10:17am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/7 "2020-03-31T10:17:00Z")

</div>

Hi @andersbl,

We’re still investigating this, in the meantime, you can find a workaround [on the other thread](https://community.sonarsource.com/t/issue-in-file-scope-excluded-still-showing-counted-also-in-number-of-lines/22097/13).

---

<div class="post-metadata">

**Author:** ![andersbl](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andersbl/32/10509_2.png) [@andersbl](https://community.sonarsource.com/u/andersbl)\
**Post date:** [March 31, 2020, 11:12am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/8 "2020-03-31T11:12:36Z")

</div>

The workaround worked 🙂 So that’s fine for now but I would prefer it to be set in the SonarCloud project and not in the source.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![janos](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/janos/32/60_2.png) [@janos](https://community.sonarsource.com/u/janos)\
**Post date:** [April 1, 2020, 3:30pm UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/9 "2020-04-01T15:30:44Z")

</div>

I confirm, currently it’s not possible to set this property using the UI.

I created a ticket to track the issue: [SCCOMM-24](https://jira.sonarsource.com/browse/SCCOMM-24)

---

<div class="post-metadata">

**Author:** ![TomVanBraband](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomvanbraband/32/46480_2.png) [@TomVanBraband](https://community.sonarsource.com/u/TomVanBraband)\
**Post date:** [May 5, 2020, 8:10am UTC](https://community.sonarsource.com/t/sonar-exclusions-not-working/22365/10 "2020-05-05T08:10:23Z")

</div>

@andersbl This has now been fixed, the exclusions set in the UI are now taken into account.
