Why is this an issue?
The use of parentheses, even those not required to enforce a desired order of operations, can clarify the intent behind a piece of code. But
redundant pairs of parentheses could be misleading, and should be removed.
Noncompliant code example
val x = (y / 2 + 1) // Compliant even if the parentheses are ignored by the compiler
if (a && ((x + y > 0))) { // Noncompliant
//...
}
return ((x + 1)) // Noncompliant
Compliant solution
val x = (y / 2 + 1)
if (a && (x + y > 0)) {
//...
}
return (x + 1)