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!
Subscribe to Blog updates
Build a Spring Boot App with AI Assistant
In this article, we’ll be building a small Java Spring Boot web application in IntelliJ IDEA with the help of JetBrains AI Assistant. If you’d like to follow along with this tutorial, you’ll need IntelliJ IDEA Ultimate, as well as an active subscription to AI Assistant or the free seven-day trial…
IntelliJ IDEA 2024.1 EAP 6: Improved Workflow for Logs, Inline Breakpoints, In-Editor Code Review, and MoreEarly Access Program
IntelliJ IDEA 2024.1 EAP 6 is here! This new build is packed with a bunch of updates anticipated for the next major release. Highlights include an enhanced user experience with logs, advanced debugging capabilities, and improved integration with version control systems. You can download the new v…
IntelliJ IDEA 2024.1 EAP 5: Enhanced Support for GitHub Actions, Updates for the HTTP Client, and MoreEarly Access Program
Packed with numerous new features and enhancements, IntelliJ IDEA 2024.1 EAP 5 brings extended support for GitHub Actions, improved integration with popular frameworks such as Spring and Quarkus, updates to the HTTP Client, and much more.
IntelliJ IDEA 2024.1 EAP 4: Sticky Lines, Improved Startup Experience, and MoreEarly Access Program
The Early Access Program for IntelliJ IDEA 2024.1 continues with our latest build where you can preview new features, including convenient sticky lines in the editor, faster access to IDE functionality while indexing, and more. You can download the new version from our website, update directly fr…