Skip to content

Instantly share code, notes, and snippets.

@puzza007
Forked from kevsmith/gist:1473809
Created December 15, 2011 13:46
Show Gist options
  • Save puzza007/1481140 to your computer and use it in GitHub Desktop.
Save puzza007/1481140 to your computer and use it in GitHub Desktop.
deadcode detecting escript
#!/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