Pattern: Unnecessary binary expression
Issue: -
Unnecessary binary expression add complexity to the code and accomplish nothing. They should be removed.
The rule works with all binary expression included if and when condition. The rule also works with all predicates.
The rule verify binary expression only in case when the expression use only one type of the following
operators ||
or &&
.
Example of incorrect code:
val foo = true
val bar = true
if (foo || bar || foo) {
}
Example of correct code:
val foo = true
if (foo) {
}