1dialyzer(3)                Erlang Module Definition                dialyzer(3)
2
3
4

NAME

6       dialyzer - Dialyzer, a DIscrepancy AnaLYZer for ERlang programs.
7
8

DESCRIPTION

10       Dialyzer  is a static analysis tool that identifies software discrepan‐
11       cies, such as definite type  errors,  code  that  has  become  dead  or
12       unreachable  because  of  programming  error, and unnecessary tests, in
13       single Erlang modules or entire (sets of) applications.
14
15       Dialyzer starts its analysis from either debug-compiled  BEAM  bytecode
16       or  from  Erlang source code. The file and line number of a discrepancy
17       is reported along with an indication of what the discrepancy is  about.
18       Dialyzer  bases  its  analysis on the concept of success typings, which
19       allows for sound warnings (no false positives).
20

USING DIALYZER FROM THE COMMAND LINE

22       Dialyzer has a command-line version for  automated  use.  This  section
23       provides  a  brief description of the options. The same information can
24       be obtained by writing the following in a shell:
25
26       dialyzer --help
27
28       For more details about the operation of Dialyzer,  see  section   Using
29       Dialyzer from the GUI in the User's Guide.
30
31       Exit status of the command-line version:
32
33         0:
34           No  problems  were  found  during the analysis and no warnings were
35           emitted.
36
37         1:
38           Problems were found during the analysis.
39
40         2:
41           No problems were found during the analysis, but warnings were emit‐
42           ted.
43
44       Usage:
45
46       dialyzer [--add_to_plt] [--apps applications] [--build_plt]
47                [--check_plt] [-Ddefine]* [-Dname] [--dump_callgraph file]
48                [files_or_dirs] [--fullpath] [--get_warnings] [--gui] [--help]
49                [-I include_dir]* [--no_check_plt] [--no_indentation] [--no_native]
50                [--no_native_cache] [-o outfile] [--output_plt file] [-pa dir]*
51                [--plt plt] [--plt_info] [--plts plt*] [--quiet] [-r dirs]
52                [--raw] [--remove_from_plt] [--shell] [--src] [--statistics]
53                [--verbose] [--version] [-Wwarn]*
54
55   Note:
56       * denotes that multiple occurrences of the option are possible.
57
58
59       Options:
60
61         --add_to_plt:
62           The PLT is extended to also include the files specified with -c and
63           -r. Use --plt to specify which PLT to start from, and  --output_plt
64           to  specify where to put the PLT. Notice that the analysis possibly
65           can include files from the PLT if they depend  on  the  new  files.
66           This option only works for BEAM files.
67
68         --apps applications:
69           This  option  is typically used when building or modifying a PLT as
70           in:
71
72         dialyzer --build_plt --apps erts kernel stdlib mnesia ...
73
74           to refer conveniently to library applications corresponding to  the
75           Erlang/OTP  installation.  However,  this option is general and can
76           also be used during analysis to refer to  Erlang/OTP  applications.
77           File or directory names can also be included, as in:
78
79         dialyzer --apps inets ssl ./ebin ../other_lib/ebin/my_module.beam
80
81         --build_plt:
82           The  analysis  starts  from an empty PLT and creates a new one from
83           the files specified with -c and -r. This option only works for BEAM
84           files.  To  override  the default PLT location, use --plt or --out‐
85           put_plt.
86
87         --check_plt:
88           Check the PLT for consistency and rebuild it if it  is  not  up-to-
89           date.
90
91         -Dname (or -Dname=value):
92           When analyzing from source, pass the define to Dialyzer. (**)
93
94         --dump_callgraph file:
95           Dump  the call graph into the specified file whose format is deter‐
96           mined by the filename extension.  Supported  extensions  are:  raw,
97           dot,  and  ps.  If  something  else  is used as filename extension,
98           default format .raw is used.
99
100         files_or_dirs (for backward compatibility also as -c files_or_dirs):
101           Use Dialyzer from the command line to detect defects in the  speci‐
102           fied files or directories containing .erl or .beam files, depending
103           on the type of the analysis.
104
105         --fullpath:
106           Display the full path names of files for which warnings  are  emit‐
107           ted.
108
109         --get_warnings:
110           Make  Dialyzer  emit warnings even when manipulating the PLT. Warn‐
111           ings are only emitted for files that are analyzed.
112
113         --gui:
114           Use the GUI.
115
116         --help (or -h):
117           Print this message and exit.
118
119         -I include_dir:
120           When analyzing from source, pass the include_dir to Dialyzer. (**)
121
122         --no_check_plt:
123           Skip the PLT check when running Dialyzer. This is useful when work‐
124           ing with installed PLTs that never change.
125
126         --no_indentation:
127           Do not insert line breaks in types, contracts, and Erlang Code when
128           formatting warnings.
129
130         --no_native (or -nn):
131           Bypass the native code compilation of some key files that  Dialyzer
132           heuristically  performs  when dialyzing many files. This avoids the
133           compilation time, but can result in (much) longer analysis time.
134
135         --no_native_cache:
136           By default, Dialyzer caches the results of  native  compilation  in
137           directory               $XDG_CACHE_HOME/erlang/dialyzer_hipe_cache.
138           XDG_CACHE_HOME defaults to $HOME/.cache. Use this option to disable
139           caching.
140
141         -o outfile (or --output outfile):
142           When  using  Dialyzer  from  the  command  line,  send the analysis
143           results to the specified outfile rather than to stdout.
144
145         --output_plt file:
146           Store the PLT at the specified file after building it.
147
148         -pa dir:
149           Include dir in the path for Erlang. This is useful  when  analyzing
150           files that have -include_lib() directives.
151
152         --plt plt:
153           Use the specified PLT as the initial PLT. If the PLT was built dur‐
154           ing setup, the files are checked for consistency.
155
156         --plt_info:
157           Make Dialyzer print information about the PLT and  then  quit.  The
158           PLT can be specified with --plt(s).
159
160         --plts plt*:
161           Merge  the  specified PLTs to create the initial PLT. This requires
162           that the PLTs are disjoint (that is, do not have any module appear‐
163           ing in more than one PLT). The PLTs are created in the usual way:
164
165         dialyzer --build_plt --output_plt plt_1 files_to_include
166         dialyzer --build_plt --output_plt plt_n files_to_include
167
168           They can then be used in either of the following ways:
169
170         dialyzer files_to_analyze --plts plt_1 ... plt_n
171
172           or
173
174         dialyzer --plts plt_1 ... plt_n -- files_to_analyze
175
176           Notice the -- delimiter in the second case.
177
178         --quiet (or -q):
179           Make Dialyzer a bit more quiet.
180
181         -r dirs:
182           Same  as  files_or_dirs, but the specified directories are searched
183           recursively for subdirectories containing .erl or  .beam  files  in
184           them, depending on the type of analysis.
185
186         --raw:
187           When  using Dialyzer from the command line, output the raw analysis
188           results (Erlang terms) instead of the  formatted  result.  The  raw
189           format  is  easier to post-process (for example, to filter warnings
190           or to output HTML pages).
191
192         --remove_from_plt:
193           The information from the files specified with -c and -r is  removed
194           from  the  PLT.  Notice  that  this  can  cause a reanalysis of the
195           remaining dependent files.
196
197         --shell:
198           Do not disable the Erlang shell while running the GUI.
199
200         --src:
201           Override the default, which is to analyze BEAM files,  and  analyze
202           starting from Erlang source code instead.
203
204         --statistics:
205           Print information about the progress of execution (analysis phases,
206           time spent in each, and size of the relative input).
207
208         --verbose:
209           Make Dialyzer a bit more verbose.
210
211         --version (or -v):
212           Print the Dialyzer version and some more information and exit.
213
214         -Wwarn:
215           A family of options that selectively  turn  on/off  warnings.  (For
216           help  on  the  names of warnings, use dialyzer -Whelp.) Notice that
217           the options can also be specified in the file  with  a  -dialyzer()
218           attribute. For details, see section Requesting or Suppressing Warn‐
219           ings in Source Files.
220
221   Note:
222       ** options -D and -I work both from the command line and  in  the  Dia‐
223       lyzer  GUI; the syntax of defines and includes is the same as that used
224       by erlc(1).
225
226
227       Warning options:
228
229         -Werror_handling (***):
230           Include warnings for functions that only return by an exception.
231
232         -Wno_behaviours:
233           Suppress warnings about behavior callbacks that drift from the pub‐
234           lished recommended interfaces.
235
236         -Wno_contracts:
237           Suppress warnings about invalid contracts.
238
239         -Wno_fail_call:
240           Suppress warnings for failing calls.
241
242         -Wno_fun_app:
243           Suppress warnings for fun applications that will fail.
244
245         -Wno_improper_lists:
246           Suppress warnings for construction of improper lists.
247
248         -Wno_match:
249           Suppress warnings for patterns that are unused or cannot match.
250
251         -Wno_missing_calls:
252           Suppress warnings about calls to missing functions.
253
254         -Wno_opaque:
255           Suppress warnings for violations of opacity of data types.
256
257         -Wno_return:
258           Suppress warnings for functions that will never return a value.
259
260         -Wno_undefined_callbacks:
261           Suppress warnings about behaviors that have no -callback attributes
262           for their callbacks.
263
264         -Wno_unused:
265           Suppress warnings for unused functions.
266
267         -Wrace_conditions (***):
268           Include warnings for possible  race  conditions.  Notice  that  the
269           analysis  that finds data races performs intra-procedural data flow
270           analysis and can sometimes explode in time. Enable it at  your  own
271           risk.
272
273         -Wunderspecs (***):
274           Warn  about underspecified functions (the specification is strictly
275           more allowing than the success typing).
276
277         -Wunknown (***):
278           Let warnings about unknown functions and types affect the exit sta‐
279           tus  of the command-line version. The default is to ignore warnings
280           about unknown functions and types when  setting  the  exit  status.
281           When  using  Dialyzer from Erlang, warnings about unknown functions
282           and types are returned; the default is not to  return  these  warn‐
283           ings.
284
285         -Wunmatched_returns (***):
286           Include warnings for function calls that ignore a structured return
287           value or do not match against one of many possible return value(s).
288
289       The following options are also available, but their use is  not  recom‐
290       mended  (they  are  mostly  for Dialyzer developers and internal debug‐
291       ging):
292
293         -Woverspecs (***):
294           Warn about overspecified functions (the specification  is  strictly
295           less allowing than the success typing).
296
297         -Wspecdiffs (***):
298           Warn when the specification is different than the success typing.
299
300   Note:
301       *** denotes options that turn on warnings rather than turning them off.
302
303

