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

查看:46
本文介绍了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.

官方文档在这里.我还发现了这篇文章 lint 是如何与 IntelliJ 检查集成的在 Android Studio 中? 和这篇文章 命令行缺失问题组上的 Android lint(相对于 Android Studio 中可用的选项).

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.

但是缺少一些信息.

  1. 规则的编号和名称是否相同?
  2. 是否有一种(简单的)方法可以将检查配置文件转换为 lint.xml,反之亦然?
  3. 它们是完全分开的还是存在其中一个包含在另一个中的情况?
  4. 除了上面提到的情况(例如对提交的分析)之外,还执行哪一个?

推荐答案

我可以总结我目前的研究.

I can sum up my research so far.

1.) Inspection Profile 是对 lint.xml 的扩展,因此 lint.xml 规则的数量小于Inspection Profile 规则的数量.可以在此处找到当前的 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 中,您可以转到 File => Settings => Editor => Inspections 并使用 Manage => Import 下拉到 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.),Inspection Profile 正在扩展 lint.xml.

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

4.) 由于检查配置文件在本地使用并在 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天全站免登陆