找到所有未使用的变量 [英] Find all unused variable

查看:232
本文介绍了找到所有未使用的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常很容易在Netbeans中看到未使用的变量,只是一条灰色的波浪线。

Normally it's easy to see unused variables in Netbeans, just a grey squiggly line.

但我如何在项目或单个班级中找到所有这些未使用的变量?

But how would I find all of these unused variables in my project or of a single class?

原因: 我正在调试一个有很多复制和粘贴的代码库,但是没有仔细完成。复制和粘贴后没有替换正确的变量有很多错误。

Reason: I'm debugging a code base which had lots of copy and paste, but it wasn't done carefully. There's many bug of not replacing with the right variable after copy and paste.

推荐答案

你可以运行类似FindBugs的东西。

You could run something like FindBugs on it.

FindBugs

查看错误列表

UuF:未使用字段(UUF_UNUSED_FIELD)
此字段从不使用。考虑从课程中删除它。

UuF: Unused field (UUF_UNUSED_FIELD) This field is never used. Consider removing it from the class.

你可以过滤这个,但是最好一直在所有代码上运行它,这真是太神奇了发现。

You could filter on just this, but it is a good idea to run this on all code all the time, it is amazing what it finds.

这篇关于找到所有未使用的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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