slackhq / slack-lints

A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.
Apache License 2.0
225 stars 11 forks source link

Library lint checks reference invalid APIs #98

Closed SimonMarquis closed 1 year ago

SimonMarquis commented 1 year ago

When running Lint on an Android project, the lint issue correclty appears in the IDE but I get the following "silent" error when running the lint task (report extract):

Obsolete custom lint check
[../../../../../../.gradle/caches/modules-2/files-2.1/com.slack.lint/slack-lint-checks/0.3.0/f9bd0e9c9aee01014e1af6d85db0823a1f836590/slack-lint-checks-0.3.0.jar](https://github.com/.gradle/caches/modules-2/files-2.1/com.slack.lint/slack-lint-checks/0.3.0/f9bd0e9c9aee01014e1af6d85db0823a1f836590/slack-lint-checks-0.3.0.jar): Library lint checks reference invalid APIs; these checks will be skipped!

Lint found an issue registry (slack.lint.SlackIssueRegistry)
which contains some references to invalid API:
com.intellij.psi.PsiTypes: com.intellij.psi.PsiPrimitiveType voidType()
(Referenced from slack/lint/retrofit/RetrofitUsageDetector$createUastHandler$1.class)

Therefore, this lint check library is not included
in analysis. This affects the following lint checks:
CastingViewContextToActivity
[...]
ParcelizeFunctionProperty

To use this lint check, upgrade to a more recent version
of the library.

Is there a specific required version of Lint? Or indirectly AGP since I believe it's AGP that fixes the version of Lint that is used during lintAnalyze tasks. From what I can see, this project uses lint in version 31.2.0-alpha07.

https://github.com/slackhq/slack-lints/blob/fd01ddf324d748686c7e2b853e13add739270cab/gradle/libs.versions.toml#L8

Which would correspond to AGP 8.2.0-alpha07 (lint = agp + 23.0.0). I can't confirm this at the moment since upgrading agp is not very trivial in the current project, and I can't remember the gradle parameter to force lint version. But if it's confirmed, we probably should lower the required version to the latest stable, or maybe document it in the README.

ZacSweers commented 1 year ago

Yes this project follows the latest AGP lints, sorry. You don't have to update all of AGP to use newer lint. You can set the gradle property android.experimental.lint.version=8.2.0-alpha08 to force a newer lint version on older AGP versions.

SimonMarquis commented 1 year ago

Thanks a lot, this was the gradle property I was looking for. The lint errors are now correclty reported!