https://kotlinlang.org logo
#android
Title
# android
c

Colton Idle

03/24/2020, 10:32 PM
Does anyone know if it's possibly to write a lint check that just warns if there's a specific import being used?
b

Brandon Trautmann

03/24/2020, 10:35 PM
Absolutely
On our team we do this -- and add quick fixes to change the import to a desired one (if it applies to your use case)
c

Colton Idle

03/24/2020, 10:36 PM
Nice! I've only written
ResourceXmlDetector
so I'm trying to figure out what to extend for a java/kotlin file.
b

Brandon Trautmann

03/24/2020, 10:36 PM
SourceCodeScanner IIRC
And Detector as well
c

Colton Idle

03/24/2020, 10:38 PM
Hm. Doesn't seem to be autofilling. I will try to look up more docs and come back if I can't happen to figure it out. Thank you @Brandon Trautmann
👍 1
@Brandon Trautmann you sure it's not just
Detector(), UastScanner
as in
class SampleCodeDetector : Detector(), UastScanner {
https://github.com/googlesamples/android-custom-lint-rules/blob/master/android-studio-4/checks/src/main/java/com/example/lint/checks/SampleCodeDetector.kt
Found a better repo with more lint checks. I think I got it. Thank you https://github.com/tikurahul/lint-experiments/tree/master/lint/src/main/java/com/rahulrav
l

liminal

03/26/2020, 3:45 AM
There are a couple of examples of custom lint checks and their unit tests which you may find useful https://github.com/jshvarts/CustomLintRule
👍 1
4 Views