googlesamples / android-custom-lint-rules

This sample demonstrates how to create a custom lint checks and corresponding lint tests
Apache License 2.0
968 stars 174 forks source link

Odd implementation of partial analysis in VectorDrawableCompatDetector #73

Open Lingviston opened 2 years ago

Lingviston commented 2 years ago

Hi! Please, read the whole issue, before rejecting it, as I think at least part of it is directly related to this project.

The chapter about partial analysis says, that we must fill the partialResult map and then process it in the checkPartialResults method. However, VectorDrawableCompatDetector seems to do it the other way around.

It fills the map in visitElement method, but processes it within the visitAttribute method. The oddest thing is that inside of the visitAttribute method the partial results of other projects are checked as well, however in my experiment (I copied the source code to my project and added some extra logging) at this point partial results were only containing the results of the scanned module. It makes the usage of the partial results redundant, doesn't it?

I wonder, if this VectorDrawableCompatDetector uses partial results in the expected manner. If yes, then could you also clarify the following:

Thanks in advance for the answers.

Lingviston commented 2 years ago

I have a feeling that the approach from VectorDrawableCompatDetector works only when checkDependencies is set to true in lint config. But this is not mentioned anywhere.