Inform-Software / sonar-groovy

SonarQube plugin for Groovy
GNU Lesser General Public License v3.0
55 stars 25 forks source link

Does sonar-groovy detect code duplications? #20

Open smolnikov opened 4 years ago

smolnikov commented 4 years ago

I tried to use sonar-groovy to perform code analysis on our Jenkins pipeline lib written with groovy, but seems it doesn't detect the code duplications. Does it?

SMUnlimited commented 4 years ago

It does, at least sonar automatically does it with this plugin enabled. Not sure if the groovy plugin itself affects duplications in anyway.

Only problem is the duplication detection is odd with groovy. Sometimes it believes import statements are duplicated between different files which you can't do anything about. So you can only ignore the file from duplicates or increase the quality gate thresholds.

smolnikov commented 4 years ago

@SMUnlimited I'm not sure, but seems https://github.com/Inform-Software/sonar-groovy/blob/master/sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/foundation/GroovyHighlighterAndTokenizer.java is responsible for defining what is code duplication and what is not. But I'm definitely not an expert in groovy and sonar. The only thing I see is that sonar is reporting zero duplications even if I copy-paste 3-5 lines of code from one file to another.