Requirement: We are interested in getting code duplications report >5 Lines
1.Change the default value for duplications to 5
In sonar-project.properties, 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
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
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 sonar-project.properties 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
Ah, now I understand better. If you’re analyzing C/C++ code on Community Edition, you are probably using SonarOpenCommunity/sonar-cxx.
Any issues you have belong on their GitHub repo so the maintainer can respond. Individual language analyzers define things like CPD tokens.
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.
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.