We need help turning of code duplication rule for certain files, but we need it to work through file config in a repo, and that it works on PR. How to do that?
It is pretty frustrating and on many repositories. The only way to ignore atm is to do it directly in the UI but that approach is not good and a bottleneck for the organization.
Most of the property keys shown in the interface at both global and project levels can also be set as analysis parameters.
From there you should be able to exclude project files from duplication either at command line level (with your pipeline definition file if you have any) or through your analyzed repository sonar-project.properties. Just set your sonar.cpd.exclusions parameter there.
Important:
In case your project analysis is automated, the properties file is you may use should be .sonarcloud.properties
And in fact I reproduced your case
a ‘regular’ scanner analysis of your project (thanks for sharing) did pick up the parameter well enough,
then I forced automatic analysis on the project and it was ignored
last I just copied your sonar-project.properties as .sonarcloud.properties and it was taken into account.