I'm currently working on an Elixir project, compiled with Mix, that as a lot of clauses with the same name and arity (number of arguments) should be grouped together
warnings. The problem is that it is a choice to not group it together (for logical reasons), so I try to find a way to silent this type of warning.
I did some research, and I learned about the @compile
attribute which allows to silent some warnings like :nowarn_unused_vars
for example, but since the "same name and arity group" warn seams to be an Elixir warning, it can't be silent this way, so I'm looking for another solution without having to move the functions.
Thanks for your help.
I believe the answer is that you can't.
Recalling a discussion from 2015 in the Elixir Google Group: How do you disable specific warnings.
Per José:
Honestly, releasing/deploying code with warnings is not an option in my book. The reason we emit warnings instead of errors is because there is no reason to make your compilation fail right out of the box, better to collect the warnings and show them for all files, instead of have the frustrating process of fixing one error just for another one to show up. That's also why we don't plan to provide options for disabling warnings: they should be fixed, even if they don't error out upfront.
There was a suggested compromise in the thread that may work for you and simultaneously keep the functions you wanted grouped:
def event(:x, var), do: one_thing(var)
def event(:y, var), do: another_thing(var)
def event(:z, var), do: something_else_entirely(var)
Good luck!