Stelos10 Stelos10 - 3 months ago 26
Javascript Question

Sonarqube: Is it possible to adapt duplication metric for javascript code?

At the moment the duplication metric for JavaScript Code in SonarQube code is defined as followed:
“There should be at least 100 successive and duplicated tokens.
Those tokens should be spread at least on 10 lines of code.”


Is there a way to change the nummer of tokens and the number of lines? Since I want to have 5 lines.

Answer

Yes, you should put this line in your sonar-project.properties file.

sonar.cpd.js.minimumLines=5

See http://docs.sonarqube.org/display/HOME/Duplications:

A piece of code is considered as duplicated as soon as there are at least 100 successive and duplicated tokens (can be overridden with property sonar.cpd.${language}.minimumTokens) spread on at least 10 lines of code (can be overridden with property sonar.cpd.${language}.minimumLines)