Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of normal and works with any version of Elixir.
Explanation
@on_load runs once a module's code is loaded and before the module is
available for use. A hot upgrade loads the new version of every module it
touches, so a module already running gets its on_load function run a
second time, on the same node, for code that was never cold-started.
Code written assuming on_load only ever happens once (seeding a table,
starting a watcher, registering something that cannot be registered
twice) duplicates the work or raises on that second call. Guard it, or do
that work from Application.start/2 or a supervised process instead,
neither of which a hot upgrade calls again on its own.
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.