I find the compile time warnings very useful, but I can occasionally miss them, especially if it's on a pull request where the tests are running on a CI server.
Ideally I would specify something in the project mix file that would make the compiler more strict.
I want to this to be in effect for all mix tasks, and I do not want to have to pass the flag to the command, as this is easy to forget.
For example with a project with a compiler warning, this command should fail
mix clean && mix compile
As should this one
mix clean && mix test
In your mix.exs
:
def project do
[...,
aliases: aliases]
end
defp aliases do
["compile": ["compile --warnings-as-errors"]]
end
Then mix compile
will pass --warnings-as-errors
to the compile.elixir
subtask.
This also works for mix test
since it runs the compile
task implicitly.
If you don't add an alias, you can still run mix compile --warnings-as-errors
and it will do what you expect, but mix test --warnings-as-errors
will not do what you expect, since the flag does not reach the compile.elixir
task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With