Inaccurate and ambiguous duplications on Vue file

The required informations are below:

  • ALM: GitHub
  • CI system: Github Actions
  • Languages of the repository: JS, Vue

When there is a change as a block, we get an indicator line left side of the code lines and the right side of the names of the one who made that change. When you hover over that line indicator, we get a message as “Duplicated block. Click for details”.
However, SonarCloud does not show clearly which line causes the duplication when there are multiple changes as lines instead of blocks. It just says: “Duplicated Lines on New Code 1

Therefore, a PR fails due to the duplication and we don’t know which part causes this issue. It only says “Duplicated Lines on New Code 1”.

The changed lines are:

  1. <v-col class="col-12">
  2. a condition: if (!form?.validate()) return
  3. a condition: if (!this.selectedRule?.id) return
  4. a condition: if (!this.selectedRule?.id) return

The worst thing is neither we can change these lines nor we exclude this .vue file from the duplication analysis. How can we solve this issue?

ps. we have branch protection rule and this PR is blocked. I would really appreciated it that if i can get prompt support.

Hey there.

This may seem like a funny question: but on which lines of code are the changed lines? (Line 10, Line 400, Line 1000).

We’re deploying a fix today where the duplication indicator didn’t show if the duplication falls in a line > 500. I wonder if it’s the same issue.

Hello @Colin ,

Thank you for the reply. It seems we got the fix. However, we cannot view the duplicated lines clearly.
We are getting duplicated blocks on many parts of the code in the PR, however, they are not located on changed lines.

The changed lines are:

  1. Line 3: <v-col class="col-12">
  2. Line 986: a condition: if (!form?.validate()) return
  3. Line 1098: a condition: if (!this.selectedRule?.id) return
  4. Line 1120: a condition: if (!this.selectedRule?.id) return

After the fix is deployed, we started to view some duplicated blocks which are:

  1. Line 715 to 737
  2. Line 742 to 786
  3. Line 797 to 853
  4. Line 979 to 1003. This is the only range where we have a change in the code.
  5. Line 1023 to 1037
  6. Line 1039 to 1071
  7. Line 1147 to 1175
  8. Line 1204 to 1228
  9. Line 1239 to 1268
  10. Line 1288 to 1333
  11. Line 1340 to 1379

How can we solve this issue?

Hello @Sarath_Nair,
It seems Colin is on vacation.
Can you please check this issue? Thanks

@Furkan_YY I will reach out to you in private to get more info

1 Like

So based on the private message this is the outcome:

It can make sense to change the quality gate to not be as restrictive in regard to duplication.

Another option is to remove those files from duplication detection: Analysis Scope | SonarCloud Docs

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