.TH erl_lint 3erl "stdlib 5.2.2" "Ericsson AB" "Erlang Module Definition" .SH NAME 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 that are not recommended\&. .LP The errors detected include: .RS 2 .TP 2 * Redefined and undefined functions .LP .TP 2 * Unbound and unsafe variables .LP .TP 2 * Illegal record use .LP .RE .LP The warnings detected include: .RS 2 .TP 2 * Unused functions and imports .LP .TP 2 * Unused variables .LP .TP 2 * Variables imported into matches .LP .TP 2 * Variables exported from \fIif\fR\&/\fIcase\fR\&/\fIreceive\fR\& .LP .TP 2 * Variables shadowed in funs and list comprehensions .LP .RE .LP Some of the warnings are optional, and can be turned on by specifying the appropriate option, described below\&. .LP The functions in this module are invoked automatically by the Erlang compiler\&. There is no reason to invoke these functions separately unless you have written your own Erlang compiler\&. .SH DATA TYPES .nf \fBerror_info()\fR\& = .br {erl_anno:location() | none, module(), error_description()} .br .fi .nf \fBerror_description()\fR\& = term() .br .fi .SH EXPORTS .LP .nf .B format_error(ErrorDescriptor) -> io_lib:chars() .br .fi .br .RS .LP Types: .RS 3 ErrorDescriptor = error_description() .br .RE .RE .RS .LP Takes an \fIErrorDescriptor\fR\& and returns a string that describes the error or warning\&. This function is usually called implicitly when processing an \fIErrorInfo\fR\& structure (see section Error Information)\&. .RE .LP .nf .B is_guard_test(Expr) -> boolean() .br .fi .br .RS .LP Types: .RS 3 Expr = erl_parse:abstract_expr() .br .RE .RE .RS .LP 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 .nf .B module(AbsForms) -> {ok, Warnings} | {error, Errors, Warnings} .br .fi .br .nf .B module(AbsForms, FileName) -> .B {ok, Warnings} | {error, Errors, Warnings} .br .fi .br .nf .B module(AbsForms, FileName, CompileOptions) -> .B {ok, Warnings} | {error, Errors, Warnings} .br .fi .br .RS .LP Types: .RS 3 AbsForms = [erl_parse:abstract_form() | erl_parse:form_info()] .br FileName = atom() | string() .br CompileOptions = [compile:option()] .br Warnings = Errors = [{SourceFile, [ErrorInfo]}] .br SourceFile = file:filename() .br ErrorInfo = error_info() .br .RE .RE .RS .LP Checks all the forms in a module for errors\&. It returns: .RS 2 .TP 2 .B \fI{ok,Warnings}\fR\&: There are no errors in the module\&. .TP 2 .B \fI{error,Errors,Warnings}\fR\&: There are errors in the module\&. .RE .LP As this module is of interest only to the maintainers of the compiler, and to avoid the same description in two places, the elements of \fIOptions\fR\& that control the warnings are only described in the \fIcompile(3erl)\fR\& module\&. .LP \fIAbsForms\fR\& of a module, which comes from a file that is read through \fIepp\fR\&, the Erlang preprocessor, can come from many files\&. This means that any references to errors must include the filename, see the \fIepp(3erl)\fR\& module or parser (see the \fIerl_parse(3erl)\fR\& module)\&. The returned errors and warnings have the following format: .LP .nf [{SourceFile,[ErrorInfo]}] .fi .LP The errors and warnings are listed in the order in which they are encountered in the forms\&. The errors from one file can therefore be split into different entries in the list of errors\&. .RE .SH "ERROR INFORMATION" .LP \fIErrorInfo\fR\& is the standard \fIErrorInfo\fR\& structure that is returned from all I/O modules\&. The format is as follows: .LP .nf {ErrorLine, Module, ErrorDescriptor} .fi .LP A string describing the error is obtained with the following call: .LP .nf Module:format_error(ErrorDescriptor) .fi .SH "SEE ALSO" .LP \fIepp(3erl)\fR\&, \fIerl_parse(3erl)\fR\&