Sonar.cpd.exclusions not working as intended

Greetings,

This is my sonar property file

sonar.sources=bin/,models/,mongo/,utils/,Dockerfile,\
Jenkinsfile,Jenkinsfile-dev,swagger.js,server.js,ecosystem-dev.config.js
sonar.tests=test/
sonar.cpd.exclusions=package.json, sonarcloud/**/*
sonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-

sonarcloud is a directory we have which houses some files that was needed for the sonarcloud setup. The file and directory given in the cpd.exclusions are not being recignised in the analysis log and hence, they can be seen in the portal under the duplications tab. I am attaching both the analysis log and the portal screenshot
Screenshot 2024-04-02 at 11.48.28 AM

In addition, test directory is also being considered for duplications. Is the properties mentioned wrong? Would love to get some insight.

Hey there.

You’re doing everything right – but when you exclude a file from duplication, that duplication gets set to 0%, not null (like for coverage). I am not really sure why, but I’m going to throw this over to somebody who might. :smiley:

Hey @Colin ,

Thanks a lot for the reply. I request to get in touch with the other person as soon as possible as this issue needs to be addressed urgently on our end. Thanks

Hey there.

I can’t understand what’s making this urgent — the values are being set to 0. Can you explain?

We would like the test folder , its contents and the files given in the exclusions to not show up in the duplications tab. I was facing a similar issue for coverage but that’s worked out. Here is my coverage tab,

. Since the duplications have not been configured, we cannot integrate sonarcloud into our workflow, which we have been trying to do for 2 months now.

Hey @Colin ,

Were you able to get in touch with the relevant personnel? Thanks

Hey @Venkatesh_Ragavan

This is how our products have worked for a long time, and we consider it more of a quirk than a bug. Somebody will look at it as time permits.

Understood. And, that should not block you from integrate SonarCloud into your workflow.

It’s a shame we only heard from you about this last week! :smiley:

1 Like

Hey Colin,

Thanks for the response. So to clarify, despite the test directory and its contents being excluded for duplications, they’ll be shown in that screen. Is my understanding correct? Does this apply to all duplication patterns?

Yes. Even if you exclude all files (**/*), Duplication will be 0%, not null.

Hey Colin,

Thanks for the response. Now i understand. However, going by my observation, coverage can be null correct?

Correct. This is the weird quirk I think we (Sonar) should look at and figure out if there’s any good reason for this.

1 Like

Hello @Venkatesh_Ragavan,

We have created a ticket to improve this behavior in the future.

1 Like