Using Dialyzer on Kazoo
After building the Kazoo project or some of its subdirectories one is able to run Dialyzer on it.
Dialyzer will check
-specs and inferred type information to try and find unexpected behaviour or bugs.
Run Dialyzer on applications/ and core/
This command, run from the root directory of the Kazoo repository,
will find BEAM files under
core/ and scan them with Dialyzer.
One can run Dialyzer only on
Note: all these Makefile targets depend on target
Run Dialyzer on particular files
Say you modified only a handful of files (be it even in different directories), you can check only those files against Dialyzer using this command:
make dialyze TO_DIALYZE='my_dir/ebin/my_file.beam other_dir/ebin/other_file.beam'
Note that Dialyzer is only run against BEAM files, but
make dialyze will try and find the corresponding
BEAM files if given
*.erl files or a
Thus note that your changed files need to be compiled for
make dialyze to find and scan them.
Run dialyzer on source files or whole directories:
make dialyze TO_DIALYZE='my_dir/ebin path/to/src/file.erl'
Where is the PLT?
This command, run from the root directory, will generate the PLT file Dialyzer needs.
This PLT includes OTP's main applications as well as Kazoo's
Note that inluding
core/ in the PLT will slow down Dialyzer significantly (and may crash if
your system does not have enough memory) while not adding much benefits to the scanning process.
make dialyze command will automatically build the PLT, if it does not exist already.
Note that this PLT file is dependent on the Erlang version running,
which means after switching to another Erlang version the PLT needs to be regenerated.
One can easily switch between Erlang versions with
kerl (not part of the Kazoo project).
False positives and filters
Using a not up-to-date Dialyzer may give a lot of false positives:
warnings on properly spec-ed functions
or warnings about specs that match a "bigger" type than it could match (
* Particularly on R15B02 to R16B, warnings about
To remove these there are filters implemented under
escript is what is behind the scenes of
One can call it directly and give it paths in place of using
make and passing the
Scripts to use
Other ways to use Dialyzer include:
scripts/dialyze-changed.bash: dialyzes the changed erl files as compared to
origin/master. You can supply additional beam files as arguments to the script as well.
scripts/dialyze-usage.bash': given a module name (likekz_json`), find all modules that use the supplied module and dialyze them together. This should suss out any modules that use the supplied module in an incorrect way (as well as plenty of other issues too, probably)