Function should not have duplicate parameter names

  • DUPLICATE_PARAM
  • Error
  • Medium
  • No tags

This rule applies when the function has duplicate parameter names.

If a function has duplicate parameter names, the later parameters shadow the earlier ones and the values passed at the earlier positions become inaccessible.

Noncompliant Code Example

View with compliant examples side by side
function foo(a, a) { // DUPLICATE_PARAM alarm
    return a + b;
}

Compliant Code Example

View with noncompliant examples side by side
function foo(a, b) {
    return a + b;
}

Version

This rule was introduced in DeepScan 1.19.0.

See

Was this documentation helpful?