I have a large Eclipse project in which there exist several classes which, although they ceased to be used anywhere, were never marked @Deprecated.
How can I easily find all of these?
UCDetector (Unecessary Code Detector) is a Open Source eclipse PlugIn Tool to find unecessary (dead) public java code. It also tries to make code final, protected or private. Caveat: Cid mentions in the comments: UCDetector shall not work if there are interface implementations which will be known only at runtime.
Use Ctrl + Shift + H keys to search for classes.
The initial value is the bin directory directly under your project. Similarly, the Source tab provides access to the location of your source input folder(s). The Java perspective filters out the output folder from the Package Explorer. If you like, you can use the Navigator view to browse the output folder.
The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.
I also like to use UCDetector:
UCDetector (Unecessary Code Detector) is a Open Source eclipse PlugIn Tool to find unecessary (dead) public java code. It also tries to make code final, protected or private.
Bonus: it can also find cyclic dependencies between classes
(also a number of other tools -- including Findbugs -- knows how do do that too)
Caveat: Cid mentions in the comments:
UCDetector shall not work if there are interface implementations which will be known only at runtime.
It incorrectly marks the implementation classes as unused.
Update 2017: static code analysis has evolved quite a bit in 8 years.
Using SonarLint for Eclipse, you can use the the latest SonarJava 4.6 plugin to analyze your code.
It will find dead code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With