The static analyser dialyzer (I use it via dialyxir) reports all usage of Logger (Logger.info "blah"
) as an unmatched return:
Expression produces a value of type 'ok' | {'error',_}, but this value is unmatched
I could write :ok = Logger.info "blah"
but obviously, it's cumbersome. I could also configure dialyser with -Wno_unmatched_returns
to ignore all theses warnings. However, I find them very informative and don't want to ignore them.
The documentation of dialyzer says that we can use module attributes to deactivate warnings on a per-module basis, but I fail to see if it's only possible to put this information in Elixir source files.
Is there a way to configure Dialyzer to ignore such warnings, but only for Logger?
There's documentation of the @dialyzer attribute here. You will need to search down the page a bit to find it.
In this particular case, I believe the following module attribute:
@dialyzer {:no_return, your_function_name: 1}
Should give you what you want. Just put it at the top of each module where you're using Logger like so:
defmodule MyLogging do
@dialyzer {:no_return, your_function_name: 1}
.
.
.
Note that it appears that you can only shut off the warnings for the functions in the current module. That is, it doesn't seem to be possible to shut off warnings for functions in a different module (e. g. Logger.info: 1
).
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