Impact:Unknown 'null' severity
Likelihood:Unknown 'null' severity
Default Quality Profiles:Sonar way, MISRA C++ 2008 recommended
Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
There are some cases when you want to have an unused parameter (usually because the function has to conform to a fixed prototype, because it is virtual or it is going to be called from a template). In this case, and if the parameter is never used, an accepted practice is to leave it unnamed. If it is only sometimes used (for instance, depending on conditional compilation), you may, since C++17, use the [[maybe_unused]] attribute to be explicit about it.
In case of Objective-C it is acceptable to have unused parameters if the method is supposed to be overridden.
- MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
- MISRA C:2012, 2.7 - There should be no unused parameters in functions
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
- C++ Core Guidelines - F.9 - Unused parameters should be unnamed