OptimumCredo.Check.Warning.MixOutsideBuildConfig (OptimumCredo v0.5.0)
View SourceBasics
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
Mix does not exist in releases; do not call it from application code.
Bad
# lib/my_app/mailer.ex
if Mix.env() == :prod, do: deliver(email)Good
# config/runtime.exs
config :my_app, deliver_emails?: config_env() == :prodCalls guarded by Code.ensure_loaded?(Mix) are accepted.
Check-Specific Parameters
Use the following parameters to configure this check:
:allowed_paths
Directory fragments where Mix calls are allowed.
This parameter defaults to ["lib/mix/tasks"].
:allow_ensure_loaded_guard
Accept calls guarded by Code.ensure_loaded?(Mix).
This parameter defaults to true.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.