Tidies and pretty-prints Erlang source code, removing unused functions, updating obsolete constructs and function calls, etc.
Caveats: It is possible that in some intricate uses of macros, the automatic addition or removal of parentheses around uses or arguments could cause the resulting program to be rejected by the compiler; however, we have found no such case in existing code. Programs defining strange macros can usually not be read by this program, and in those cases, no changes will be made.
If you really, really want to, you may call it "Inga".
Disclaimer: The author accepts no responsibility for errors introduced in code that has been processed by the program. It has been reasonably well tested, but the possibility of errors remains. Keep backups of your original code safely stored, until you feel confident that the new, modified code can be trusted.
Equivalent to dir("").
Equivalent to dir(Dir, []).
dir(Directory::filename(), Options::[term()]) -> ok
Types:
filename() (see module file)
Tidies Erlang source files in a directory and its subdirectories.
Available options:
true
, symbolic directory
links will be followed. The default value is
false
.true
, subdirectories will be
visited recursively. The default value is
true
.regexp
). Tidying will only be applied to those
regular files whose names match this pattern. The default
value is ".*\\.erl$"
, which matches normal
Erlang source file names.true
, no files will be
modified. The default value is false
.true
, progress messages will
be output while the program is running, unless the
quiet
option is true
. The default
value when calling dir/2 is true
.See the function file/2 for further options.
Equivalent to file(Name, []).
file(Name::filename(), Options::[term()]) -> ok
Tidies an Erlang source code file.
Available options are:
".bak"
(cf. the backups
option).true
, existing files will be
renamed before new files are opened for writing. The new
names are formed by appending the string given by the
backup_suffix
option to the original name. The
default value is true
.Name
argument is used.Function = (syntaxTree()) -> string()
erl_prettypr:format/2
.true
, no files will be
modified; this is typically most useful if the
verbose
flag is enabled, to generate reports
about the program files without affecting them. The default
value is false
.See the function module/2
for further options.
See also: module/2, erl_prettypr:format/2.
Equivalent to module(Forms, []).
module(Forms, Options::[term()]) -> syntaxTree()
Types:
Forms = syntaxTree() | [syntaxTree()]
syntaxTree() (see module erl_syntax)
Tidies a syntax tree representation of a module
definition. The given Forms
may be either a single
syntax tree of type form_list
, or a list of syntax
trees representing "program forms". In either case,
Forms
must represents a single complete module
definition. The returned syntax tree has type
form_list
and represents a tidied-up version of the
same source code.
Available options are:
true
, all matches
"{V1, ..., Vn} = E
" where E
is a
case-, if- or receive-expression whose branches all return
n-tuples (or explicitly throw exceptions) will be rewritten
to bind and export the variables V1
, ...,
Vn
directly. The default value is false
.{X, Y} = case ... of ... -> {17, foo()}; ... -> {42, bar()} endwill be rewritten to:
case ... of ... -> X = 17, Y = foo(), {X, Y}; ... -> X = 42, Y = bar(), {X, Y} end
true
, calls to
lists:map/2
and lists:filter/2
will
be rewritten using list comprehensions. The default value is
true
.true
, all options that affect
how the code is modified are set to "no changes". For example,
to only update guard tests, and nothing else, use the options
[new_guard_tests, idem]
. (Recall that options
closer to the beginning of the list have higher
precedence.)true
, unused functions will
not be removed from the code. The default value is
false
.true
, guard tests will be
updated to use the new names, e.g. "is_integer(X)
"
instead of "integer(X)
". The default value is
true
. See also old_guard_tests
.true
, all import statements
will be removed and calls to imported functions will be
expanded to explicit remote calls. The default value is
false
.true
, guard tests will be
changed to use the old names instead of the new ones,
e.g. "integer(X)
" instead of
"is_integer(X)
". The default value is
false
. This option overrides the
new_guard_tests
option.true
, all information
messages and warning messages will be suppressed. The default
value is false
.{Module, Name, Arity}
with tuples
{NewModule, NewName}
, specifying renamings of
calls to remote functions. By default, the value is the empty
list.{NewModule, NewName}
only. Only
calls matching the specified arity will match; multiple
entries are necessary for renaming calls to functions that
have the same module and function name, but different
arities.true
, progress messages
will be output while the program is running, unless the
quiet
option is true
. The default
value is false
.