readability-named-parameter¶
Find functions with unnamed arguments.
The check implements the following rule originating in the Google C++ Style Guide:
https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions
All parameters should have the same name in both the function declaration and definition. If a parameter is not utilized, its name can be commented out in a function definition.
int doingSomething(int a, int b, int c);
int doingSomething(int a, int b, int /*c*/) {
// Ok: the third param is not used
return a + b;
}
Corresponding cpplint.py check name: readability/function.
The check ignores parameters whose types are standard tag types (e.g.
std::in_place_t, std::allocator_arg_t, std::nothrow_t,
iterator tags, lock tags, etc.). The set of ignored types can be customized
with the IgnoredTypes option.
Options¶
- InsertPlainNamesInForwardDecls¶
When
true, the check will insert parameter names without comments for forward declarations only. Otherwise, the check will insert parameter names as comments (e.g.,/*param*/). Default isfalse.
- IgnoredTypes¶
A semicolon-separated list of fully-qualified type names whose parameters do not need to be named (for example, tag dispatch types, iterator tags, etc.). The following standard tag types are ignored by default:
std::adopt_lock_tstd::allocator_arg_tstd::bidirectional_iterator_tagstd::contiguous_iterator_tagstd::default_sentinel_tstd::defer_lock_tstd::destroying_delete_tstd::forward_iterator_tagstd::from_range_tstd::in_place_index_tstd::in_place_tstd::in_place_type_tstd::input_iterator_tagstd::nothrow_tstd::nostopstate_tstd::nullopt_tstd::output_iterator_tagstd::piecewise_construct_tstd::random_access_iterator_tagstd::sorted_equivalent_tstd::sorted_unique_tstd::try_to_lock_tstd::unexpect_tstd::unreachable_sentinel_t