(#) Spelling error !!! WARNING: Spelling error This is a warning. Id : `Typos` Summary : Spelling error Severity : Warning Category : Correctness: Messages Platform : Android Vendor : Android Open Source Project Feedback : https://issuetracker.google.com/issues/new?component=192708 Since : Initial Affects : Resource files Editing : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/TypoDetector.kt) Tests : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java) Copyright Year : 2011 This check looks through the string definitions, and if it finds any words that look like likely misspellings, they are flagged. !!! Tip This lint check has an associated quickfix available in the IDE. (##) Example Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/strings.xml:6:Warning: "activites" is a common misspelling; did you mean "activities"? [Typos] <string name="s2">Andriod activites!</string> ^ res/values/strings.xml:8:Warning: "Cmoputer" is a common misspelling; did you mean "Computer"? [Typos] <string name="s3"> (Cmoputer </string> ^ res/values/strings.xml:10:Warning: "throught" is a common misspelling; did you mean "thought" or "through" or "throughout"? [Typos] <string name="s4"><b>throught</b></string> ^ res/values/strings.xml:12:Warning: "Seach" is a common misspelling; did you mean "Search"? [Typos] <string name="s5">Seach</string> ^ res/values/strings.xml:16:Warning: "Tuscon" is a common misspelling; did you mean "Tucson"? [Typos] <string name="s7">Tuscon tuscon</string> ^ res/values/strings.xml:20:Warning: "Ok" is usually capitalized as "OK" [Typos] <string name="dlg_button_ok">Ok</string> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `res/values/strings.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers <?xml version="1.0" encoding="utf-8"?> <resources> <!-- No typos --> <string name="s1">Home Sample</string> <!-- Plain typos --> <string name="s2">Andriod activites!</string> <!-- Make capitalization match typo --> <string name="s3"> (Cmoputer </string> <!-- Markup indirection --> <string name="s4"><b>throught</b></string> <!-- Typo, match capitalized --> <string name="s5">Seach</string> <!-- random words, shouldn't flag --> <string name="s6">abcdefg qwerty asdf jklm</string> <!-- typo, but should only match when capitalized --> <string name="s7">Tuscon tuscon</string> <!-- case changes only: valid --> <string name="s8">OK Cancel dialog with a long message</string> <!-- case changes only: invalid --> <string name="dlg_button_ok">Ok</string> <!-- escaped separator --> <string name="issue39599">"Please take a moment\nto rate ^1"</string> <!-- escaped separator 2 --> <string name="issue39599_2">"\nto</string> <!-- not translatable --> <string name="translatable" translatable="false">"Andriod</string> <!-- don't spell check resource references; not user visible anyway --> <string name="issue77269_1">@android:string/ok</string> <string name="issue77269_2"> @string/cmoputer </string> </resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java) for the unit tests for this check to see additional scenarios. The above example was automatically extracted from the first unit test found for this lint check, `TypoDetector.testPlainValues`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. (##) Suppressing You can suppress false positives using one of the following mechanisms: * Adding the suppression attribute `tools:ignore="Typos"` on the problematic XML element (or one of its enclosing elements). You may also need to add the following namespace declaration on the root element in the XML file if it's not already there: `xmlns:tools="http://schemas.android.com/tools"`. ```xml <?xml version="1.0" encoding="UTF-8"?> <resources xmlns:tools="http://schemas.android.com/tools"> ... <string tools:ignore="Typos" .../> ... </resources> ``` * Using a special `lint.xml` file in the source tree which turns off the check in that folder and any sub folder. A simple file might look like this: ```xml <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="Typos" severity="ignore" /> </lint> ``` Instead of `ignore` you can also change the severity here, for example from `error` to `warning`. You can find additional documentation on how to filter issues by path, regular expression and so on [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html). * In Gradle projects, using the DSL syntax to configure lint. For example, you can use something like ```gradle lintOptions { disable 'Typos' } ``` In Android projects this should be nested inside an `android { }` block. * For manual invocations of `lint`, using the `--ignore` flag: ``` $ lint --ignore Typos ...` ``` * Last, but not least, using baselines, as discussed [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).