Methods in production code only referenced from test code

The existing version of IntelliJ IDEA has a very nice feature, where unused methods are highlighted (non just private ones).
This has helped me to find tons of "production" code that was never used. Deleting this code typically highlighted even more unused code, triggering quite drastic cleanups in legacy code bases.

I often stumble upon another kind of "dead code": methods in production sources that are only ever called from test code.
Quite often there's some implementation, with a matching unit test, that is actually never used from the other production classes.
Typically when I find such code, the source control system shows that this method has been, throughout the last couple of years, cleaned up, refactored, tested, but never used. :)
Since the method has usages in test sources, IDEA does not flag it as unused.

I think it would be nice if IDEA 10 provided support for flagging such code.
It could be a dedicated inspection, since strictly speaking the "gray unused" highlighting would not be correct.
Sounds like a useful feature? Vote for

Other comments or ideas welcome of course.



Please sign in to leave a comment.