After request in this thread I created simple task for looking for unused public functions (mix xref unreachable returns information only about unused private functions).
Thanks! I was just checking out xref to see if it already did this. I’ll check it out this weekend. I was hoping to hook this into a CI pipeline to remind devs to trim dead code
So I have finally find some time to make it work for Elixir 1.10 and publish it on Hex.
Now it is implemented via compiler tracing, so it is only Elixir 1.10 and later, but thanks to that, it also works with ElixirLS.
Beware that it is still WIP, and there are some features missing, and it will print a lot (and by a lot I mean A LOT) of false positives as it do not filter out generated functions nor Elixir macros. So prepare for filtering out quite a lot.
Testers, suggestions, and pull requests are welcome.
What is not currently working:
Macros filtering
Generated functions filtering (so for example you need to filter out {:_, :__schema__, :_} if you use Ecto, all controller actions if you use Phoenix, etc.)
Lines for given functions, so all missing functions will be reported on top of the file
No way to filter out functions using regular expression
Most important change is check whether structures are used and will inform if not. Just pattern matching on the structure is enough to mark it as used.
From minor changes - it now do not fail on recompilation via Phoenix LiveReload or call to recompile/0 from IEx shell.