Unused _Variables reported as such #66
Replies: 3 comments 4 replies
-
The idea of the rule is to spot parameters that are unused in all clauses of the function and therefore unnecessary. The function would work as well with one less argument. |
Beta Was this translation helpful? Give feedback.
-
Look no further than That function has three clauses… parse_host_port(_Scheme, DefaultPort, <<"[", HostPort/binary>>, Opts) -> %ipv6
…
parse_host_port(_Scheme, DefaultPort, "[" ++ HostPort, Opts) -> %ipv6
…
parse_host_port(_Scheme, DefaultPort, HostPort, _Opts) ->
… The first argument ( Just to be sure… this function is not a behavior callback. It's actually only used here and here. So, since the first argument is useless, it can be removed. That would turn parse_host_port(DefaultPort, <<"[", HostPort/binary>>, Opts) -> %ipv6
…
parse_host_port(DefaultPort, "[" ++ HostPort, Opts) -> %ipv6
…
parse_host_port(DefaultPort, HostPort, _Opts) ->
… …and it will simplify Cool, isn't it? 😎 |
Beta Was this translation helpful? Give feedback.
-
This rule name is confusing, it's the proposal for the new name (by @elbrujohalcon ) |
Beta Was this translation helpful? Give feedback.
-
Let's say I have this code
rebar3_hank
signals the parameter as unused. But I feel that naming unused variables (instead of simply using _) helps readability (I use it extensively).What is the rationale behind the warning? (or is there an option to turn it off I didn't notice?)
Beta Was this translation helpful? Give feedback.
All reactions