OptimumCredo.Check.Warning.EnvVarWithoutFailure (OptimumCredo v0.5.0)

View Source

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

Fail loudly on missing production environment variables.

Bad

if config_env() == :prod do
  client_id = System.get_env("GITHUB_CLIENT_ID")
end

Good

if config_env() == :prod do
  client_id = System.fetch_env!("GITHUB_CLIENT_ID")
end

Check-Specific Parameters

Use the following parameters to configure this check:

:optional_vars

Environment variable names that may be unset.

This parameter defaults to ["DNS_CLUSTER_QUERY"].

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.