View Source unnecessary_function_arguments (rebar3_hank v1.4.0)
The rule emits a warning for each function argument that is consistently ignored in all function clauses.
To avoid this warning, remove the unused argument(s).
note
Note
This rule will not emit a warning if the function implements a NIF call (assuming that the stub function calls erlang:nif_error/1,2
) or if it's a behaviour callback. In particular, the rule will not emit a warning for any exported function in modules that implement non-OTP behaviors or OTP behaviors that have dynamic callbacks, like gen_statem
or ct_suite
. It will also not emit a warning if the function is "known" even if not in a behaviour, like parse_transform/2.
Link to this section Summary
Functions
Rule ignore specifications. Example:
-hank([{unnecessary_function_arguments,
%% You can give a list of multiple specs or a single one
[%% Will ignore any unused argument from ignore_me/2 within the module
{ignore_me, 2},
%% Will ignore the 2nd argument from ignore_me_too/3 within the module
{ignore_me_too, 3, 2},
%% Will ignore any unused argument from any ignore_me_again/x
%% within the module (no matter the function arity)
ignore_me_again]}]).
Link to this section Types
-type imp_callbacks() :: #{File :: string() => [tuple()] | syntax_error}.
Link to this section Functions
-spec ignored(hank_rule:ignore_pattern(), term()) -> boolean().
-hank([{unnecessary_function_arguments,
%% You can give a list of multiple specs or a single one
[%% Will ignore any unused argument from ignore_me/2 within the module
{ignore_me, 2},
%% Will ignore the 2nd argument from ignore_me_too/3 within the module
{ignore_me_too, 3, 2},
%% Will ignore any unused argument from any ignore_me_again/x
%% within the module (no matter the function arity)
ignore_me_again]}]).