[Ericsson AB]

erl_lint

MODULE

erl_lint

MODULE SUMMARY

The Erlang Code Linter

DESCRIPTION

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:

Warnings include:

Some of the warnings are optional, and can be turned on by giving the appropriate option, described below.

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.

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 = [term()]
FileName = FileName2 = atom() | string()
Warnings = Errors = [{Filename2,[ErrorInfo]}]
ErrorInfo = see separate description below.
CompileOptions = [term()]

This function checks all the forms in a module for errors. It returns:

{ok,Warnings}
There were no errors in the module.
{error,Errors,Warnings}
There were errors in the module.

The elements of Options selecting optional warnings are as follows:

{warn_format, Verbosity}
Causes warnings to be emitted for malformed format strings as arguments to io:format and similar functions. Verbosity 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. Verbosity 0 can also be selected by the option nowarn_format.
warn_unused_vars
Causes warnings to be emitted for variables which are not used, with the exception of variables beginning with an underscore ("Prolog style warnings"). No warnings for unused variables, which is the default, can be selected by the option nowarn_unused_vars.
warn_export_vars
Causes warnings to be emitted for all implicitly exported variables referred to after the primitives where they were first defined. No warnings for exported variables unless they are referred to in some pattern, which is the default, can be selected by the option nowarn_export_vars.
warn_shadow_vars
Causes warnings to be emitted for "fresh" variables in functional objects or list comprehensions with the same name as some already defined variable. The default is to warn for such variables. No warnings for shadowed variables can be selected by the option nowarn_shadow_vars.
warn_unused_import
Causes warnings to be emitted for unused imported functions. No warnings for imported functions, which is the default, can be selected by the option nowarn_unused_import.

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(3), or parser erl_parse(3) The warnings and errors returned have the following format:

    [{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) -> bool()

Types:

Expr = term()

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) -> string()

Types:

ErrorDescriptor = errordesc()

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:

apply(Module, format_error, ErrorDescriptor)

See Also

erl_parse(3), epp(3)

AUTHORS

Robert Virding - support@erlang.ericsson.se

stdlib 1.12.9
Copyright © 1991-2006 Ericsson AB