USING DIALYZER FROM ERLANG

305       Dialyzer  can  be  used directly from Erlang. Both the GUI and the com‐
306       mand-line versions are also available. The options are similar  to  the
307       ones  given from the command line, see section  Using Dialyzer from the
308       Command Line.
309

REQUESTING OR SUPPRESSING WARNINGS IN SOURCE FILES

311       Attribute -dialyzer() can be used for turning off warnings in a  module
312       by  specifying  functions  or warning options. For example, to turn off
313       all warnings for the function f/0, include the following line:
314
315       -dialyzer({nowarn_function, f/0}).
316
317       To turn off warnings for improper lists, add the following line to  the
318       source file:
319
320       -dialyzer(no_improper_lists).
321
322       Attribute  -dialyzer() is allowed after function declarations. Lists of
323       warning options or functions are allowed:
324
325       -dialyzer([{nowarn_function, [f/0]}, no_improper_lists]).
326
327       Warning options can be restricted to functions:
328
329       -dialyzer({no_improper_lists, g/0}).
330
331       -dialyzer({[no_return, no_match], [g/0, h/0]}).
332
333       For help on the warning options, use dialyzer -Whelp. The  options  are
334       also enumerated, see function gui/1 below (WarnOpts).
335
336   Note:
337       Warning  option  -Wrace_conditions  has  no  effect  when set in source
338       files.
339
340
341       Attribute -dialyzer() can also be used for  turning  on  warnings.  For
342       example, if a module has been fixed regarding unmatched returns, adding
343       the following line can help in assuring that no  new  unmatched  return
344       warnings are introduced:
345
346       -dialyzer(unmatched_returns).
347

