Credence.Rule.RedundantListGuard
(credence v0.2.0)
Copy Markdown
Detects redundant is_list/1 guards on variables already bound by a
cons pattern ([head | tail]).
Why this matters
The pattern [head | tail] destructures an Erlang cons cell, which
guarantees that tail is a list. Adding when is_list(tail) is
therefore a no-op that clutters the function signature without providing
any additional safety.
Flagged patterns
| Pattern | Fix |
|---|---|
def f([h | t]) when is_list(t) | def f([h | t]) |
def f([h | t]) when is_list(t) and is_atom(h) | def f([h | t]) when is_atom(h) |
def f([_ | a], [_ | b]) when is_list(a) and … | Remove each redundant is_list call |
Severity
:warning