Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 462 Bytes

LogicInversion.md

File metadata and controls

20 lines (15 loc) · 462 Bytes

LogicInversion

Category: pmd
Rule Key: pmd:LogicInversion

⚠️ This rule is deprecated in favour of S1940.


Use opposite operator instead of negating the whole expression with a logic complement operator. Example:

public boolean bar(int a, int b) {

  if (!(a == b)) // use !=
    return false;

  if (!(a < b)) // use >=
    return false;

  return true;
}