Cannot pass Quality Gate but I have already added the file to sonar.exclusions

I am using the Github Pull Request analysis feature and my PR keeps failing the Quality Gate.

SonarCloud reports that my __mockdata__ file has too many duplications, even though I have already added sonar.exclusions=**/__mockdata__/* to my sonar-project.properties file to exclude the file. However, the file is still not being excluded.

Does anyone know why?

Can you give an example of a file path you’re trying to exclude? Do the files exist directly under the * mockdata* folder or in further sub-directories (which would require an exclusion like **/__mockdata__/**/*

the file path I am trying to exclude: /libs/ecommerce/src/client/dom/__mockdata__/price.tests.data.js
my exclusion is **/__mockdata__/*.

Thanks.

First things first, do you see the exclusion referenced in your scanner logs?

INFO: Project configuration:
INFO:   Excluded sources: <exclusion patterns>

Hi Colin,

How can I see the scanner log?

I forgot to clarify – are you using CI-based analysis or Automatic Analysis? If the latter, you should use a .sonarcloud.properties file rather than a sonar-project.properties file.

May I clarify the difference between CI-based analysis and automatic analysis? If my sonarcloud is triggered in Github and I don’t see any github actions for the analysis, can I confirm the analysis is an automatic analysis?

Yes, that’s a safe assumption. You can also check your projects’ Administration > Analysis Method.

Hi

I have added the following config to .sonarcloud.properties

Path to sources

#sonar.sources=
#sonar.exclusions=
#sonar.inclusions=

Path to tests

#sonar.tests=
#sonar.test.exclusions=
#sonar.test.inclusions=

Source encoding

#sonar.sourceEncoding=UTF-8

Exclusions for copy-paste detection

sonar.cpd.exclusions=libs/**/__mockdata__/*,apps/**/__mockdata__/*

But the quality gate still failed

Thanks.

Is this file at the root of your repository?