equals - code inspection insanity.

I've enabled most of the code inspections in IntelliJ to get myself more familar with, well everything, but a number of the recommendation fight directly against each other.

One notable example is that equals methods should be final as whichever class defines the method is in charge of working out whether subtypes are equal or not.

However there is another rule that states that *no* methods should be final on a class due to not letting sub-classes override the behaviour, so which should it be?

Seems to me that the the "no methods should be final" should have an exception for equals and hashcode methods, as I've seen next to no examples of when a final equals method is bad in a concrete class.

1 comment
Comment actions Permalink

Just a common note: it's a known thing that there are inspections with mutually opposite meaning. It's supposed that every user can select inspections he needs and disable others.



Please sign in to leave a comment.