table of contents
other versions
- jessie 1:17.3-dfsg-4+deb8u2
- jessie-backports 1:19.2.1+dfsg-2+deb9u1~bpo8+1
- stretch 1:19.2.1+dfsg-2+deb9u2
- testing 1:21.2.5+dfsg-1
- unstable 1:21.2.6+dfsg-1
- experimental 1:22.0~rc1+dfsg-1
erl_lint(3erl) | Erlang Module Definition | erl_lint(3erl) |
NAME¶
erl_lint - The Erlang Code LinterDESCRIPTION¶
This module is used to check Erlang code for illegal syntax and other bugs. It also warns against coding practices which are not recommended. The errors detected include:- *
- redefined and undefined functions
- *
- unbound and unsafe variables
- *
- illegal record usage.
- *
- unused functions and imports
- *
- unused variables
- *
- variables imported into matches
- *
- variables exported from if/case/receive
- *
- variables shadowed in lambdas and list comprehensions.
DATA TYPES¶
error_info() = {erl_scan:line(), module(), error_description()}error_description() = term()
EXPORTS¶
module(AbsForms) -> {ok, Warnings} | {error, Errors, Warnings}
module(AbsForms, FileName) -> {ok, Warnings} | {error, Errors, Warnings}
module(AbsForms, FileName, CompileOptions) -> {ok, Warnings} | {error, Errors, Warnings}
Types:
AbsForms = [erl_parse:abstract_form()]
FileName = atom() | string()
CompileOptions = [ compile:option()]
Warnings = [{ file:filename(), [ErrorInfo]}]
Errors = [{FileName2 :: file:filename(), [ErrorInfo]}]
ErrorInfo = error_info()
This function checks all the forms in a module for errors. It returns:
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 maintenance
nightmare, the elements of Options that control the warnings are only
described in compile(3erl).
The AbsForms of a module which comes from a file that is read through
epp, the Erlang pre-processor, can come from many files. This means
that any references to errors must include the file name (see
epp(3erl), or parser erl_parse(3erl)). The warnings and errors
returned have the following format:
- {ok,Warnings}:
- There were no errors in the module.
- {error,Errors,Warnings}:
- There were errors in the module.
[{FileName2,[ErrorInfo]}]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.
is_guard_test(Expr) -> boolean()
Types:
Expr = erl_parse:abstract_expr()
This function tests if Expr is a legal guard test. Expr is an
Erlang term representing the abstract form for the expression.
erl_parse:parse_exprs(Tokens) can be used to generate a list of
Expr.
format_error(ErrorDescriptor) -> io_lib:chars()
Types:
ErrorDescriptor = error_description()
Takes an ErrorDescriptor and returns a string which describes the error
or warning. This function is usually called implicitly when processing an
ErrorInfo structure (see below).
ERROR INFORMATION¶
The ErrorInfo mentioned above is the standard ErrorInfo structure which is returned from all IO modules. It has the following format:{ErrorLine, Module, ErrorDescriptor}A string which describes the error is obtained with the following call:
Module:format_error(ErrorDescriptor)
SEE ALSO¶
erl_parse(3erl), epp(3erl)stdlib 2.2 | Ericsson AB |