AutosarC++17_10-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
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Unused named parameters are often a result of a design changes and can lead to mismatched parameter lists.
Note: This rule does not apply to unnamed parameters, as overridden methods for some subclasses may need additional parameters.
Example
//% $Id: A0-1-3.cpp 291350 2017-10-17 14:31:34Z jan.babst $
#include <cstdint>
#include <vector>
// Compressor.h
class Compressor {
public:
using raw_memory_type = std::vector<uint8_t>;
raw_memory_type Compress(const raw_memory_type &in, uint8_t ratio);
private:
virtual raw_memory_type __Compress(const raw_memory_type &in,
uint8_t ratio) = 0;
};
// Compressor.cpp
Compressor::raw_memory_type Compressor::Compress(const raw_memory_type &in,
uint8_t ratio) {
return __Compress(in, ratio);
}
// JPEGCompressor.h
class JPEGCompressor : public Compressor {
private:
raw_memory_type __Compress(const raw_memory_type &in, uint8_t ratio) override;
};
// JPEGCompressor.cpp
JPEGCompressor::raw_memory_type
JPEGCompressor::__Compress(const raw_memory_type &in, uint8_t ratio) {
raw_memory_type ret;
// jpeg compression, ratio used
return ret;
}
// HuffmanCompressor.h
class HuffmanCompressor : public Compressor {
private:
raw_memory_type __Compress(const raw_memory_type &in, uint8_t) override;
};
// JPEGCompressor.cpp
HuffmanCompressor::raw_memory_type
HuffmanCompressor::__Compress(constraw_memory_type &in, uint8_t) {
raw_memory_type ret;
// Huffman compression, no ratio parameter available in the algorithm
return ret;
}
See Also
- C++ Core Guidelines [10]: F.9: Unused parameters should be unnamed
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
unused_parameter |
Unused named parameter of virtual function |
None |
False |
Options¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
ignore_address_taken_functions¶
ignore_address_taken_functions : bool = False
inspect_constexprs¶
inspect_constexprs : bool = False
inspect_nonvirtual_functions¶
inspect_nonvirtual_functions : bool = False
inspect_virtual_functions¶
inspect_virtual_functions : bool = True
inspect_virtual_functions_directly¶
inspect_virtual_functions_directly : bool = False
report_all_virtual_functions¶
report_all_virtual_functions : bool = False
report_unnamed_parameters¶
report_unnamed_parameters : bool = False
suppress_attribute_maybe_unused¶
suppress_attribute_maybe_unused
Filter action to apply to violations for objects marked asType: FilterAction
Default:
'suppress'
[[maybe_unused]] or __attribute__((unused)).
If set to "suppress", findings will be reported but marked as suppressed.
If set to "exclude", findings will not be reported at all.
If set to "normal", no special treatment is applied and the finding is reported as usual.
Option Types¶
These types are used by options listed above:
FilterAction¶
Used for the return value of add_filter() callbacks.normal
The violation proceeds as usual.exclude
The violation is excluded: The violation is discarded as if `--exclude` applied to it. The following filters won't get to see the violation, and it will not be imported into the database under any circumstances.suppress
The violation is suppressed as if `AXIVION DISABLE` applied to it. Whether the violation gets imported into the database is controlled by the Axivion CI configuration.