No Single-Clause Case Expressions

View Source
Single-clause case expressions should be avoided.
Avoid
case do:something() of
{ok, Result} -> do:something("else")
endPrefer
{ok, Result} = do:something(),
do:something("else")Rationale
Using a case expression with only one clause is unnecessary and reduces code clarity. It adds
syntactic overhead without providing meaningful branching logic. In such cases, a let-style
assignment or direct pattern matching is typically more appropriate and idiomatic. Removing
single-clause case expressions also improves readability and simplifies the control flow.
Options
- None.
Example configuration
{elvis_style, no_single_clause_case, #{}}