java - 关闭 IntelliJ 中公共(public)函数的未使用代码警告

标签 java intellij-idea warnings visibility inspection

Eclipse 在这方面很聪明; IntelliJ 还没有。当然,如果一个函数未被使用(并且未经测试,我想我应该为此感到难过——即使它只是返回一个简单的变量,或者实现其他人的接口(interface))但是公开的,它可以在其他地方使用。在“检查”下查看并搜索“未使用”,我没有看到可见性设置。这种粒度存在吗?

最佳答案

If you want to highlight unused public methods, please enable the "Settings|Inspections|Declaration redundancy|Unused declaration" global inspection.

If you want to highlight unused private methods, please enable the "Settings|Inspections|Declaration redundancy|Unused symbol" local inspection.

So, if you want to highlight unused private members, but do not highlight unused public members, turn off "Unused declaration" and turn on "Unused symbol".

Source

我刚刚使用 IDEA 13.1.4 对其进行了测试,它完全按照描述工作。

关于java - 关闭 IntelliJ 中公共(public)函数的未使用代码警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23923696/

相关文章:

java - Android Java AsyncTask 在 Activity 重新启动后执行两次

python - 在不中断程序的情况下在 Python 中发出警告

gcc - 获取默认 GCC 警告列表

java - Spring原型(prototype)在运行时继承属性

java - 使用随机枢轴元素而不是中间元素代码进行快速排序

java - 如何解压缩 lzo_deflate 文件?

java - 每次我在 block 注释中按回车键时,IntelliJ 都会添加额外的 *

scala - 将现有的 sbt 项目导入 IntelliJ

java - 带有 List<String> 的原始类型给出编译错误

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP