Parentheses should not be used for an already parenthesized expression

  • DUPLICATE_PARENS
  • Code Quality
  • Low
  • No tags

This rule applies when duplicate parentheses are used for an already parenthesized expression.

Those parentheses are redundant because the execution result is always the same without them. Also when the expression is complex, it can be hard to notice that the entire inner expression is just another parentheses.

Therefore, it is recommended to remove the duplicate parentheses for code readability and maintainability.

Noncompliant Code Example

View with compliant examples side by side
function foo(a, b, c, d) {
    return ((a * b)) / ((c * d)); // DUPLICATE_PARENS alarm
}

Compliant Code Example

View with noncompliant examples side by side
function foo(a, b, c, d) {
    return (a * b) / (c * d);
}

Version

This rule was introduced in DeepScan 1.25.0.

See

Was this documentation helpful?