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

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

This rule checks that functions declared in same scope don't have identical names. Indeed, it is possible to declare 2 functions with the same name, but only the last definition will be kept by the JavaScript engine before starting execution of the whole code.

The following code illustrates this:

fun(); // prints "bar"

// first declaration of the function
function fun() {
  print("foo");
}

fun(); // prints "bar"

// redeclaration of the "fun" function: this definition overrides the previous one
function fun() {
  print("bar");
}

fun(); // prints "bar"

This use of duplicate function name is often unwanted and can lead to bugs and more generally to confusing code.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy