AUTOSAR C++14 Rule A0-1-5
There shall be no unused named parameters in the set of parameters for a virtual function and all the functions that override it
Since R2020a
Description
Rule Definition
There shall be no unused named parameters in the set of parameters for a virtual function and all the functions that override it.
Rationale
Unused parameters can indicate that the code is possibly incomplete. The parameter is possibly intended for an operation that you forgot to code.
The rule focuses on virtual functions because all functions that override a virtual function must have the same signature as the virtual function, including number and type of parameters. If a parameter is indeed not required, the issue can cascade from the original function to all overriding functions.
However, in an overriding function, you might not have need for a certain parameter. You can leave that parameter unnamed. This rule enforces the convention that unused parameters stay unnamed.
Polyspace Implementation
For each virtual function, the checker looks at all overrides of the function. If an override has a named parameter that is not used, the checker shows a violation on the original virtual function and lists the override as a supporting event.
Note that Polyspace checks for unused parameters in virtual functions within single translation units. For instance, if a base class contains a virtual method with an unused parameter but the derived class implementation of the method uses that parameter, the rule is not violated. However, if the base class and derived class are defined in different files, the checker, which operates file by file, flags a violation of this rule on the base class.
The checker does not flag unused parameters in functions with empty bodies.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Check Information
Group: Language independent issues |
Category: Required, Automated |
Version History
Introduced in R2020a