的erl_tidy,最简单的方法 - 也是最直接的,如果你一直在你的源目录中运行一个,就是直接从 Eshell 使用它,如
$ erl
1> m(erl_tidy).
% output snipped
2> erl_tidy:dir(). % recursively tidy the present directory and its children
% output snipped
3> erl_tidy:dir("", [{recursive, false}]). % just the present directory
reading module `./bad.erl'.
made backup of file `./bad.erl'.
writing to file `./bad.erl'.
4>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,bad.erl从
-module(bad).
-compile(export_all).
bad(0)->1;bad(1)->2;bad(N)->3.bad()->0.
Run Code Online (Sandbox Code Playgroud)
到整理好的
-module(bad).
-compile(export_all).
bad ( 0 ) -> 1 ; bad ( 1 ) -> 2 ; bad ( N ) -> 3 . bad ( ) -> 0 .
Run Code Online (Sandbox Code Playgroud)
...好吧,这不是魔术师:-)
erl_tidy也可以通过参数调用 to erl,如
$ # unix prompt
$ erl -s erl_tidy dir
tidying directory `./wesnoth'.
tidying directory `./wesnoth/Vix'.
tidying directory `./wesnoth/Vix/utils'.
...
Run Code Online (Sandbox Code Playgroud)
erl_lint然而完全不同。要了解如何使用它,首先要了解这个字符串评估示例中发生了什么。 erl_lint旨在作用于 Erlang 源的中间表示,而不是它的字符串。
| 归档时间: |
|
| 查看次数: |
1715 次 |
| 最近记录: |