-
-
Save puzza007/1481140 to your computer and use it in GitHub Desktop.
deadcode detecting escript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env escript | |
%% -*- erlang -*- | |
%% Find unused exports in a given module | |
%% Example: deadcode mod_foo deps/foo/ebin deps/bar/ebin | |
%% Assumes this script is in a file named deadcode | |
main([Module0|Dirs]) -> | |
Module = list_to_atom(Module0), | |
{ok, _Pid} = xref:start(foo), | |
[xref:add_directory(foo, Dir) || Dir <- Dirs], | |
{ok, Answer} = xref:analyze(foo, exports_not_used, [{verbose, false}]), | |
io:format("==========~n", []), | |
[io:format("~p:~p/~p~n", [Mod, Fun, Arity]) || {Mod, Fun, Arity} <- Answer, | |
Mod =:= Module], | |
io:format("==========~n", []). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment