Java 如何在 Android Studio IDE 中找到我项目中所有未使用的方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33674592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 14:54:13  来源:igfitidea点击:

How can I find all unused methods of my project in the Android Studio IDE?

javaandroidandroid-studiointellij-idea

提问by Hamed Ghadirian

How can I find all unused methods and variablesof my project in the Android Studio IDE?

如何在Android Studio IDE 中找到我项目中所有未使用的方法和变量

采纳答案by Hamed Ghadirian

In the android studio(or more generally in the Intellij IDEA) you can specify inspection code that you want to analyze from Analyze->Inspect Code...and then define the scope of your code. You can see the result for my code in the below picture:

在 android studio(或更一般地在 Intellij IDEA 中)中,您可以指定要从中分析的检查代码,Analyze->Inspect Code...然后定义代码的范围。您可以在下图中看到我的代码的结果:

enter image description here

在此处输入图片说明

In Declaration redundancyyou can see that "someMethod" is declared unused. Also, in Probable bugsyou can find variable iis never used.

Declaration redundancy你可以看到“someMethod”被声明为未使用。此外,Probable bugs您可以找到i从未使用过的变量。

回答by Erythrozyt

You can also install the QAPlug via File -> Settings -> Plugins -> Browse Repositories -> QAPlug.

您也可以安装QAPlug via File -> Settings -> Plugins -> Browse Repositories -> QAPlug.

For Mac:

对于 Mac:

Android Studio -> Preferences... -> Plugins -> Browse Repositories -> QAPlug.

In QAPlug is PMD, FindBugs, Checkstyle and Hammurapi integrated. These tools are very nice to find dead code, bugs, increase performance and make the code more readable. I highly recommend those tools if you work for a bigger project.

在 QAPlug 中集成了 PMD、FindBugs、Checkstyle 和 Hammurapi。这些工具非常适合查找死代码、错误、提高性能并使代码更具可读性。如果您为更大的项目工作,我强烈推荐这些工具。