awful_waffle

awful_waffle

Enabling --warnings-as-errors flag?

Hello!

I recently discovered the --warnings-as-errors flag and strongly prefer the workflow of being blocked by compiler warnings. Warnings in Elixir seem to be much more important (i.e. calls to undefined functions) than what I typically see as warnings in my experience with other languages (i.e. lint errors, unused variables).

I’m currently working through a Phoenix project but found that mix phx.server --warnings-as-errors was unrecognized. Is there a way to tell mix/Elixir to use --warnings-as-errors under the hood when running phx.server?

Thank you for your help!

Marked As Solved

hauleth

hauleth

If you want to enable that flag by default you can use:

elixirc_options: [
  :warnings_as_errors
]

Also Liked

fuelen

fuelen

Hello!
--warnings-as-errors is a flag for mix compile.
What do you expect from --warnings-as-errors when running phx.server? Do not start server at all?
If so, then this command may help:

$ mix do compile --warnings-as-errors, phx.server
awful_waffle

awful_waffle

Thanks for the responses!

Adding elixirc_options: [warnings_as_errors: true] to my project in mix.exs achieved my goal! Now warnings display as errors when I am working in Phoenix, which works great with live reload. If I start the server with an error, it fails to run - which is fine with me.

The only down side is that the warning itself is not printed to the browser - it just shows a generic compilation error screen. The console in which I ran mix phx.server still displays the rest of the information, at least. I assume there is a configuration setting somewhere to output those warnings to the web display, but for now I am happy.

Thank you again!

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30840 112
New
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35953 110
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement