missing violation: CompareObjectsWithEquals
A source code analyzer
Brought to you by:
adangel,
juansotuyo
Hello,
only those cases are detected, that directly use objects. (val1 == val2)
If the compare is based on methods ( ob1.getVal() == obj2.getVal() ), PMD will not detect a object compare!
our code:
case 1:
Long val1 = merkmalbezeichnung.getDoktypoid();
Long val2 = doktypproztyp.getVondoktypoid();
if (val1 == val2) // is detected
case2:
//if (merkmalbezeichnung.getDoktypoid() == doktypproztyp.getVondoktypoid()) // is not detected
Stefan
Hi,
The trick here is to detect that .getDoktypoid() return an Object and not an int or a long, which is not trivial for PMD as it does not really have a good support for TypeResolution.
Thanks for the report anyway. If you can, we'll appreciate that you attach some unit tests to reproduce this issue. (Just look in PMD source code to see how unit are handled, this is very easy, you don't really have to write Java code).