tir38
tir38

Reputation: 10441

Why can't I suppress Android lint via comment

For some lint checks I can suppress them with a comment or a method annotation. ConstantConditions is a good example:

Android Studio screenshot showing multiple suppress options

However for other checks I can only suppress via a method annotation. CheckResult is an example.

Android Studio screenshot showing only one option

Is there any reason for this difference? Is it just that Android tools team hasn't added a comment-based suppression check?

Upvotes: 1

Views: 395

Answers (1)

italankin
italankin

Reputation: 846

Basically, Android Studio comes with a two sets of inspections:

  1. inspections from Intellij IDEA
  2. inspections from Android Lint

So, ConstantConditions is an Intellij IDEA inspection, and CheckResult is coming from Android Lint.

I think the reason that Android Lint checks usually disabled with @SuppressLint annotation is just that it's technically easier to understand that check is suppressed or not for a particular source code element.

Actually, you can suppress a check will comment like this:

//noinspection CheckResult

But it only works when running lint from the command line, but not in Android Studio.

Upvotes: 1

Related Questions