Credence.Rule.InconsistentParamNames
(credence v0.2.0)
Copy Markdown
Detects functions where the same positional parameter uses different variable names across clauses.
Why this matters
LLMs generate function clauses semi-independently, often drifting parameter names between clauses of the same function:
# Flagged — first arg is "current" in one clause, "prev" in another
defp do_fibonacci(current, _next, 0), do: current
defp do_fibonacci(prev, current, steps), do: do_fibonacci(current, prev + current, steps - 1)
# Consistent — same name at each position across all clauses
defp do_fibonacci(prev, _current, 0), do: prev
defp do_fibonacci(prev, current, steps), do: do_fibonacci(current, prev + current, steps - 1)Inconsistent names make the reader question whether the function is
correct — if the first argument is called current in one clause and
prev in another, which is it?
Detection scope (strict)
Only simple variables are compared. A position is skipped if any clause uses a pattern, literal, or underscore-prefixed variable at that position. This avoids false positives on legitimate pattern-matching dispatch like:
def handle({:ok, result}), do: result
def handle({:error, reason}), do: raise reasonSingle-clause functions are never flagged.
Severity
:warning