Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 527 Bytes

MisplacedNullCheck.md

File metadata and controls

15 lines (13 loc) · 527 Bytes

MisplacedNullCheck

Category: pmd
Rule Key: pmd:MisplacedNullCheck

⚠️ This rule is deprecated in favour of S1697, S2259.


The null check here is misplaced. if the variable is null you'll get a NullPointerException. Either the check is useless (the variable will never be null) or it's incorrect.
Example :

if (object1!=null && object2.equals(object1)) { 
  ...
}