Credence.Pattern.NoCondTwoClauses (credence v0.6.0)

Copy Markdown

Detects cond with exactly two clauses where the second guard is true — a pattern that is just an if/else in disguise.

Bad

cond do
  low > high -> false
  true ->
    mid = div(low + high, 2)
    search(mid, target)
end

Good

if low > high do
  false
else
  mid = div(low + high, 2)
  search(mid, target)
end

Auto-fix

Rewrites as if/else using the first clause's guard as the condition. The condition is never modified.