SonarQube - Too many duplications references on file ... what is a compliant solution? or a useful configuration to find the real duplicates?
Asked Answered
E

0

6

I'm trying to analyse a huge java project (over 1 million lines of code) with SonarQube (version has to be 4.5.6 since the rule set is given, we're not allowed to change it and some rules and plugins don't work with 5.x) and stumbling over useless code duplication messages. The project uses EJB and so there are many code fragments repeating in each class with all those ejb methods (most being empty in most classes). Those are all marked as duplicate leading to an too many duplications message in the log.

Futheron: due to the hugeness of the project there are many files which need to import the same packages, so there are many blocks of the same import lines in the code which are reported as duplicates - but what would be a compliant solution to avoid this kind of duplication? Or is there some useful kind of configuration which will ignore such blocks of import lines but doesn't ignore other duplicated code? (this kind of sub problem was asked before here: SonarQube - duplicated block, how to change configuration - but it's not clear for which SonarQube version, so this may be different in SQ 4.5.6)

Furtheron: there are many simple getter and setter methods - due to those having the same structure and are mostly one liners which just differ in the name and member which is set/get, these are also found as duplicated code.

Overall: I get literally thousands of duplication messages, and didn't find one real code duplication yet because those real duplications are buried all over all those wrong ones.

So how to configure SonarQube code duplication to render it useful. Thanks for any hints. So far my solution for this issue is: ignore it - it just doesn't make sense to search for one hit among thousands of false positives.

Excretion answered 17/5, 2016 at 9:36 Comment(3)
Would it be possible to extract the boilerplate methods and getters/setters to parent classes?Hildebrandt
@G.Ann-SonarSourceTeam How should this be possible? With something like thousand classes which each have a bunch of private members where each has a getter/setter with more or less unique names - all these have the same one-liner structure, but the members have different names.Excretion
it was worth asking @ExcretionHildebrandt

© 2022 - 2024 — McMap. All rights reserved.