Credence.Pattern.NoGuardEqualityForPatternMatch
(credence v0.4.3)
Copy Markdown
Readability rule: Detects guard clauses that compare a parameter to a
literal value with == when pattern matching in the function head would
be clearer and more idiomatic.
This only flags simple var == literal comparisons where var is one of
the function's parameters and literal is an integer, atom, or string.
Bad
defp do_count(n, _a, b) when n == 2, do: b
def process(action) when action == :stop, do: :haltedGood
defp do_count(2, _a, b), do: b
def process(:stop), do: :halted