Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Context of lint.xml and inspection profile

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.

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).

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

Yet there is some information missing.

  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)?
like image 276
LastFreeNickname Avatar asked Mar 13 '17 10:03

LastFreeNickname


People also ask

What is lint XML?

The lint.xml file A configuration file that you can use to specify any lint checks that you want to exclude and to customize problem severity levels.


1 Answers

I can sum up my research so far.

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.) 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.

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

3.) See 1.), Inspection Profile is extending 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.

Additional, helpful things:

  • 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.

  • 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.

like image 55
LastFreeNickname Avatar answered Oct 31 '22 07:10

LastFreeNickname