No Single-Match Maybe Blocks

View Source
Single-match maybe blocks should be avoided.
Note
This rule only works under Erlang/OTP 27+.
Avoid
maybe
{ok, A} ?= do:something()
endPrefer
{ok, A} = do:something()Note that maybe blocks with an else are perfectly acceptable, too:
maybe
{ok, A} ?= do:something()
else
OtherThing -> handle:this(OtherThing)
endRationale
Using a maybe block with only one match 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-match maybe block also improves readability and simplifies the control flow.
Options
- None.
Example configuration
{elvis_style, no_single_match_maybe, #{}}