Suppressing lint issues in pure Java/Kotlin projects

37 views
Skip to first unread message

Zac Sweers

unread,
Sep 1, 2021, 11:43:42 PM9/1/21
to lint-dev
Since `@SuppressLint` is not available in these projects, are comments the only way to suppress in these? Would you consider adding an annotations artifact (or adding to `androidx.annotation`) to cover these? Or consider supporting `@SuppressWarnings`/`@Suppress` in Java/Kotlin like Error-Prone and Detekt do?

Tor Norbye

unread,
Sep 2, 2021, 12:54:44 AM9/2/21
to Zac Sweers, lint-dev
@Suppress and @SuppressWarnings should already be working (and have been for years) -- if they do not please file a bug with repro instructions!

-- Tor


On Wed, Sep 1, 2021 at 8:43 PM Zac Sweers <zac.s...@gmail.com> wrote:
Since `@SuppressLint` is not available in these projects, are comments the only way to suppress in these? Would you consider adding an annotations artifact (or adding to `androidx.annotation`) to cover these? Or consider supporting `@SuppressWarnings`/`@Suppress` in Java/Kotlin like Error-Prone and Detekt do?

--
You received this message because you are subscribed to the Google Groups "lint-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lint-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lint-dev/596255b3-e97c-4dd9-a665-dcb2d8d9cb7fn%40googlegroups.com.

Zac Sweers

unread,
Sep 2, 2021, 3:53:49 PM9/2/21
to lint-dev
Interesting, in testing it looks like the issue I'm stuck on is a custom lint we have to ensure `@Target` annotations include FIELD. The case I'm trying to suppress looks like this.

```
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@JsonQualifier // For access in Moshi deserialization
annotation class SlackEndpoint(...)
```

Where our lint requires that `@Target` includes `FIELD`. Using `@Suppress("MoshiUsageQualifierTarget")` on the class or file doesn't appear to work though. `//noinspection MoshiUsageQualifierTarget` however does work. Want me to file an issue?
Reply all
Reply to author
Forward
0 new messages