Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
LLMs tend to paste the same fully-qualified module name into every
call inside a function body. A single Credo.Code.prewalk is fine;
five of them in one function is unreadable slop.
Unlike Credo's AliasUsage (which flags every nested call and
excludes ~50 stdlib lastnames by default), this check only fires
when a module is used repeatedly within a single function body.
# bad — AI slop (3+ uses in one function)
def run(source_file) do
Credo.Code.prewalk(source_file, &walk/2, ctx)
Credo.Code.remove_metadata(pattern)
Credo.Code.remove_metadata(body)
end
# good
def run(source_file) do
alias Credo.Code
Code.prewalk(source_file, &walk/2, ctx)
Code.remove_metadata(pattern)
Code.remove_metadata(body)
end
# fine — only one use, no alias needed
def run(source_file) do
Credo.Code.prewalk(source_file, &walk/2, ctx)
endCheck-Specific Parameters
Use the following parameters to configure this check:
:min_count
Minimum uses of a module within a single function body (default: 3).
This parameter defaults to 3.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.