How can I find all unused methods and variables of my project in the Android Studio IDEA?
如何在Android Studio IDEA中找到项目中所有未使用的方法和变量?
2 个解决方案
#1
59
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工作室(或更一般地说,在Intellij IDEA中),您可以指定要从Analyze-> Inspect Code ...分析的检查代码,然后定义代码的范围。您可以在下图中看到我的代码的结果:
In Declaration redundancy
you can see that "someMethod" is declared unused. Also, in Probable bugs
you can find variable i
is never used.
在声明冗余中,您可以看到“someMethod”被声明为未使用。此外,在可能的错误中,您可以找到变量i从未使用过。
#2
2
You can also install the QAPlug via File -> Settings -> Plugins -> Browse Repositories -> QAPlug.
您还可以通过文件 - >设置 - >插件 - >浏览存储库 - > QAPlug安装QAPlug。
For Mac: Android Studio -> Preferences... -> Plugins -> Browse Repositories -> QAPlug.
对于Mac:Android Studio - >首选项... - >插件 - >浏览存储库 - > QAPlug。
In QAPlug is PMD, FindBugs, Checkstyle and Hammurapi integrated. These tools are very nice to finde 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。这些工具非常适合查找死代码,错误,提高性能并使代码更具可读性。如果您为更大的项目工作,我强烈推荐这些工具。
#1
59
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工作室(或更一般地说,在Intellij IDEA中),您可以指定要从Analyze-> Inspect Code ...分析的检查代码,然后定义代码的范围。您可以在下图中看到我的代码的结果:
In Declaration redundancy
you can see that "someMethod" is declared unused. Also, in Probable bugs
you can find variable i
is never used.
在声明冗余中,您可以看到“someMethod”被声明为未使用。此外,在可能的错误中,您可以找到变量i从未使用过。
#2
2
You can also install the QAPlug via File -> Settings -> Plugins -> Browse Repositories -> QAPlug.
您还可以通过文件 - >设置 - >插件 - >浏览存储库 - > QAPlug安装QAPlug。
For Mac: Android Studio -> Preferences... -> Plugins -> Browse Repositories -> QAPlug.
对于Mac:Android Studio - >首选项... - >插件 - >浏览存储库 - > QAPlug。
In QAPlug is PMD, FindBugs, Checkstyle and Hammurapi integrated. These tools are very nice to finde 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。这些工具非常适合查找死代码,错误,提高性能并使代码更具可读性。如果您为更大的项目工作,我强烈推荐这些工具。