Credence.Pattern.NoRedundantAssignment
(credence v0.6.0)
Copy Markdown
Detects a variable (or tuple/list of plain variables) being assigned and immediately returned as the last two statements of a block.
This is a common LLM verbosity pattern where the assignment adds no value. In Elixir, the last expression in a block is its return value, so the intermediate binding is unnecessary.
Tier 1 — simple variable
# Bad
result = compute(x)
result
# Good
compute(x)Tier 2 — tuple/list of plain variables
# Bad
{a, b} = process(input)
{a, b}
# Good
process(input)Patterns containing literals (e.g. {:ok, result}) are NOT fixed because
the match acts as an assertion — removing it would change error behavior.
Map patterns are never fixed because reconstruction produces a subset.
Auto-fix
Replaces the last two statements with just the RHS of the assignment.