File: erl_lint.html

package info (click to toggle)
erlang-doc-html 1%3A8.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 18,028 kB
  • ctags: 7,419
  • sloc: perl: 1,841; ansic: 323; erlang: 155
file content (140 lines) | stat: -rw-r--r-- 5,485 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>erl_lint</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>


<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>erl_lint</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
erl_lint</UL>
<H3>MODULE SUMMARY</H3>
<UL>
The Erlang Code Linter</UL>
<H3>DESCRIPTION</H3>
<UL>
<P>This module is used to check Erlang code for illegal syntax and
other bugs. It also warns against coding practices which are not recommended. <P>The errors detected include:<P><UL>
<LI>redefined and undefined functions</LI><BR>
<LI>unbound and unsafe variables</LI><BR>
<LI>illegal record usage.</LI><BR>
</UL>
<P>Warnings include:<P><UL>
<LI>unused functions and imports</LI><BR>
<LI>variables imported into matches</LI><BR>
<LI>variables exported from <CODE>if</CODE>/<CODE>case</CODE>/<CODE>receive</CODE></LI><BR>
<LI>variables shadowed in lambdas and list comprehensions.</LI><BR>
</UL>
<P>Some of the warnings are optional, and can be turned on by giving the
appropriate option, described below.<P>The functions in this module are invoked automatically by the Erlang compiler and there is no reason to invoke these functions separately unless you have written your own Erlang compiler.</UL>
<H3>EXPORTS</H3>
<P><A NAME="module%1"><STRONG><CODE>module(AbsForms) -&#62; {ok,Warnings} | {error,Errors,Warnings}</CODE></STRONG></A><BR>
<A NAME="module%2"><STRONG><CODE>module(AbsForms, FileName) -&#62; {ok,Warnings} | {error,Errors,Warnings}</CODE></STRONG></A><BR>
<A NAME="module%3"><STRONG><CODE>module(AbsForms, FileName, CompileOptions) -&#62; {ok,Warnings} | {error,Errors,Warnings}</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>AbsForms = [term()]</CODE></STRONG><BR>
<STRONG><CODE>FileName = FileName2 = atom() | string()</CODE></STRONG><BR>
<STRONG><CODE>Warnings = Errors = [{Filename2,[ErrorInfo]}]</CODE></STRONG><BR>
<STRONG><CODE>ErrorInfo = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>CompileOptions = [term()]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function checks all the forms in a module for errors. It returns:
<P><DL>
<DT><CODE>{ok,Warnings}</CODE></DT>
<DD>There were no errors in the module.<BR>
</DD>
<DT><CODE>{error,Errors,Warnings}</CODE></DT>
<DD>There were errors in the module.<BR>
</DD>
</DL>
<P>The elements of <CODE>Options</CODE> selecting optional warnings
        are as follows:
        <P><DL>
<DT><CODE>{warn_format, Verbosity}</CODE></DT>
<DD>Causes warnings to be emitted for malformed format strings
         as arguments to <CODE>io:format</CODE> and similar functions.
         <CODE>Verbosity</CODE> selects the amount of warnings: 0 = no warnings;
         1 = warnings for invalid format strings and incorrect number of
         arguments; 2 = warnings also when
         the validity could not be checked (for example, when the format
         string argument is a variable). The default verbosity is 1.
         <BR>
</DD>
<DT><CODE>warn_unused_vars</CODE></DT>
<DD>Causes warnings to be emitted for variables which are
         not used, with the exception of variables beginning with an
         underscore (&#34;Prolog style warnings&#34;).
         <BR>
</DD>
</DL>
<P>The <CODE>AbsForms</CODE> of a module which comes from a file that is read through <CODE>epp</CODE>, the
Erlang pre-processor, can come from many
files. This means that any references to errors must include
the file name (see <A HREF="epp.html">epp</A>, or parser <A HREF="erl_parse.html">erl_parse</A>
        The warnings and errors returned have the
following format:

<PRE>    [{FileName2,[ErrorInfo]}]</PRE><P>The errors and warnings are listed in the order in which they are
encountered in the forms. This means that the errors from one file may be
split into different entries in the list of errors.
</UL>
<P><A NAME="is_guard_test%1"><STRONG><CODE>is_guard_test(Expr) -&#62; bool()</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Expr = term()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function tests if <CODE>Expr</CODE> is a legal guard test. <CODE>Expr</CODE> is
         an Erlang term representing the abstract form for the expression.
         <CODE>erl_parse:parse_exprs(Tokens)</CODE> can be used to generate a list
         of <CODE>Expr</CODE>.
</UL>
<P><A NAME="format_error%1"><STRONG><CODE>format_error(ErrorDescriptor) -&#62; string()</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>ErrorDescriptor = errordesc()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Takes an <CODE>ErrorDescriptor</CODE> and returns a string which
describes the error or warning. This function is usually
called implicitly when processing an <CODE>ErrorInfo</CODE>
structure (see below).
</UL>
<H3>Error Information</H3>
<UL>
<P>The <CODE>ErrorInfo</CODE> mentioned above is the standard
<CODE>ErrorInfo</CODE> structure which is returned from all IO
modules. It has the following format:

<PRE>    {ErrorLine, Module, ErrorDescriptor}</PRE><P>A string which describes the error is obtained with the following call:

<PRE>apply(Module, format_error, ErrorDescriptor)</PRE></UL>
<H3>See Also</H3>
<UL>
<P><A HREF="erl_parse.html">erl_parse</A>,
<A HREF="epp.html">epp</A>
</UL>
<H3>AUTHORS</H3>
<UL>
Robert Virding - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright &copy; 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>