| You can suppress false positives using one of the following mechanisms: |
| |
| * Using a suppression annotation like this on the enclosing |
| element: |
| |
| ```kt |
| // Kotlin |
| @Suppress("$id") |
| fun method() { |
| problematicStatement() |
| } |
| ``` |
| |
| or |
| |
| ```java |
| // Java |
| @SuppressWarnings("$id") |
| void method() { |
| problematicStatement(); |
| } |
| ``` |
| |
| * Using a suppression comment like this on the line above: |
| |
| ```kt |
| //noinspection $id |
| problematicStatement() |
| ``` |
| |
| * Adding the suppression annotation `@Suppress("SdCardPath")` |
| (in Kotlin) or `@SuppressWarnings("SdCardPath")` (in Java) on the |
| enclosing element. |
| |
| * Adding the suppression comment `//noinspection SdCardPath` on the |
| line above the problematic statement. |
| |
| * Adding the suppression attribute `tools:ignore="MissingClass"` 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 |
| <root xmlns:tools="http://schemas.android.com/tools"> |
| ... |
| <example attribute="problem" tools:ignore> |
| </root> |
| ``` |
| |
| // TODO: Check the detector resource type to figure out how |
| // to make an example! |
| |
| // Manifest example |
| ```xml |
| <manifest ... |
| xmlns:tools="http://schemas.android.com/tools" |
| ...> |
| <application ... tools:ignore="$id"> |
| </application> |
| ... |
| ``` |
| where application is $tag |
| |
| // Value resource example |
| ``` |
| <resources ... |
| xmlns:tools="http://schemas.android.com/tools" |
| ...> |
| <string name="something" ... tools:ignore="$id">Something</string> |
| ... |
| |
| * 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=“MissingClass” 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 'MissingClass' |
| } |
| ``` |
| In Android projects this should be nested inside an `android { }` |
| block. |
| |
| * For manual invocations of `lint`, using the `--ignore` flag: |
| ``` |
| $ lint --ignore MissingClass ...` |
| ``` |
| |
| * Last, but not least, using baselines, as discussed |
| [here](https://googlesamples.github.io/android-custom-lint-rules/usage |
| /baselines.md.html). |
| |
| <!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script> |