Skip to content

Commit fdcdd99

Browse files
committed
Updated issue documentation to include sorting and AndroidX
1 parent b27bfc3 commit fdcdd99

File tree

83 files changed

+10205
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+10205
-275
lines changed

docs/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ Let's go there right now: [Link](README.md.html)
1010

1111
There is also a pre-rendered HTML version of the API Guide
1212
[here](book.html) suitable for online hosting.
13+
14+
Finally, a (usually recent) snapshot of these docs are hosted
15+
[here](http://googlesamples.github.io/android-custom-lint-rules/).

docs/README.md.html

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4545

4646
Documentation History:
47+
* May 2021: Adding documentation for individual lint issues
4748
* March 2021: Initial version
4849

4950
<!-- 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>

docs/api-guide.html

+27-5
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@
127127
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//howdoilookupifaclassisasubclassofanother?" class="level3"><span class="tocNumber">8.0.13&nbsp; </span>How do I look up if a class is a subclass of another?</a><br>
128128
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//howdoiknowwhichparameteracallargumentcorrespondsto?" class="level3"><span class="tocNumber">8.0.14&nbsp; </span>How do I know which parameter a call argument corresponds to?</a><br>
129129
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//howcanmylintcheckstargettwodifferentversionsoflint?" class="level3"><span class="tocNumber">8.0.15&nbsp; </span>How can my lint checks target two different versions of lint?</a><br>
130-
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//howdoicheckoutthecurrentlintsourcecode?" class="level3"><span class="tocNumber">8.0.16&nbsp; </span>How do I check out the current lint source code?</a><br>
131-
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//wheredoifindexamplesoflintchecks?" class="level3"><span class="tocNumber">8.0.17&nbsp; </span>Where do I find examples of lint checks?</a><br>
130+
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//canimakemylintcheck%E2%80%9Cnotsuppressible?%E2%80%9D" class="level3"><span class="tocNumber">8.0.16&nbsp; </span>Can I make my lint check “not suppressible?”</a><br>
131+
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//howdoicheckoutthecurrentlintsourcecode?" class="level3"><span class="tocNumber">8.0.17&nbsp; </span>How do I check out the current lint source code?</a><br>
132+
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#frequentlyaskedquestions//wheredoifindexamplesoflintchecks?" class="level3"><span class="tocNumber">8.0.18&nbsp; </span>Where do I find examples of lint checks?</a><br>
132133
<a href="#appendix:recentchanges" class="level1"><span class="tocNumber">9&nbsp; </span>Appendix: Recent Changes</a><br>
133134
<a href="#appendix:environmentvariablesandsystemproperties" class="level1"><span class="tocNumber">10&nbsp; </span>Appendix: Environment Variables and System Properties</a><br>
134135
&nbsp;&nbsp;<a href="#appendix:environmentvariablesandsystemproperties/environmentvariables" class="level2"><span class="tocNumber">10.1&nbsp; </span>Environment Variables</a><br>
@@ -3332,7 +3333,7 @@
33323333
This means that instead, you need to aggregate data along the way.
33333334
For example, the way lint handles the version check method lookup is
33343335
to look for SDK_INT comparisons, and if found, stores a reference to
3335-
the method in ther partial results map which it can later consult
3336+
the method in the partial results map which it can later consult
33363337
from downstream modules.
33373338

33383339
</p><p>
@@ -4175,7 +4176,23 @@
41754176
outside of the current API level.
41764177

41774178
</p>
4178-
<a class="target" name="howdoicheckoutthecurrentlintsourcecode?">&nbsp;</a><a class="target" name="frequentlyaskedquestions//howdoicheckoutthecurrentlintsourcecode?">&nbsp;</a><a class="target" name="toc8.0.16">&nbsp;</a><h3>How do I check out the current lint source code?</h3>
4179+
<a class="target" name="canimakemylintcheck%E2%80%9Cnotsuppressible?%E2%80%9D">&nbsp;</a><a class="target" name="frequentlyaskedquestions//canimakemylintcheck%E2%80%9Cnotsuppressible?%E2%80%9D">&nbsp;</a><a class="target" name="toc8.0.16">&nbsp;</a><h3>Can I make my lint check “not suppressible?”</h3>
4180+
<p>
4181+
4182+
4183+
In some (hopefully rare) cases, you may want your lint checks to not be
4184+
suppressible using the normal mechanisms — suppress annotations,
4185+
comments, lint.xml files, baselines, and so on. The usecase for this is
4186+
typically strict company guidelines around compliance or security and
4187+
you want to remove the easy possibility of just silencing the check.
4188+
4189+
</p><p>
4190+
4191+
This is possible as part of the issue registration. After creating your
4192+
<code>Issue</code>, set the <code>suppressNames</code> property to an <strong class="asterisk">empty</strong> collection.
4193+
4194+
</p>
4195+
<a class="target" name="howdoicheckoutthecurrentlintsourcecode?">&nbsp;</a><a class="target" name="frequentlyaskedquestions//howdoicheckoutthecurrentlintsourcecode?">&nbsp;</a><a class="target" name="toc8.0.17">&nbsp;</a><h3>How do I check out the current lint source code?</h3>
41794196
<pre class="listing backtick"><code><span class="line"><span class="hljs-meta">$</span><span class="bash"> git <span class="hljs-built_in">clone</span> --branch=mirror-goog-studio-master-dev --single-branch \</span>
41804197
<span class="line"> https://android.googlesource.com/platform/tools/base</span></span>
41814198
<span class="line">Cloning into 'base'...</span>
@@ -4192,7 +4209,7 @@
41924209
<span class="line">.gitignore MODULE_LICENSE_APACHE2 cli/</span>
41934210
<span class="line"><span class="hljs-meta">$</span><span class="bash"> ls libs/</span></span>
41944211
<span class="line">intellij-core/ kotlin-compiler/ lint-api/ lint-checks/ lint-gradle/ lint-model/ lint-tests/ uast/</span></code></pre>
4195-
<a class="target" name="wheredoifindexamplesoflintchecks?">&nbsp;</a><a class="target" name="frequentlyaskedquestions//wheredoifindexamplesoflintchecks?">&nbsp;</a><a class="target" name="toc8.0.17">&nbsp;</a><h3>Where do I find examples of lint checks?</h3>
4212+
<a class="target" name="wheredoifindexamplesoflintchecks?">&nbsp;</a><a class="target" name="frequentlyaskedquestions//wheredoifindexamplesoflintchecks?">&nbsp;</a><a class="target" name="toc8.0.18">&nbsp;</a><h3>Where do I find examples of lint checks?</h3>
41964213
<p>
41974214

41984215

@@ -4330,6 +4347,11 @@
43304347

43314348
<p></p><p>
43324349

4350+
</p></li>
4351+
<li class="asterisk">UAST for Kotlin is now based on Kotlin 1.5.
4352+
4353+
<p></p><p>
4354+
43334355
</p></li>
43344356
<li class="asterisk">Certain Kotlin PSI elements have new implementations known as <em class="underscore">ultra
43354357
light classes</em>. Ultra light classes improve performance by answering

docs/api-guide/changes.md.html

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272

7373
* API documentation is now available.
7474

75+
* UAST for Kotlin is now based on Kotlin 1.5.
76+
7577
* Certain Kotlin PSI elements have new implementations known as _ultra
7678
light classes_. Ultra light classes improve performance by answering
7779
PSI queries “directly from source” rather than delegating to the

docs/api-guide/faq.md.html

+11
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@
276276
lint loads the issue registries it will ignore registries with a range
277277
outside of the current API level.
278278

279+
### Can I make my lint check “not suppressible?”
280+
281+
In some (hopefully rare) cases, you may want your lint checks to not be
282+
suppressible using the normal mechanisms -- suppress annotations,
283+
comments, lint.xml files, baselines, and so on. The usecase for this is
284+
typically strict company guidelines around compliance or security and
285+
you want to remove the easy possibility of just silencing the check.
286+
287+
This is possible as part of the issue registration. After creating your
288+
`Issue`, set the `suppressNames` property to an **empty** collection.
289+
279290
### How do I check out the current lint source code?
280291

281292
```shell

docs/api-guide/partial-analysis.md.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
This means that instead, you need to aggregate data along the way.
218218
For example, the way lint handles the version check method lookup is
219219
to look for SDK_INT comparisons, and if found, stores a reference to
220-
the method in ther partial results map which it can later consult
220+
the method in the partial results map which it can later consult
221221
from downstream modules.
222222

223223
* Multiple passes across the modules (lint has a way to request

docs/checks/AnnotateVersionCheck.md.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
}
225225

226226
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N)
227-
fun isNougat3(): Boolean { // Should NOT annotate (already annotateD)
227+
fun isNougat3(): Boolean { // Should NOT annotate (already annotated)
228228
return VERSION.SDK_INT >= VERSION_CODES.N
229229
}
230230

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<meta charset="utf-8">
22
(#) AppLinksAutoVerifyError
33

4-
The issue for this id has been deleted or marked obsolete and can now be
5-
ignored.
4+
This issue id is an alias for
5+
[AppLinksAutoVerify](AppLinksAutoVerify.md.html).
66

77
(Additional metadata not available.)<!-- 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>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<meta charset="utf-8">
22
(#) AppLinksAutoVerifyWarning
33

4-
The issue for this id has been deleted or marked obsolete and can now be
5-
ignored.
4+
This issue id is an alias for
5+
[AppLinksAutoVerify](AppLinksAutoVerify.md.html).
66

77
(Additional metadata not available.)<!-- 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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<meta charset="utf-8">
2+
(#) Invalid WorkManager Configuration Provider
3+
4+
!!! ERROR: Invalid WorkManager Configuration Provider
5+
This is an error, and is also enforced at build time when
6+
supported by the build system. For Android this means it will
7+
run during release builds.
8+
9+
Id
10+
: `BadConfigurationProvider`
11+
Summary
12+
: Invalid WorkManager Configuration Provider
13+
Severity
14+
: Fatal
15+
Category
16+
: Correctness
17+
Platform
18+
: Android
19+
Vendor
20+
: Android Open Source Project (androidx.work.lint.workmanager)
21+
Affects
22+
: Kotlin and Java files
23+
Editing
24+
: This check runs on the fly in the IDE editor
25+
Implementation
26+
: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/workmanager-lint/src/main/java/androidx/work/lint/BadConfigurationProviderIssueDetector.kt)
27+
28+
An `android.app.Application` must implement
29+
`androidx.work.Configuration.Provider`
30+
for on-demand initialization.
31+
32+
(##) Suppressing
33+
34+
You can suppress false positives using one of the following mechanisms:
35+
36+
* Using a suppression annotation like this on the enclosing
37+
element:
38+
39+
```kt
40+
// Kotlin
41+
@Suppress("BadConfigurationProvider")
42+
fun method() {
43+
problematicStatement()
44+
}
45+
```
46+
47+
or
48+
49+
```java
50+
// Java
51+
@SuppressWarnings("BadConfigurationProvider")
52+
void method() {
53+
problematicStatement();
54+
}
55+
```
56+
57+
* Using a suppression comment like this on the line above:
58+
59+
```kt
60+
//noinspection BadConfigurationProvider
61+
problematicStatement()
62+
```
63+
64+
* Using a special `lint.xml` file in the source tree which turns off
65+
the check in that folder and any sub folder. A simple file might look
66+
like this:
67+
```xml
68+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
69+
&lt;lint&gt;
70+
&lt;issue id="BadConfigurationProvider" severity="ignore" /&gt;
71+
&lt;/lint&gt;
72+
```
73+
Instead of `ignore` you can also change the severity here, for
74+
example from `error` to `warning`. You can find additional
75+
documentation on how to filter issues by path, regular expression and
76+
so on
77+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
78+
79+
* In Gradle projects, using the DSL syntax to configure lint. For
80+
example, you can use something like
81+
```gradle
82+
lintOptions {
83+
disable 'BadConfigurationProvider'
84+
}
85+
```
86+
In Android projects this should be nested inside an `android { }`
87+
block.
88+
89+
* For manual invocations of `lint`, using the `--ignore` flag:
90+
```
91+
$ lint --ignore BadConfigurationProvider ...`
92+
```
93+
94+
* Last, but not least, using baselines, as discussed
95+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
96+
97+
<!-- 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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<meta charset="utf-8">
2+
(#) Use `enqueueUniquePeriodicWork()` instead of `enqueue()`
3+
4+
!!! WARNING: Use `enqueueUniquePeriodicWork()` instead of `enqueue()`
5+
This is a warning.
6+
7+
Id
8+
: `BadPeriodicWorkRequestEnqueue`
9+
Summary
10+
: Use `enqueueUniquePeriodicWork()` instead of `enqueue()`
11+
Severity
12+
: Warning
13+
Category
14+
: Correctness
15+
Platform
16+
: Android
17+
Vendor
18+
: Android Open Source Project (androidx.work.lint.workmanager)
19+
Affects
20+
: Kotlin and Java files
21+
Editing
22+
: This check runs on the fly in the IDE editor
23+
Implementation
24+
: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/workmanager-lint/src/main/java/androidx/work/lint/PeriodicEnqueueIssueDetector.kt)
25+
Tests
26+
: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/workmanager-lint/src/test/java/androidx/work/lint/PeriodicEnqueueIssueDetectorTest.kt)
27+
28+
When using `enqueue()` for `PeriodicWorkRequest`s, you might end up
29+
enqueuing
30+
duplicate requests unintentionally. You should be using
31+
`enqueueUniquePeriodicWork` with an `ExistingPeriodicWorkPolicy.KEEP`
32+
instead.
33+
34+
(##) Suppressing
35+
36+
You can suppress false positives using one of the following mechanisms:
37+
38+
* Using a suppression annotation like this on the enclosing
39+
element:
40+
41+
```kt
42+
// Kotlin
43+
@Suppress("BadPeriodicWorkRequestEnqueue")
44+
fun method() {
45+
problematicStatement()
46+
}
47+
```
48+
49+
or
50+
51+
```java
52+
// Java
53+
@SuppressWarnings("BadPeriodicWorkRequestEnqueue")
54+
void method() {
55+
problematicStatement();
56+
}
57+
```
58+
59+
* Using a suppression comment like this on the line above:
60+
61+
```kt
62+
//noinspection BadPeriodicWorkRequestEnqueue
63+
problematicStatement()
64+
```
65+
66+
* Using a special `lint.xml` file in the source tree which turns off
67+
the check in that folder and any sub folder. A simple file might look
68+
like this:
69+
```xml
70+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
71+
&lt;lint&gt;
72+
&lt;issue id="BadPeriodicWorkRequestEnqueue" severity="ignore" /&gt;
73+
&lt;/lint&gt;
74+
```
75+
Instead of `ignore` you can also change the severity here, for
76+
example from `error` to `warning`. You can find additional
77+
documentation on how to filter issues by path, regular expression and
78+
so on
79+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
80+
81+
* In Gradle projects, using the DSL syntax to configure lint. For
82+
example, you can use something like
83+
```gradle
84+
lintOptions {
85+
disable 'BadPeriodicWorkRequestEnqueue'
86+
}
87+
```
88+
In Android projects this should be nested inside an `android { }`
89+
block.
90+
91+
* For manual invocations of `lint`, using the `--ignore` flag:
92+
```
93+
$ lint --ignore BadPeriodicWorkRequestEnqueue ...`
94+
```
95+
96+
* Last, but not least, using baselines, as discussed
97+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
98+
99+
<!-- 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>

0 commit comments

Comments
 (0)