The use of parentheses, even those not required to enforce a desired order of operations, can clarify the intent behind a piece of code. However,
redundant pairs of parentheses could be misleading and should be removed.
Noncompliant code example
x = (y / 2 + 1) # Compliant even if the parenthesis are ignored by the compiler
if a && ((x+y > 0)) # Noncompliant
# ...
end
return ((x + 1)) # Noncompliant
Compliant solution
x = (y / 2 + 1)
if a && (x+y > 0)
# ...
end
return (x + 1)