elixir-lang/elixir — pull request #1026 by josevalim (2013-05-07 02:32:56+00:00)
Title: Warn on unused imports

This is a pull request to solve issue #821. After this pull request is merged, an unused import is going to trigger a warn. This warning is not per function but per module. So if you import any number of functions from a module `Foo`, as long as you use one of those functions, you won't get a warning.

There are two "issues" with this patch:

1. We only warn missing imports inside a module.

2. It is common in Elixir code to provide "DSLs". For example, in ExUnit, we provide both `setup` and `teardown` macros that you may or may not use. Since this is part of ExUnit's DSL, we don't want to emit warnings. I have originally fixed this issue by passing a `warn: false` argument to those imports. However, [in a later commit](https://github.com/elixir-lang/elixir/commit/7bae0029f274f2a8398160d9567c31cc93e58a3f) I changed the code to automatically detect if the import should warn or not. Basically, if the import is explicit (i.e. it is not generated by a macro), it warns by default. The logic is simple but it is code complexity regardless.

Yay or nay?