Proposed Rule Name: SuspiciousEqualsCall? EqualsOnIncompatibleTypes?
Proposed Category: Error Prone
Description: This rule would trigger on calls of a.equals(b), where the static types of a and b don't have a common supertype (except Object).
Code like this usually comes up when you
- were thinking of slightly different objects (e.g. you meant to call
a.getId().equals(b) or something like that
- messed up a refactoring.
Code Sample:
Integer i;
String s;
if (i.equals(s)) { // violation
// do stuff
}
Possible Properties:
- Maybe a stricter mode, where one of the types must be a supertype of the other?
Proposed Rule Name: SuspiciousEqualsCall? EqualsOnIncompatibleTypes?
Proposed Category: Error Prone
Description: This rule would trigger on calls of
a.equals(b), where the static types ofaandbdon't have a common supertype (except Object).Code like this usually comes up when you
a.getId().equals(b)or something like thatCode Sample:
Possible Properties: