Duplicate Code Detection exclusion by method name

946 views
Skip to first unread message

Christian

unread,
Oct 28, 2016, 5:04:19 AM10/28/16
to SonarQube
Hello all,

in some projects we have a lot of duplicated code detected in entity classes which results from very similar order and similar hashCode and equals methods. Many classes have an id attribute, a getter for it, a setter for it, a hashCode and an equals method. Sometimes other attributes are quite common as well. Still it does not make much sense to have common superclasses for them.
That's why I suggest to have
a) a means to exclude certain methods (e.g. by regular expression matched to signature) from duplicate detection
b) possibility to mark detected duplicate code blocks as false positives.
While a) would certainly be more important to us.
What do you think? Or is there even a featured which can be used like that or a workaround?

Regards,
Christian

Christian

unread,
Oct 28, 2016, 5:16:19 AM10/28/16
to SonarQube
P.S. there was a discussion about this which did not seem to lead to any action: http://sonarqube-archive.15.x6.nabble.com/Checkstyle-Rule-Strict-Duplicate-Code-td3208415.html

Christian

unread,
Nov 3, 2016, 11:25:50 AM11/3/16
to SonarQube
Did my own PS cause this not to be answered? Or are there really no opinions about it?

G. Ann Campbell

unread,
Nov 3, 2016, 1:49:16 PM11/3/16
to SonarQube
Hi Christian,

I think you've gotten no response because there's no interest (other than yours) in your proposal.

Our attitude at SonarSource in general is that configuration is evil. When necessary, we make it available, but you will rarely see us jumping with enthusiasm on adding new configs.

Because you're not likely to get what you're asking for, I'll point out that you can work around your issue using some of the additional configurations, specifically exclusions (Administration > General Settings > Analysis Scope > Duplication Exclusions).


Ann
Reply all
Reply to author
Forward
0 new messages