Add-on for Credo for checking environment variables that get evaluated at Elixir compile time. Please see Credo for usage.
This plugin does not guarantee 100% that all environment variables that are evaluated at compile time could be detected.
It just simply check wherever Application.get_env() or System.get_env() have been used outside def or defp. This will help you screen for most of the cases to make you less worried about environment variables compilation in your app.
If available in Hex, the package can be installed
by adding credo_envvar
to your list of dependencies in mix.exs
:
def deps do
[
{:credo, "~> 1.0.0", only: [:dev, :test], runtime: false},
{:credo_envvar, "~> 0.1.0", only: [:dev, :test], runtime: false}
]
end
And run:
$ mix deps.get
Add CredoEnvvar check to .credo.exs
in your project
#
## Warnings
#
{Credo.Check.Warning.BoolOperationOnSameValues},
{CredoEnvvar.Check.Warning.EnvironmentVariablesAtCompileTime}, # <- Add here
{Credo.Check.Warning.ExpensiveEmptyEnumCheck},
{Credo.Check.Warning.IExPry},
To run credo in the current project, just type:
$ mix credo
You can exclude files or paths with the excluded_paths
option:
{CredoEnvvar.Check.Warning.EnvironmentVariablesAtCompileTime, excluded_paths: ["test/support", "priv"]}
- Fork it!
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Theesit Konkaew (@kaorism)
CredoEnvvar is released under the MIT License. See the LICENSE file for further details.