EXPORTS

349       format_warning(Msg) -> string()
350
351              Types:
352
353                 Msg = {Tag, Id, msg()}
354                   See run/1.
355
356              Get a string from warnings as returned by run/1.
357
358       format_warning(Msg, Options) -> string()
359
360              Types:
361
362                 Msg = {Tag, Id, msg()}
363                   See run/1.
364                 Options = [{indent_opt, boolean()}]
365
366              Get a string from warnings as returned by run/1.
367
368              If indent_opt is set to true (default), line breaks are inserted
369              in types, contracts, and Erlang code to improve readability.
370
371       gui() -> ok | {error, Msg}
372       gui(OptList) -> ok | {error, Msg}
373
374              Types:
375
376                 OptList
377                   See below.
378
379              Dialyzer GUI version.
380
381              OptList  :: [Option]
382              Option   :: {files,          [Filename :: string()]}
383                        | {files_rec,      [DirName :: string()]}
384                        | {defines,        [{Macro :: atom(), Value :: term()}]}
385                        | {from,           src_code | byte_code}
386                                             %% Defaults to byte_code
387                        | {init_plt,       FileName :: string()}
388                                             %% If changed from default
389                        | {plts,           [FileName :: string()]}
390                                             %% If changed from default
391                        | {include_dirs,   [DirName :: string()]}
392                        | {output_file,    FileName :: string()}
393                        | {output_plt,     FileName :: string()}
394                        | {check_plt,      boolean()},
395                        | {analysis_type,  'succ_typings' |
396                                           'plt_add' |
397                                           'plt_build' |
398                                           'plt_check' |
399                                           'plt_remove'}
400                        | {warnings,       [WarnOpts]}
401                        | {get_warnings,   boolean()}
402                        | {native,         boolean()}
403                                             %% Defaults to false when invoked from Erlang
404                        | {native_cache,   boolean()}
405
406              WarnOpts :: error_handling
407                        | no_behaviours
408                        | no_contracts
409                        | no_fail_call
410                        | no_fun_app
411                        | no_improper_lists
412                        | no_match
413                     | no_missing_calls
414                        | no_opaque
415                     | no_return
416                        | no_undefined_callbacks
417                        | no_unused
418                        | race_conditions
419                        | underspecs
420                        | unknown
421                        | unmatched_returns
422                        | overspecs
423                        | specdiffs
424
425       plt_info(string()) -> {'ok', [{atom(), any()}]} | {'error', atom()}
426
427              Returns information about the specified PLT.
428
429       run(OptList) -> Warnings
430
431              Types:
432
433                 OptList
434                   See gui/0,1.
435                 Warnings
436                   See below.
437
438              Dialyzer command-line version.
439
440              Warnings :: [{Tag, Id, Msg}]
441              Tag      :: 'warn_behaviour'
442                        | 'warn_bin_construction'
443                        | 'warn_callgraph'
444                        | 'warn_contract_not_equal'
445                        | 'warn_contract_range'
446                        | 'warn_contract_subtype'
447                        | 'warn_contract_supertype'
448                        | 'warn_contract_syntax'
449                        | 'warn_contract_types'
450                        | 'warn_failing_call'
451                        | 'warn_fun_app'
452                        | 'warn_matching'
453                        | 'warn_non_proper_list'
454                        | 'warn_not_called'
455                        | 'warn_opaque'
456                        | 'warn_race_condition'
457                        | 'warn_return_no_exit'
458                        | 'warn_return_only_exit'
459                        | 'warn_umatched_return'
460                        | 'warn_undefined_callbacks'
461                        | 'warn_unknown'
462              Id  = {File :: string(), Line :: integer()}
463              Msg = msg() -- Undefined
464
465
466
467Ericsson AB                     dialyzer 4.1.1                     dialyzer(3)
Impressum