Help setting SonarCloud duplication Exclusions

My project runs with Django and I want SonarCloud to stop reporting string duplications in automatic tests.

To achieve this, I added the pattern **/tests/**/test_*.py in the following section:

Administration > General Settings > Analysis Scope > Duplications > Duplication Exclusions

Still, in, this issue is raised:
File: my_project/tests/test_foo/

String literals should not be duplicated

What should I change in my settings to prevent SonarCloud from raising this issue?

Hey there.

sonar.cpd.exclusions will prevent duplication from being calculated, but won’t prevent rules in your Quality Profile from triggering. Preventing a specific rule from triggering on a file path pattern is more in the scope of Ignore Issues on Multiple Criteria on the same settings page.

In fact, what you probably want to do is make sure sonar.tests is configured correctly (this would be done as an analysis parameter on the command line or in a file). This will make sure that the rules only run on your Main (source) code. Check the documentation on Analysis Scope.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.