问题描述
我试图创建一个自定义的Git预提交钩子,该钩子检查(使用控制台的Lint,通过"gradlew")是否存在问题.但是,我找不到如何仅在提供的文件中运行Lint.如果我运行类似的东西
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分析所有项目文件,此操作可能会花费很多时间.在此文档中,有一个增量棉绒"部分,它涵盖了与我所寻找的东西相似的东西.我还发现了这个公开问题,它与是我的问题,但似乎更为具体,因为它自动"检索了要整理的文件.
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.
总结:是否可以通过命令行在文件集合上运行Lint?还是我只为整个项目运行呢?
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?
最诚挚的问候
推荐答案
还有一个专用的 Lint CLI 可用于检查特定的目录/文件[1].
There is also a dedicated Lint CLI available which allows to check particular directories/files [1].
示例:
lint theDirYouWantToCheck/
lint orOneParticularFile.xml
使用--check
选项,您还可以限制执行的检查.有关更多信息,请参见lint --help
.
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]
...只是cd
更深入目录结构.
...just cd
deeper into the directory structure.
这篇关于从控制台仅对选定文件运行Lint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!