Functions should not be called with extra arguments
- TOO_MANY_ARGS
- Code Quality
- Low
- cwe
This rule applies when a function is called with extra arguments.
For code readability and maintainability, this is not recommended because the extra arguments are always ignored in the function execution.
It is recommended to remove the unnecessary arguments or refactor the function itself to process the extra arguments.
Note: Not applied for empty functions and the case wherein arguments
is used.
Noncompliant Code Example
View with compliant examples side by sidefunction add(x, y) {
return x + y;
}
var sum = add(1, 2, 3); // TOO_MANY_ARGS alarm because 'add' function takes only 2 arguments.
Compliant Code Example
View with noncompliant examples side by sidefunction add3(x, y, z) {
return x + y + z;
}
var sum = add3(1, 2, 3);
Version
This rule was introduced in DeepScan 1.0.0-alpha.