Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lint check for unused methods (command line)

How can I achieve the same what is described in the following Stack Overflow question?

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

Using the command line only?

./gradlew lint ...
like image 979
hhg Avatar asked May 12 '17 14:05

hhg


People also ask

How do you check for lint problems?

Run lint using the standalone tool You can then locate the lint tool at android_sdk /cmdline-tools/ version /bin/lint . For example, you can issue the following command to scan the files under the myproject directory and its subdirectories.

How can I see unused methods in eclipse?

UCDetector (Unnecessary Code Detector) is a eclipse PlugIn tool to find unnecessary (dead) public java code. For example public classes, methods or fields which have no references.

How do you find the dead code?

The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.

What is lint command?

Description. The lint command checks C and C++ language source code for coding and syntax errors and for inefficient or non-portable code. You can use this program to: Identify source code and library incompatibility. Enforce type-checking rules more strictly than does the compiler.


2 Answers

Run lint from the command line

You can use the Gradle wrapper to invoke the lint task for your project by entering one of the following commands from the root directory of your project:

On Windows:

gradlew lint

On Linux or Mac:

./gradlew lint

You should see output similar to the following:

> Task :app:lint
Ran lint on variant release: 5 issues found
Ran lint on variant debug: 5 issues found
Wrote HTML report to file:<path-to-project>/app/build/reports/lint-results.html
Wrote XML report to file:<path-to-project>/app/build/reports/lint-results.xml

When the lint tool completes its checks, it provides paths to the XML and HTML versions of the lint report. You can then navigate to the HTML report and open it in your browser, as shown in figure 2.

you can check the docs "Improve your code with lint checks"

like image 122
Luis Galaz Avatar answered Sep 21 '22 11:09

Luis Galaz


If your project includes build variants, and you instead want to run the lint task for only a specific build variant, you must capitalize the variant name and prefix it with lint.

gradlew lintDebug

To learn more about running Gradle tasks from the command line, [read Build Your App from the Command Line.][1]

  [1]: https://developer.android.com/studio/build/building-cmdline
like image 21
Pallav Khare Avatar answered Sep 22 '22 11:09

Pallav Khare