Erlang 静的解析 dialyzer を mio で試す

Erlang の静的解析ツール dialyzer を試す。マニュアルは→Erlang -- dialyzer

plt を作る

% dialyzer --build_plt \
-r /usr/local/lib/erlang/lib/kernel-2.13.5/ebin \
-r /usr/local/lib/erlang/lib/memcached-client-0.0.1/ebin \
-r /usr/local/lib/erlang/lib/mnesia-4.4.13/ebin \
-r /usr/local/lib/erlang/lib/os_mon-2.2.5/ebin \
-r /usr/local/lib/erlang/lib/stdlib-1.16.5/ebin

# 足りなかったので追加
% dialyzer --add_to_plt -r /usr/local/lib/erlang/lib/eunit-2.1.5/ebin
% dialyzer --add_to_plt -r /usr/local/lib/erlang/lib/crypto-1.6.4

解析する

dialyzer -Wno_return -I $(INCLUDE_DIR) -c $(EBIN_DIR)

結果

disk_log_h.erl:139: The variable Error can never match since previous clauses completely covered the type integer() | {'error',_,integer()}
logger.erl:108: Call to missing or unexported function error_logger:simple_logger/0
mio_bucket.erl:662: Call to missing or unexported function mio_sup:terminate_node/1
mio_local_store.erl:51: The attempt to match a term of type tid() against the pattern {'error', Reason} breaks the opaqueness of the term
mio_local_store.erl:68: The variable Other can never match since previous clauses completely covered the type 'true'
mio_logger.erl:113: Call to missing or unexported function error_logger:warn_msg/2
mio_memcached.erl:62: The variable Reason can never match since previous clauses completely covered the type {'ok',_}
mio_bucket_tests.erl:49: The variable _ can never match since previous clauses completely covered the type 'false'
mio_bucket_tests.erl:49: The pattern 'true' can never match the type 'false'

バグをたくさん見つけてくれました。ありがとう!。

開発プロセスに組み込む

make dialyzer で起動するようにした。解析には数分かかるので make check で起動するのはためらわれる。