aboutsummaryrefslogtreecommitdiffstats
path: root/guide/dialyzer.html
blob: 0ec7be7750569fa7ce4a59c00aa40053198a0491 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Erlang.mk User Guide</title>
<style type="text/css"><!--
body{background:white;color:black;font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;justify-content:center;margin:0 auto;padding:0;width:600px}
header {align-items:center;display:flex;justify-content:center}
header nav.left{text-align:right;width:150px}
header nav.right{text-align:left;width:150px}
header nav a{display:block;margin:1.5em 1em}
main{margin-top:2em;text-align:justify}
main h2, main h3{margin-top:2em}
main h1, main div.chapter>div.titlepage h2{font-size:2em;margin-top:.67em}
a{color:#d9230f;text-decoration:none}
a:hover{text-decoration:underline}
a.xref{display:none}
h1, h2, h3{font-weight:normal}
div.navfooter{margin-bottom:1em}
--></style>
</head>
<body>
<header>
	<nav class="left">
		<a href="index.html">User guide</a>
		<a href="getting_started.html">Tutorials</a>
	</nav>
	<a href="/" class="logo"><img src="../res/logo-small.png" alt="Erlang.mk" title="Erlang.mk: A build tool for Erlang that just works" height="200" width="206"/></a>
	<nav class="right">
		<a href="https://github.com/ninenines/erlang.mk/tree/master/index">470+ packages</a>
		<a href="https://github.com/ninenines/erlang.mk/issues">Issues?</a>
	</nav>
</header>
<main>

<div class="navheader"><table width="100%" summary="Navigation header"><tr><td width="20%" align="left"><a accesskey="p" href="ci.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="xref.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="dialyzer"></a>Chapter 20. Dialyzer</h2></div></div></div><p>Dialyzer is a tool that will detect discrepancies in your
program. It does so using a technique known as success
typing analysis which has the advantage of providing no
false positives. Dialyzer is able to detect type errors,
dead code and more.</p><p>Erlang.mk provides a wrapper around Dialyzer.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_how_it_works"></a>20.1. How it works</h2></div></div></div><p>Dialyzer requires a PLT file to work. The PLT file contains
the analysis information from all applications which are not
expected to change, or rarely do. These would be all the
dependencies of the application or applications you are
currently working on, including standard applications in
Erlang/OTP itself.</p><p>Dialyzer can generate this PLT file. Erlang.mk includes rules
to automatically generate the PLT file when it is missing.</p><p>Once the PLT file is generated, Dialyzer can perform the
analysis in record time.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_configuration_5"></a>20.2. Configuration</h2></div></div></div><p>In a typical usage scenario, no variable needs to be set.
The defaults should be enough. Do note however that the
dependencies need to be set properly using the <code class="literal">DEPS</code> and
<code class="literal">LOCAL_DEPS</code> variables.</p><p>The <code class="literal">DIALYZER_PLT</code> file indicates where the PLT file will
be written to (and read from). By default this is
<span class="emphasis"><em>$(PROJECT).plt</em></span> in the project’s directory. Note that
the <code class="literal">DIALYZER_PLT</code> variable is exported and is understood
by Dialyzer directly.</p><p>The <code class="literal">PLT_APPS</code> variable can be used to add additional
applications to the PLT. You can either list application
names or paths to these applications.</p><p>Erlang.mk defines two variables for specifying options
for the analysis: <code class="literal">DIALYZER_DIRS</code> and <code class="literal">DIALYZER_OPTS</code>.
The former one defines which directories should be part
of the analysis. The latter defines what extra warnings
Dialyzer should report.</p><p>Note that Erlang.mk enables the race condition warnings
by default. As it can take considerably large resources
to run, you may want to disable it on larger projects.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_usage_4"></a>20.3. Usage</h2></div></div></div><p>To perform an analysis, run the following command:</p><pre class="programlisting">$ make dialyze</pre><p>This will create the PLT file if it doesn’t exist.</p><p>The analysis will also be performed when you run the
following command, alongside tests:</p><pre class="programlisting">$ make check</pre><p>You can use the <code class="literal">plt</code> target to create the PLT file if
it doesn’t exist. This is normally not necessary as
Dialyzer creates it automatically.</p><p>The PLT file will be removed when you run <code class="literal">make distclean</code>.</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ci.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="tests.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="xref.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div>
</main>
</body>
</html>