Credence.Pattern.NoUnlessElse
(credence v0.4.4)
Copy Markdown
Detects unless ... do ... else ... end — a style guide violation.
The Elixir style guide says: "Never use unless with else.
Rewrite these with the positive case first."
The fix swaps unless to if and reverses the branch bodies.
The condition is never modified.
Bad
unless MapSet.member?(set, value) do
:missing
else
:found
endGood
if MapSet.member?(set, value) do
:found
else
:missing
endAuto-fix
Replaces unless with if and swaps the do/else bodies.