Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Lint from console for only selected files

I am trying to create a custom Git pre-commit hook that checks (using Lint from console, via "gradlew") for possible issues. However, I can't find how to run Lint only in provided files. If I run something like

./gradlew app:lint

Lint analyzes all the project files, and this operation can take quite a bit of time. In this document, there is a "Incremental Lint" section, which covers something similar to what I am looking for. I also found this open issue, that is quite the same as my problem, but seems to be more specific, since it "automatically" retrieves the files to be linted.

To sum up: is it possible to run Lint from command line over a collection of files? Or I am just stucked in running it for the whole project?

Best regards

like image 702
jmm Avatar asked Oct 08 '14 14:10

jmm


People also ask

How do I check lint for a specific file?

There is also a dedicated Lint CLI available which allows to check particular directories/files [1]. With the --check option you are also free to limit the checks which are performed. See lint --help for more information.

How do you make lint baseline?

If you want to create a new baseline, manually delete the file and run lint again to recreate it. Then, run lint from the IDE (Analyze > Inspect Code) or from the command line as follows. The output prints the location of the lint-baseline. xml file.

Which command is used to run lint using gradle?

Invoking lint from gradle You can invoke lint in multiple ways: ./gradlew lint :will run lint on all modules for all variants. ./gradlew :app:lint :will run lint on the app module for all variants. ./gradlew :library:lint :will run lint on the library module for all variants.


1 Answers

There is also a dedicated Lint CLI available which allows to check particular directories/files [1].

Examples:

lint theDirYouWantToCheck/
lint orOneParticularFile.xml

With the --check option you are also free to limit the checks which are performed. See lint --help for more information.

One remark: If you are facing something like...

main: Error: "main" is a Gradle project. To correctly analyze Gradle projects, you should run "gradlew :lint" instead. [LintError]

...just cd deeper into the directory structure.

  1. http://developer.android.com/tools/help/lint.html
like image 101
André Diermann Avatar answered Oct 02 '22 04:10

André Diermann