11

Android Lint picks up the string constant in this code sample as a spelling error on "dWQGSCDx". According to the docs I should use @SupressLint("Typos") to suppress it but that doesn't achieve that. I see others have suggested using @SuppressWarnings but that is not working either.

/**
 * Constants.kt
 */

import android.annotation.SuppressLint

@SuppressLint("Typos")
@SuppressWarnings("SpellCheckingInspection")    
const val SOME_STRING_VALUE = "...dWQGSCDx..."

Note this is a file-scoped global constant, it is not inside a class so an annotation cannot be placed on a containing class.

How do I suppress spell-checking of this constant definition without disabling spellcheck entirely and without adding the "mispelt" text to the dictionary?

Ollie C
  • 28,313
  • 34
  • 134
  • 217
  • I am struggling for the same thing, probably it is a bug in Kotlin or the IDE itself. – Enzokie Dec 11 '17 at 08:23
  • Have you tried adding this word to IDE's dictionary? it should be in the suggestion list to fix it – elmorabea Dec 11 '17 at 09:03
  • @elmorabea As I said in the question, I need a solution that does NOT involve putting the text in the dictionary. – Ollie C Dec 11 '17 at 11:42
  • 3
    This appears to be Kotlin-specific. The @SuppressWarnings("SpellCheckingInspection") annotation does suppress the spelling warning, but only in Java and not Kotlin. I've reported it as a bug. https://issuetracker.google.com/issues/70615542 Please star the bug if you see the same issue. – Ollie C Dec 13 '17 at 15:22
  • Ollie - This doesn't work in latest IntelliJ with raw Kotlin (no Android). Also, @elmorabea if you have stuff in your tests (like testing Base64 encoded values), then you don't want to add each encoded string to the dictionary, I'm guessing that's the case with OP too. – milosmns Apr 08 '18 at 20:51

1 Answers1

15

In Kotlin you can suppress this warning using @Suppress instead of @SuppressWarnings with the following annotation

@Suppress("SpellCheckingInspection")
Borja Quevedo
  • 354
  • 2
  • 7
  • That works, but I have to repeat this line before every Class, that is annoying, is there a way to suppress spell checking globally for a whole project? – gundrabur Sep 25 '19 at 20:51
  • 1
    You can disable spellchecking in Android Studio or IntelliJ in `Preferences` - `Editor` - `Inspections` – Borja Quevedo Oct 09 '19 at 18:18