How can I disable elixir compiler warnings
Asked Answered
R

2

6

When I do

mix compile

I get messages like

warning: variable "test_val" is unused
lib/myapp/mymodule.ex:46

I'm just hacking on a side project and I don't care about these warnings for now. Is there a way to turn this off?

Reply answered 22/3, 2018 at 6:32 Comment(0)
H
3

It doesn't look possible, but I could be wrong.

https://groups.google.com/forum/#!topic/elixir-lang-talk/XBnap4u6OkM

https://elixirforum.com/t/is-there-a-way-to-suppress-warnings-about-unused-variables/8637/7

The code that generates the warning (as best I can tell) is elixir_errors:warn and that doesn't have any flags to be able to turn off.

https://github.com/elixir-lang/elixir/search?p=1&q=%3Aelixir_errors.warn&type=&utf8=%E2%9C%93

Nor does it look like there are any code comments you can add to suppress the errors.

Consider it another facet of elixir's very opinionated viewpoint (right along with the "there's only one formatter, and it has no config")

Heda answered 22/3, 2018 at 6:58 Comment(2)
Your point is valid, but as a side note, the formatter is actually configurable ;-) hexdocs.pm/mix/Mix.Tasks.Format.html#module-formatting-optionsGlassful
And considering that he can shut off the "unused variable" warning with a relatively simple trick, I'd say your answer is somewhat inaccurate.Iceland
I
2

You can stop that particular compiler warning (i. e. test_val is unused) by proceeding the value with _. That is, rename the value to _test_val and you won't get the warning. But if you're warned the variable is unused, maybe you want to double check your code.

Iceland answered 22/3, 2018 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.