Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get dialyzer to ignore certain unexported functions?

I'm using lager to do my logging; it has a parser transform which converts lager:warn/1, etc. functions into lager:trace... functions.

dialyzer doesn't process the parser transform, so it warns with Call to missing or unexported function lager:warn/1.

How do I tell it that this function does exist, and not to warn about it?

like image 992
Roger Lipscombe Avatar asked Dec 05 '13 16:12

Roger Lipscombe


People also ask

How do I use Erlang dialyzer?

When using Dialyzer from the command line, send the analysis results to the specified outfile rather than to stdout. Store the PLT at the specified file after building it. Include dir in the path for Erlang.

What is elixir dialyzer?

Dialyzer is a static analysis tool for Erlang and other languages that compile to BEAM bytecode for the Erlang VM. It can analyze the BEAM files and provide warnings about problems in your code including type mismatches and other issues that are commonly detected by static language compilers.


2 Answers

The best way to do it is to have dialyzer look at your compile beam files, as long as the parse transform is applied when the code is compiled and you include lager in your .plt file it will be fine

like image 59
Zachary K Avatar answered Sep 30 '22 10:09

Zachary K


Stumbled upon a way by checking out what's done in the meck project's Makefile regarding dialyzer. Have a look: Makefile
Key part is this:

| \
    fgrep -v -f ./dialyzer.ignore-warnings

So within that file: dialyzer.ignore-warnings you'll see what to do. In my version I added:

Call to missing or unexported function lager:warning/1
Call to missing or unexported function lager:warning/2
Call to missing or unexported function lager:info/1
Call to missing or unexported function lager:info/2
Call to missing or unexported function lager:error/1
Call to missing or unexported function lager:error/2

And the warnings I was getting went away. I do of course have this entry in my rebar.config:

{erl_opts, [{parse_transform, lager_transform}]}. 
like image 39
Khorkrak Avatar answered Sep 30 '22 10:09

Khorkrak