简体   繁体   中英

Custom Lint check not running

I am currently trying to write a custom lint check that I am working on. I have created a separate java project and included it as a jar.

My problem is that no matter what, it seems that my custom check is not being run when analyzing my code base.

I've included a registry

class MyIssueRegistry : IssueRegistry() {
override val issues: List<Issue>
    get() = listOf(MyIssues.ISSUE_PATTERN)
}

And a detector

class MyIssueDetector : Detector(), Detector.UastScanner {

    override fun getApplicableUastTypes() = listOf(UClass::class.java)

    override fun createUastHandler(context: JavaContext) =
        MyIssueDetector(context)

    class MyIssueDetector(private val context: JavaContext) : UElementHandler() {
        override fun visitClass(node: UClass) {
            context.report(MyIssues.ISSUE_PATTERN, context.getNameLocation(node), "This is just a test")
        }
    }
}

I've also added attributes("Lint-Registry-v2": "com.pathto.lint.MyIssueRegistry") to my java project's gradle and included it in my app gradle as lintChecks project(":lint")

AFAIK this topic- My code should be throwing a warning everytime it reads a class, but the lint check is not being ran. Is there a step I am missing?

first, check your lint.jar is placed on the right path. my path is ~/.android/lint/lint.jar.

then execute command '$ANDROID_HOME/tools/bin/lint --show | grep 'your issue name'' to check your custom lint is attached or not.

and then you can put some log to your custom lint implementation just like using "System.out.println()"
hope this can help u.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM