File: erl_lint.3

package info (click to toggle)
erlang-manpages 1%3A12.b.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,188 kB
  • ctags: 2
  • sloc: makefile: 68; perl: 30; sh: 15
file content (138 lines) | stat: -rw-r--r-- 3,606 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
.TH erl_lint 3 "stdlib  1.15.3" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
erl_lint \- The Erlang Code Linter
.SH DESCRIPTION
.LP
This module is used to check Erlang code for illegal syntax and other bugs\&. It also warns against coding practices which are not recommended\&. 
.LP
The errors detected include:
.RS 2
.TP 2
*
redefined and undefined functions
.TP 2
*
unbound and unsafe variables
.TP 2
*
illegal record usage\&.
.RE
.LP
Warnings include:
.RS 2
.TP 2
*
unused functions and imports
.TP 2
*
unused variables
.TP 2
*
variables imported into matches
.TP 2
*
variables exported from \fIif\fR/\fIcase\fR/\fIreceive\fR
.TP 2
*
variables shadowed in lambdas and list comprehensions\&.
.RE
.LP
Some of the warnings are optional, and can be turned on by giving the appropriate option, described below\&.
.LP
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\&.

.SH EXPORTS
.LP
.B
module(AbsForms) -> {ok,Warnings} | {error,Errors,Warnings}
.br
.B
module(AbsForms, FileName) -> {ok,Warnings} | {error,Errors,Warnings}
.br
.B
module(AbsForms, FileName, CompileOptions) -> {ok,Warnings} | {error,Errors,Warnings}
.br
.RS
.TP
Types
AbsForms = [term()]
.br
FileName = FileName2 = atom() | string()
.br
Warnings = Errors = [{Filename2, [ErrorInfo]}]
.br
ErrorInfo = see separate description below\&.
.br
CompileOptions = [term()]
.br
.RE
.RS
.LP
This function checks all the forms in a module for errors\&. It returns: 
.RS 2
.TP 4
.B
\fI{ok, Warnings}\fR:
There were no errors in the module\&.
.TP 4
.B
\fI{error, Errors, Warnings}\fR:
There were errors in the module\&.
.RE
.LP
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 \fIOptions\fR that control the warnings are only described in compile(3)\&. 
.LP
The \fIAbsForms\fR of a module which comes from a file that is read through \fIepp\fR, the Erlang pre-processor, can come from many files\&. This means that any references to errors must include the file name (see epp(3), or parser erl_parse(3) The warnings and errors returned have the following format: 

.nf
    [{FileName2,[ErrorInfo]}]        
.fi
.LP
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\&.
.RE
.LP
.B
is_guard_test(Expr) -> bool()
.br
.RS
.TP
Types
Expr = term()
.br
.RE
.RS
.LP
This function tests if \fIExpr\fR is a legal guard test\&. \fIExpr\fR is an Erlang term representing the abstract form for the expression\&. \fIerl_parse:parse_exprs(Tokens)\fR can be used to generate a list of \fIExpr\fR\&.
.RE
.LP
.B
format_error(ErrorDescriptor) -> Chars
.br
.RS
.TP
Types
ErrorDescriptor = errordesc()
.br
Chars = [char() | Chars]
.br
.RE
.RS
.LP
Takes an \fIErrorDescriptor\fR and returns a string which describes the error or warning\&. This function is usually called implicitly when processing an \fIErrorInfo\fR structure (see below)\&.
.RE
.SH ERROR INFORMATION
.LP
The \fIErrorInfo\fR mentioned above is the standard \fIErrorInfo\fR structure which is returned from all IO modules\&. It has the following format: 

.nf
    {ErrorLine, Module, ErrorDescriptor}    
.fi
.LP
A string which describes the error is obtained with the following call: 

.nf
apply(Module, format_error, ErrorDescriptor)    
.fi
.SH SEE ALSO
.LP
erl_parse(3), epp(3)