SonarCloud Exclusions do not appear to be working correctly for Pull Requests

Hello,

We currently have SonarCloud (paid) on one of our Private Repos. An issue that we were running into was PRs from our developers that contain unit testing are being failed due to Duplication.

As a bit of background, we only have .sonarcloud.properties in our master branch. The PRs are being made from a developer’s feature branch to our “development” branch. The PRs are still being analyzed by SonarCloud (which we want all PRs to be analyzed).

I have made some changes to the .sonarcloud.properties as well as from the project’s Administration > Analysis Scope after the .sonarcloud.properties changes did not work.

This is what I have in our sonarcloud.properties:
sonar.cpd.exclusions=test/jasmine/unit/spec/**/*,test/jasmine/unit/spec/**/**/*,test/jasmine/unit/spec/**/**/**/*,test/jasmine/unit/spec/**/**/**/**/*,test/jasmine/unit/spec/lib/*_Spec.js,test/jasmine/unit/spec/restletScripts/*_Spec.js,test/jasmine/unit/spec/support/*_Spec.js,test/jasmine/unit/spec/emailCommunication/lib/*_Spec.js

Because of the fact that this hasn’t been working with sonar.cpd.exclusions, I tried adding the things I want excluded to the sonar.exclusions as well. It looks like the following:
sonar.exclusions=Objects/*.xml, test/jasmine/unit/spec/**/*, test/jasmine/unit/spec/**/**/*, test/jasmine/unit/spec/**/**/**/*, test/jasmine/unit/spec/**/**/**/**/*, test/jasmine/unit/spec/lib/*_Spec.js, test/jasmine/unit/spec/restletScripts/*_Spec.js, test/jasmine/unit/spec/support/*_Spec.js, test/jasmine/unit/spec/emailCommunication/lib/*_Spec.js

The exclusions do appear be working on some directories and files but not all.

An example where this exclusion appears to be working is the following:
test/jasmine/unit/spec/sfIntegration/lib/sfAdapter_Spec.js

An example where this exclusion is not working:
test/jasmine/unit/spec/emailCommunication/lib/emailCommunication_Spec.js

I believe I have accounted for all the possible patterns that would exclude this specific example (which is failing) but I wanted to see if there was anything in my configuration that seems like it would be preventing this from working correctly, or if the issue is due to .sonarcloud.properties not existing in the “development” branch.

Hello @al-haras,

The .sonarcloud.properties has to be part of either the feature branch or the branch being targeted (development in your case), otherwise it will not be taken into account for the PR analysis.

That being said it is currently not possible to configure the sonar.exclusions and sonar.test.exclusions from the Administration > Analysis Scope when using Automatic Analysis, we have a ticket open that you can follow.

It should however be possible to configure sonar.cpd.exclusions from the administration UI.

The sonar.cpd.exclusions files are still supposed to be analyzed, there is just no duplication detection happening on those files.

The following should be equivalent to your configuration: sonar.exclusions=Objects/*.xml,test/jasmine/unit/spec/**/*

Hope that helps!