Credo Envvar
Add-on for Credo for checking environment variables that get evaluated at Elixir compile time. Please see Credo for usage.
How does it work? + Disclaimer
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.
Installation
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
Basic Usage
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
Contributing
- 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
Author
Theesit Konkaew (@kaorism)
License
CredoEnvvar is released under the MIT License. See the LICENSE file for further details.