在Java Eclipse项目中查找未使用的类 [英] Find unused classes in a Java Eclipse project

查看:285
本文介绍了在Java Eclipse项目中查找未使用的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的Eclipse项目,其中有几个类,虽然它们在任何地方都不再使用,但从未被标记为@Deprecated。



找到所有这些?

解决方案

我也喜欢使用 - 包括Findbugs - 知道如何做到这一点)






警告 Cid 提及在评论中:



$ b

UCDetector不能工作,只有在运行时才会知道接口实现。
$ b




更新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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