Code Duplications : In some files even though Code duplications are present but still not able to see in the sonarqube report generated


We are using SonarQube 7.6 Community Edition

Requirement: We are interested in getting code duplications report >5 Lines

1.Change the default value for duplications to 5
In, have set sonar.cpd.c.minimumLines=5

Observation Result:

1.In some files duplicate code is detected and in many files even though duplications >5 is present but still not able to see in the report generated after successful analysis

Can you please help.
Appreciate the support

Thanks and Regards,
Dhanush K C

Hey there.

SonarQube v7.6 is very old at this point. You should upgrade to at leaset v7.9 LTS, if nothing else to prepare yourself for the upcoming v8.x LTS.

If you still have an issue on a supported version of SonarQube, let us know.

1 Like

Sure, Will Check this version
Thanks for your timely support



In v7.9.6 LTS also same observation is reported
Can I know brief logic used by sonarqube for cpd detection because even though n lines are duplicated and present in the file but sonarqube is failing to detect it

Have set sonar.cpd.c.minimumLines=5

Note:Concern is in some A tool, duplications are reported for the same file but In SonarQube is failing to detect it

Is this is a bug or the logic is different. Ideally logic for cpd detection should be same using any tools


I would recommend you build a small reproducing project where you expect duplication to be reported (and is by some other tool) and share it here.

1 Like


Am attaching Sample_dup.txt(It is c file but while file uploading here .c extension is not supported hence uploading in .txt extension. Sample_dup.txt (3.0 KB) Kindly convert the extension of this file to .c ),

Some tool is able to detect duplications “Between lines 61 and 68” and “Between lines 10 and 17”. But Sonarqube is not able to detect duplications in this file .

Note : Have set duplications, sonar.cpd.c.minimumLines=5 in file.

Is this is a bug or the SonarQube logic for code duplications is different. Ideally logic for code duplication detection should be same using any other tools

Warm Regards,
Dhanush K C

Ah, now I understand better. If you’re analyzing C/C++ code on Community Edition, you are probably using SonarOpenCommunity/sonar-cxx.

  1. Any issues you have belong on their GitHub repo so the maintainer can respond. Individual language analyzers define things like CPD tokens.
  2. The language key you use in analysis parameters like sonar.cpd.[language].minimumLines will be different. I believe for this community-supported plugin, the language key is cxx.
1 Like

Yeah as guessed by you we are using the same SonarOpenCommunity/sonar-cxx.

Have raised the same issue in Github repo

Have tried using language key cpp also but the result is same.In community supported plugin there is a plugin for c language also which we are using hence language key is c only we guess.

Thanks for the support

Warm Regards,
Dhanush K C

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