How to check “The value of the local variable/field is not used” in Checkstyle?

爱⌒轻易说出口 提交于 2019-12-06 11:10:35

Checkstyle can't do that, I'm afraid, but PMD (rule) and FindBugs (rule) can.

Checkstyle and PMD operate only on the Java source, and it is harder to deduce field and variable use only from the source. FindBugs operates on the compiled class files, so it has an easier job in this case. PMD can only detect unused private fields and variables, which can be found by looking at a single source file.

Writing an "unused private field/variable detector" for Checkstyle is possible, if tedious. I would recommend going with the PMD tool for this, which also features a light-weight Eclipse plugin.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!