Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of high and works with any version of Elixir.
Explanation
Variable names that shadow common Kernel functions hurt readability.
Why
Naming a variable max shadows Kernel.max/2. Code like
max(max, other) becomes ambiguous to readers and to lexical-grep
tools: is max a function call being shadowed, or the variable?
LLMs frequently generate this in Enum.reduce/3 accumulators or
function arguments because the name is the obvious one for the value.
Bad
Enum.reduce(list, 0, fn x, max -> max(max, x) end)
defp longest(strings, max), do: ...Good
Enum.reduce(list, 0, fn x, current_max -> max(current_max, x) end)
defp longest(strings, max_length), do: ...Names flagged
max, min, elem, hd, tl, length, abs, round, trunc,
div, rem, tuple_size, map_size, byte_size, bit_size.
Only binding sites are checked: = LHS, fn parameters, def/defp
parameters. References after the binding (e.g. max(max, x)) are not
flagged on their own — the binding is the root cause.
Check-Specific Parameters
There are no specific parameters for this check.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.