Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

## Noncompliant Code Example

    function doSomething(a, b) { // "a" is unused
      return compute(b);
    }

## Compliant Solution

    function doSomething(b) {
      return compute(b);
    }

## Exceptions

When writing function callbacks, some arguments might be required as part of the function signature, but not actually needed by the callback code. For instance, JQuery has the 'each' helper to iterate over arrays or objects, but using the counter 'i' should remain optional:

    $(["first", "last"]).each(function (i, value) {
      computeSomethingWithValue(value);
    });

So only unused arguments listed at the end of the argument list will be flagged with issues because they could be omitted from the function signature. Unused arguments which are followed by an argument that _is_ used will be ignored.

Examples :

    var myFirsCallBackFunction = function (p1, p2, p3, p4) {  //unused p2 is not reported but p4 is
                                                  return p1 + p3; }

    var mySecondCallBackFunction = function (p1, p2, p3, p4) {  //unused p1, p2 and p3 are not reported
                                                  return p4; }

    var myThirdCallBackFunction = function (p1, p2, p3, p4) {  //unused p1 is not reported but p3 and p4 are
                                                  return p2; }

Further, when `arguments` is used in the function body, no parameter is reported as unused.

    function doSomething(a, b, c) {
      compute(arguments);
    }

## See

- MISRA C++:2008, 0-1-11
- MISRA C:2012, 2.7