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:

3 Likes

I need to update it to use Elixir compiler tracing.

1 Like