I wish there was unused code warning (that would ignore test calls)

I wish there was a warning for unused code. Currently if you have unused code covered by tests, it won’t be considered unused. So there is a good chance you forget to remove it during refactoring.

I’d love the compiler to warn me about unused code ignoring test calls. For the code that needs to be unused on purpose (e.g. to be called manually via console, or specifically for tests) there could be a special tag to suppress compiler warnings.

Public functions will never be considered unused, as they are considered part of your API.

Private functions can’t be called from tests, so I’m not sure what exactly you want to be warned about.

1 Like

Not a perfect solution but you may be interested in @hauleth’s mix unused library:


I need to update it to use Elixir compiler tracing.


this package doesn’t seem to be listed in hex anymore. at least not for elixir 1.11

It doesn’t seem like it was ever actually published on hex. Also it doesn’t seem to support Elixir 1.10 yet, although the PR to support that looks like it is mostly complete

Yes, I am working on migrating it to compiler traces. I think I can manage it next week and then release it on Hex.


very cool. thank you!