Global unused declaration inspection
April 27th, 2009 by Alexey KudravtsevThanks to improvements in the internal indexes behind the Intellij IDEA code insight engine, Maia will be able to instantly highlight some java classes, methods and fields which are unused across the entire project.
To use the feature, enable the Unused declarations inspection.

Of course, all sorts of JEE @Inject annotations, test code entry points
and other implicit dependencies configured in the Unused declarations inspection
are deeply respected.
Tags: code inspections, highlighting, maia
April 27th, 2009 at 9:50 am
Whoa, this is crazy cool! Can’t wait for the first EAP.
April 27th, 2009 at 10:27 am
Long waited, indeed. Great stuff!
April 28th, 2009 at 8:47 am
By the way, shouldn’t this entry be also tagged “maia”?
July 8th, 2009 at 1:32 am
It is really cool! Helps me to found bug occured due wrong resolving.
Thanks a lot!
July 10th, 2009 at 8:52 am
Very exciting news! I can’t wait to run it against our diseased codebase
October 7th, 2009 at 6:36 am
Is there a way to disable this inspection for public methods? I still like the inspection to warn me about unused private/protected/package_private methods, but not for public methods.
The problem with this feature is that it doesn’t work well if you are developing an API of some sort, on which other projects (outside the scope of the currently opened IDEA project) depend.
Don’t get me wrong, I like this feature, but I would also like to configure it differently for public and non-public methods.
October 15th, 2009 at 2:25 pm
What about recursive global unused declarations? possibly with “remove entire declaration tree” action?
November 17th, 2009 at 4:34 am
I second Jan. There are many public methods in our project that are invoked through reflection, e.g. through Spring XML configuration. So now I see warnings everywhere, which is frustrating because I know these methods are used. I could turn \Unused declarations\ inspection off, but then I would also lose notifications of unused private methods, and that would be a shame.
November 23rd, 2009 at 4:16 pm
+1 to Jan. There should be an option to disable public declarations, but to keep it for other scopes.
December 9th, 2009 at 3:32 pm
I agree with you, Jan. There should be an option to disable this feature for public methods.
December 14th, 2009 at 6:28 am
Agreed with Jan - this feature made one of the most important inspection useless. Public methods should be excludable from the inspection!
Hope Jetbrains issue a fix soon.
January 13th, 2010 at 3:42 am
Partly agree with Jan - but with a caveat:
The optimal solution would be if this was configurable so that a project could specify whether:
- all public declarations will be excluded from inspection (suitable for some libraries etc, or for projects with lots of reflection or injection etc)
- declarations that are tagged as unused could be marked as “ignore usage - it really is in use I say!” - suitable for projects that have some reflection/injection/other reasons
- the project has a set of “entry points”, e.g. a set of interfaces/classes that define the “really public” part of your library, and remaining public declarations are checked for usage. This is due to the missing modularization support in Java, with Java7 this feature would be even more useful (but require modification/extension).
The last option would be extremely useful for me in my project!
January 29th, 2010 at 9:00 am
+1 to Jan. A great feature rendered virtually useless. And there doesn’t appear to be a fix in the 9.0.2 release..
January 29th, 2010 at 11:17 am
To disable the inspection for public methods, turn off the “Settings|Inspections|Declaration redundancy|Unused declaration” global inspection.