Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 601 Bytes

InvertedCondition.md

File metadata and controls

19 lines (12 loc) · 601 Bytes

Pattern: Use of inverted condition

Issue: -

Description

An inverted condition is one where a constant expression is used on the left hand side of the equals comparison. Such conditions can be confusing especially when used in assertions where the expected value is by convention placed on the right hand side of the comparison.

Example of violations:

boolean isTenCharactersLong(String value) {
    10 == value.size()  // violation
}

Further Reading