Find unused classes in a Java Eclipse project

前端 未结 3 1058
时光说笑
时光说笑 2020-11-28 23:39

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

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 00:19

    I also like to use UCDetector:

    screenshot

    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.

提交回复
热议问题