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
Requires DynamicSupervisor and Registry child specs to declare a
:name option.
Both processes are typically referenced by name from the rest of the
application: DynamicSupervisor.start_child(MySupervisor, ...),
Registry.lookup(MyRegistry, key). Starting them anonymously means
callers must thread the pid through every callsite, and crashes
replace the pid with a new one — silently breaking every caller that
cached the old reference.
The check inspects list literals whose elements all look like child
specs (bare module aliases or {Module, opts} 2-tuples) and flags
DynamicSupervisor/Registry entries inside them that lack :name
(or set name: to a literal nil).
Map-form child specs (%{id: ..., start: {M, :start_link, [opts]}})
aren't inspected — they're rare and would require walking inside the
:start MFA tuple.
Bad
children = [
DynamicSupervisor,
{Registry, keys: :unique}
]Good
children = [
{DynamicSupervisor, name: MyApp.WorkerSupervisor},
{Registry, keys: :unique, name: MyApp.WorkerRegistry}
]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.