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.
Ide
I like Michael Stalker's solution here.
Treating warnings as errors always can get annoying during TDD, where you might be rapidly refactoring code while running tests.
Instead, you can make the --warnings-as-errors
flag conditional on your Mix env like this:
defmodule SomeProject.MixProject do
use Mix.Project
def project do
[
elixirc_options: [
warnings_as_errors: treat_warnings_as_errors?(Mix.env())
]
# ...
]
end
defp treat_warnings_as_errors?(:test), do: false
defp treat_warnings_as_errors?(_), do: true
end
Warnings will go ignored when testing, but not for a dev
or prod
compilation.