在 Java Eclipse 项目中查找未使用的类 [英] Find unused classes in a Java Eclipse project
问题描述
我有一个大型 Eclipse 项目,其中存在多个类,尽管它们已不再在任何地方使用,但从未被标记为 @Deprecated.
如何轻松找到所有这些?
我也喜欢用 ——包括 Findbugs——也知道怎么做)
<小时><块引用>如果存在仅在运行时才知道的接口实现,UCDetector 将无法工作.
它错误地将实现类标记为未使用.
<小时>
2017 年更新:静态代码分析在 8 年里有了很大的发展.
使用SonarLint for Eclipse,您可以使用最新的SonarJava 4.6 插件来分析您的代码.
它将找到死代码.
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?
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.
这篇关于在 Java Eclipse 项目中查找未使用的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!