IntelliJ IDEA
IntelliJ IDEA – the Leading Java and Kotlin IDE, by JetBrains
IntelliJ IDEA 2016.3 EAP Makes Unused Code Detection More Flexible
Have you ever seen a project with no unused symbols? If so, you are really lucky! Jokes aside, finding unused code is difficult because of things like dependency injection, reflection, and countless frameworks. Luckily we have IntelliJ IDEA that provides instance editor highlighting and batch inspection that are a great aid in this task. Unfortunately, sometimes static information is not enough to detect that code is implicitly used by a framework or called through reflection, or your project is a library and all public methods are therefore implicitly used. To make the inspection more flexible and support all that cases, we’ve introduced the following settings.
Now, with IntelliJ IDEA 2016.3 EAP you can configure the IDE to treat your project as a library and report only private members:
Please note that public method of a private inner class will be treated as private as well.
It was always possible to annotate a member as used, but sometimes it’s tedious to annotate every second method just to make the inspection happy. Now you can specify class or method pattern which should be treated as entry points, e.g. used by test harness or by reflection.
The last but not the least, is that you can find code used from tests only. The code is strictly speaking reachable, but if your project is not a library, then you may consider removing it.
Bottom line: unused declaration inspection now reports unused parameters and unused local variables, sharing the settings with the instant editor highlighting.
Feedback is very welcome.
Develop with Pleasure!