Unused Symbol Detection

Jason Zaugg

Unused Symbols

Invariably as  code evolves, some lonely unused definitions are are left around. To help you find and eradicate these, IDEA now highlights unused vals, vars, and defs.

You can use the quick fix to delete the unused symbol.

Needless Vars

Similarly, IDEA highlights needless vars, that is, ones that are never assigned to, with a quick fix to convert it to a val.

Limitations

Currently this reference checking is not enabled for cross-file references, you still need to use Find Usages for these. This means that only locals and private class members are highlighted.

It is also disabled for implicit members, and for methods with special names (apply/unapply/update/map/flatMap/filter/withFilter/foreach), for which the reference checking is not yet comprehensive.

Comments below can no longer be edited.

3 Responses to Unused Symbol Detection

  1. Alain O'Dea says:

    May 1, 2011

    I am a heavy user of similar functionality in IntelliJ’s Java support and already enjoy the identfication of unnecessary vars.

    I am looking forward to putting this into action in cleaning up my code 🙂

  2. Jonathan Toland says:

    May 3, 2011

    Just wanted to say great work and thx for keeping us in the loop on incoming features!!

  3. Lurline says:

    May 4, 2011

    Thank you for making the effort to explain the terminlogy to the rookies!