Many of the standard source code checking tools (PMD, FindBugs, Checkstyles) all implement a "String Equality" rule, where the usage of ==
(or !=
) when comparing strings can be detected and reported as an error.
I'm looking to write (or configure!) a similar rule that works on a set of other object types in my API.
//Want to detect things like:
Instance a = ...;
Instance b = ...;
if ( a == b ) //Error here, not using a.equals(b)
Looking at PMD & FindBugs there is no obvious (or easy) way to do this, has anyone come across something like this ?
Cheers, Ro
Doesn't CompareObjectsWithEquals in PMD work for you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With