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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.3 -->
<HTML>
<HEAD>
<TITLE>erl_lint</TITLE>
<SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
<STYLE TYPE="text/css">
<!--
.REFBODY { margin-left: 13mm }
.REFTYPES { margin-left: 8mm }
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
<IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>erl_lint</H1>
</CENTER>
<H3>MODULE</H3>
<DIV CLASS=REFBODY>
erl_lint
</DIV>
<H3>MODULE SUMMARY</H3>
<DIV CLASS=REFBODY>
The Erlang Code Linter
</DIV>
<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>
<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>
<LI>
unbound and unsafe variables
</LI>
<LI>
illegal record usage.
</LI>
</UL>
<P>Warnings include:
<P>
<UL>
<LI>
unused functions and imports
</LI>
<LI>
unused variables
</LI>
<LI>
variables imported into matches
</LI>
<LI>
variables exported from
<CODE>if</CODE>/<CODE>case</CODE>/<CODE>receive</CODE>
</LI>
<LI>
variables shadowed in lambdas and list
comprehensions.
</LI>
</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.
</DIV>
<H3>EXPORTS</H3>
<P><A NAME="module/1"><STRONG><CODE>module(AbsForms) -> {ok,Warnings}
| {error,Errors,Warnings}</CODE></STRONG></A><BR>
<A NAME="module/2"><STRONG><CODE>module(AbsForms, FileName) -> {ok,Warnings}
| {error,Errors,Warnings}</CODE></STRONG></A><BR>
<A NAME="module/3"><STRONG><CODE>module(AbsForms, FileName, CompileOptions) ->
{ok,Warnings} | {error,Errors,Warnings}</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<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>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<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>Since this module is of interest only to the maintainers of
the compiler, and to avoid having the same description in
two places to avoid the usual maintainence nightmare, the
elements of <CODE>Options</CODE> that control the warnings are
only described in <A HREF="javascript:erlhref('../../../../', 'compiler', 'compile.html#erl_lint_options');">compile(3)</A>.
<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(3)</A>, or parser <A HREF="erl_parse.html">erl_parse(3)</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.
</DIV>
<P><A NAME="is_guard_test/1"><STRONG><CODE>is_guard_test(Expr) -> bool()</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Expr = term()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<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>.
</DIV>
<P><A NAME="format_error/1"><STRONG><CODE>format_error(ErrorDescriptor) -> Chars</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ErrorDescriptor = errordesc()</CODE></STRONG><BR>
<STRONG><CODE>Chars = [char() | Chars]</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<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).
</DIV>
<H3>Error Information</H3>
<DIV CLASS=REFBODY>
<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>
</DIV>
<H3>See Also</H3>
<DIV CLASS=REFBODY>
<P><A HREF="erl_parse.html">erl_parse(3)</A>,
<A HREF="epp.html">epp(3)</A>
</DIV>
<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
Robert Virding - support@erlang.ericsson.se<BR>
</DIV>
<CENTER>
<HR>
<SMALL>stdlib 1.14.2<BR>
Copyright © 1991-2006
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>
|