lint.xml和检查配置文件的上下文 [英] Context of lint.xml and inspection profile

查看:155
本文介绍了lint.xml和检查配置文件的上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio中,有 lint.xml 配置和 ./idea/inspectionProfiles/.xml 可通过 Settings => Editor => Inspections管理 em>.我了解 lint.xml 由lint命令行工具使用,并且检查配置文件由Android Studio IDE使用.

In Android Studio there is the lint.xml configuration and ./idea/inspectionProfiles/.xml manageable via Settings => Editor => Inspections. I understand lint.xml is used by lint command line tool and the inspection profile is used by Android Studio IDE.

官方文档位于此处.我还发现了该帖子皮棉如何与IntelliJ检查集成和这篇文章

The official documentation is here. I also found this post How is lint integrated with IntelliJ inspections in Android Studio? and this post Android lint on command-line missing issue groups (versus options available in Android Studio).

此答案在build.gradle中具有lintOptions {}块的很好示例.

This answer has a good example of lintOptions{ } block in build.gradle.

但是仍然缺少一些信息.

Yet there is some information missing.

  1. 规则的编号和名称是否相同?
  2. 是否有一种(简单的)方法可以将检查配置文件转换为 lint.xml ,反之亦然?
  3. 它们是完全分开的吗,还是有一种情况包含在另一种情况中?
  4. 除了上面提到的案例(例如对提交的分析)之外,还有哪一个被执行?
  1. Are numbers and names of the rules the same?
  2. Is there a (simple) way to convert inspection profile to the lint.xml and vice versa?
  3. Are they completely separated or are there cases when one is included in the other?
  4. Which one is executed apart from cases metioned above (e.g. analysis on commit)?

推荐答案

到目前为止,我可以总结我的研究.

I can sum up my research so far.

1.)检查配置文件正在扩展lint.xml,因此lint.xml规则的数量小于检查配置文件规则的数量. 当前的lint.xml规则集可以在此处找到.

1.) Inspection Profile is extending lint.xml, so the number of lint.xml rules is smaller than the number of Inspection profile rules. The current lint.xml ruleset can be found here.

2.)定义lint.xml后,可以在Android Studio中转到文件=>设置=>编辑器=>检查,然后使用 Manage =>导入下拉列表转到您的lint.xml.这将设置禁用lint.xml之外的所有规则.

2.) When you have defined a lint.xml, in your Android Studio you can go to File => Settings => Editor => Inspections and use the Manage => Import dropdown towards your lint.xml. This will set all rule outside lint.xml to be deactivated.

我不知道从InspectionProfile转换为lint.xml的任何方式.

I don't know of any way for convert from InspectionProfile into lint.xml.

3.)参见1.),检查配置文件正在扩展lint.xml.

3.) See 1.), Inspection Profile is extending lint.xml.

4.)由于Inspection Profile是本地使用的,并且在Android Studio中使用,因此它将在运行时在编辑器中执行,并在检查分析时提交. 您的lint.xml通常位于项目的根目录中,并提交到SVN/GIT中.然后,您的配置服务器(Jenkins,QuickBuild等)可以具有指定的任务来运行此lint.xml并处理其输出.

4.) As Inspection Profile is locally used and inside Android Studio, it is executed during runtime in the editor and on commit when analysis is checked. Your lint.xml is usually located in the project's root and submitted into SVN/GIT. Then your configuration server (Jenkins, QuickBuild etc.) can have a designated task to run this lint.xml and process its output.

其他有用的东西:

  • 您可以在Android Studio的终端中运行 gradlew lint .它将在/build/outputs/lint-results-debug.html 或指定的任何文件位置创建一个html页面.
  • 在Android Studio编辑器中打开lint.xml文件时,将为规则提供很多内容帮助.尽管如此,规则集似乎存在差距,例如Convert2Lambda在示例lint.xml中,但不在官方文档中.

  • You can run gradlew lint from the Terminal inside Android Studio. It will create a html page at /build/outputs/lint-results-debug.html or at any file position specified.
  • When you open a lint.xml file in your Android Studio editor, a lot of content assist is provided for the rules. Nevertheless there seems to be a gap in the rulesets, as e.g. Convert2Lambda is in the example lint.xml, but not in the official documentation.

尽管将 ./idea 置于版本控制之下通常不是一个好主意,但要使团队分配,您可以在/.idea/inspectionProfiles/MyInspectionProfile中提交检查配置文件.xml ,然后将其他所有文件放在/.idea 中.关于此主题的文章我找不到了,但是这种解决方案对我的团队来说就像一个魅力.

Despite that it is generally a bad idea to put ./idea under version control, for team distibution you can submit your Inspection Profile at /.idea/inspectionProfiles/MyInspectionProfile.xml and put every other file inside /.idea on ignore. There is an article on this topic I cannot find anymore, but this solution works like a charm for my team.

这篇关于lint.xml和检查配置文件的上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