False positives in duplications

Good morning.

As we have seen in the last few with our clients, we need a bit more control over duplicates, in order to be able to select if a duplicate is indeed a duplicate or not.

We have run into situations where a js template, such as react components is taken as a duplicate. We have also had problems with some Swagger annotations.

In those situations, we must exclude the entire file, which leads to losing any actual duplicates in that file.

Therefore, we felt it would be useful to be able to:

  • Mark a duplicate block or even a duplicate line as a “false positive” and have it disregarded.
  • Select a file to be disregarded for duplicates directly in the user interface, and not via sonar.cpd.exclusions.

Thank you,

1 Like

Hi, there:

We have faced again issues with code duplicates in one of our clients and they let us post the screenshots they gave us in order to depict this.

This is it:

As you may see in these screenshots, SonarQube is marking them as duplicates, because SonarQube does not take account of what’s the value of the literal, just its variable name and structure.

This type of structure is commonly used in object declaration, for example. Therefore, it should be considered as false positive.

Currently we don’t have any control over this. It should be very useful to have the posibility of mark these code blocks as false positives in the duplicates measure. Excluding the entirety of the file from duplicates may prevent us to detect some actual duplicates.

Thank you,