dialyzer
The Dialyzer, a DIscrepancy AnalYZer for ERlang programs
The Dialyzer is a static analysis tool that identifies software discrepancies such as type errors, unreachable code, unnecessary tests, etc in single Erlang modules or entire (sets of) applications. Dialyzer starts its analysis from either debug-compiled BEAM bytecode or from Erlang source code. The file and line number of a discrepancy is reported along with an indication of what the discrepancy is about. Dialyzer bases its analysis on the concept of success typings which allows for sound warnings (no false positives).
Read more about Dialyzer and about how to use it from the GUI in Dialyzer User's Guide.
Using the Dialyzer from the command line
Dialyzer also has a command line version for automated use. Below is a brief description of the list of its options. The same information can be obtained by writing
dialyzer --help
in a shell. Please refer to the GUI description for more details on the operation of Dialyzer.
The exit status of the command line version is:
0 - No problems were encountered during the analysis and no warnings were emitted. 1 - Problems were encountered during the analysis. 2 - No problems were encountered, but warnings were emitted.
Usage:
dialyzer [--help] [--version] [--shell] [--quiet] [--verbose] [-pa dir]* [--plt plt] [-Ddefine]* [-I include_dir]* [--output_plt file] [-Wwarn]* [--src] [-c applications] [-r applications] [-o outfile] [--build_plt] [--add_to_plt] [--remove_from_plt] [--check_plt] [--get_warnings]
Options:
-c applications
(or --command-line applications
).erl
or .beam
files)-r applications
-c
only that directories are searched recursively for
subdirectories containing .erl
or .beam
files (depending on the
type of analysis)-o outfile
(or --output outfile
)outfile
rather than in stdout--src
--raw
-Dname
(or -Dname=value
)-I include_dir
include_dir
to Dialyzer (**)-pa dir
dir
in the path for Erlang. Useful when analyzing files
that have -include_lib()
directives.--output_plt file
--plt plt
-Wwarn
dialyzer -Whelp
)--shell
--version (or -v)
--help (or -h)
--quiet (or -q)
--verbose
--check_plt
--no_check_plt
--build_plt
--add_to_plt
--remove_from_plt
--get_warnings
Note!
* denotes that multiple occurrences of these options are possible.
** options -D
and -I
work both from command-line and in the Dialyzer GUI;
the syntax of defines and includes is the same as that used by erlc
.
Warning options:
-Wno_return
-Wno_unused
-Wno_improper_lists
-Wno_fun_app
-Wno_match
-Werror_handling
***-Wunmatched_returns
***-Wunderspecs
***-Woverspecs
***-Wspecdiffs
***Note!
*** These are options that turn on warnings rather than turning them off.
Using the Dialyzer from Erlang
You can also use Dialyzer directly from Erlang. Both the gui and the command line version is available. The options are similar to the ones given from the command line, so please refer to the sections above for a description of these.
Functions
gui() -> ok | {error, Msg}
gui(OptList) -> ok | {error, Msg}
OptList -- see below
Dialyzer GUI version.
OptList : [Option] Option : {files, [Filename : string()]} \011 | {files_rec, [DirName : string()]} \011 | {defines, [{Macro: atom(), Value : term()}]} \011 | {from, src_code | byte_code} %% Defaults to byte_code \011 | {init_plt, FileName : string()} %% If changed from default \011 | {include_dirs, [DirName : string()]} \011 | {output_file, FileName : string()} \011 | {output_plt, FileName :: string()} \011 | {analysis_type, 'success_typings' | 'plt_add' | 'plt_build' | 'plt_check' | 'plt_remove'} \011 | {warnings, [WarnOpts]} \011 | {get_warnings, bool()} WarnOpts : no_return \011 | no_unused \011 | no_improper_lists \011 | no_fun_app \011 | no_match \011 | no_fail_call \011 | error_handling \011 | unmatched_returns \011 | overspecs \011 | underspecs \011 | specdiffs
run(OptList) -> Warnings
OptList -- see gui/0,1
Warnings -- see below
Dialyzer command line version.
Warnings :: [{Tag, Id, Msg}] Tag : 'warn_return_no_exit' | 'warn_return_only_exit' \011 | 'warn_not_called' | 'warn_non_proper_list' \011 | 'warn_fun_app' | 'warn_matching' \011 | 'warn_failing_call' | 'warn_contract_types' \011 | 'warn_contract_syntax' | 'warn_contract_not_equal' \011 | 'warn_contract_subtype' | 'warn_contract_supertype' Id = {File :: string(), Line :: integer()} Msg = msg() -- Undefined
format_warning(Msg) -> string()
Msg = {Tag, Id, msg()} -- See run/1
Get a string from warnings as returned by dialyzer:run/1.
plt_info(string()) -> {'ok', [{atom(), any()}]} | {'error', atom()}
Returns information about the specified plt.