All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.DuplicateFunctionArgument.html Maven / Gradle / Ivy

There is a newer version: 2.5
Show newest version

Function arguments should all have different names to prevent any ambiguity. Indeed, if arguments have the same name, the last duplicated argument hides all the previous arguments with the same name (those previous arguments remain available through arguments[i], so they're not completely inaccessible).

This hiding makes no sense, clearly reduces understandability and maintainability, and obviously can be error prone. Furthermore, in JavaScript strict mode, declaring arguments with the same name produces an error. The following code snippet illustrates this rule :

Noncompliant Code Example

function compute(a, a, c) { // Noncompliant
}

Compliant Solution

function computeBis(a, b, c) { // Compliant
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy