Functions should not be called with extra arguments

  • 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 side
function 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 side
function add3(x, y, z) {
    return x + y + z;
var sum = add3(1, 2, 3);


This rule was introduced in DeepScan 1.0.0-alpha.


  • CWE-628

  • CWE-685

  • MISRA C:2004, Rule 16.6: The number of arguments passed to a function shall match the number of parameters.

  • MISRA C:2012, Rule 8.2: Number of formal and actual parameters passed to function do not match

Was this documentation helpful?