Detecting Duplication Code Issue

Hello Community,

Is there a way that we would be able to specifically pinpoint the duplicated code issue that Sonar detected in one of our merge request (MR)?

SonarCloud in its MR analysis told that we have code duplication issue on these files:

These files are JSON files containing language translations.

Opening the MR to view the changes to the file, this is what was added:

Viewing the file in Sonar / Code Editor / Gitlab Editor, I can confirm that there’s no duplicated instance of the text that were added

Note that I fully expanded the file in SonarCloud and confirmed in Gitlab (viewing the file on the specific commit.

Is this likely a false positive detected?


There’s a vertical, grey line in your screenshots between the line numbers and the code. If you mouse over it, do you get this?

Duplicated Lines (-) on New Code - analyses-differ - SonarSource - Island_001

In fact, string values are ignored in duplication calculation. I think what’s going on here is that you changed one line in an already-duplicated block. And that’s what’s showing up as a duplicated line in your PR.

Does that make sense?



Yes, I got that info when hovering.

When I click on the Details, this is what I get (file below is the frontend_en.json file)

And this is supposedly the duplicated file:

It is stating that the blocks of code are duplicated in its entirety (lines 1-1949).

From the screenshot though, you may see that the blocks are not duplicated as one file contains the English and the other file contains the corresponding language translation.

If I am reading this correct, in the JSON files:


"Test": {
    "Account already created": "This account has already been created.",
    "Account Settings": "Account Settings"


"Test": {
    "Account already created": "Esta cuenta ya ha sido creada.",
    "Account Settings": "Configuración de la cuenta",

This will be marked as duplicated, just because of the property they have? Even if the definition for each property is different?

If this is the case, then will excluding them from the scan be the only recourse for them not to be flagged?


Again, string values are ignored for duplication calculation. So what analysis is looking at is something like :

And yes, if you don’t want these files picked up as duplicates of each other, I suggest you set a duplications exclusion.