Closed elbrujohalcon closed 1 year ago
Pattern-matching should not be used in case statement conditions, like this:
case
case #{a := A} = do:something() of #{b := good} -> {a, really, nice, A}; #{b := bad} -> {"not", a, good, A} end
YES
While the code as written above is valid, it's much harder to understand (particularly for large statements) than the one below.
case do:something() of #{a := A, b := good} -> {a, really, nice, A}; #{a := A, b := bad} -> {"not", a, good, A} end
Inspired by the Refactor.MatchInCondition rule from Credo
Refactor.MatchInCondition
No Match in Condition
Brief Description
Pattern-matching should not be used in
case
statement conditions, like this:Should be on by default?
YES
Options
Reasoning
While the code as written above is valid, it's much harder to understand (particularly for large statements) than the one below.
Refactoring Proposal
Origin (#281)
Inspired by the
Refactor.MatchInCondition
rule from Credo