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
the file path I am trying to exclude:
my exclusion is
First things first, do you see the exclusion referenced in your scanner logs?
INFO: Project configuration:
INFO: Excluded sources: <exclusion patterns>
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.
I have added the following config to .sonarcloud.properties
Path to sources
Path to tests
Exclusions for copy-paste detection
But the quality gate still failed
Is this file at the root of your repository?