Skip to content

Commit b27bfc3

Browse files
authored
Merge pull request googlesamples#42 from tnorbye/issuedocs
Add issue documentation and update documentation snapshot
2 parents 009beab + e5cbe89 commit b27bfc3

File tree

420 files changed

+65867
-61
lines changed

Some content is hidden

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

420 files changed

+65867
-61
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The lint source code contains a lot of documentation on how to write
55
custom checks; this git repository contains a snapshot of this
66
documentation which you can read here:
77

8-
* [Full API Guide](https://googlesamples.github.io/android-custom-lint-rules/book.html)
8+
* [Full API Guide](https://googlesamples.github.io/android-custom-lint-rules/api-guide.html)
99
* [Other docs](https://googlesamples.github.io/android-custom-lint-rules/index.html)
1010

1111
Lint

docs/README.md.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* Documents for users of lint, in the `usage` folder:
1818
- [Complete Book](user-guide.md.html), containing all of the below
1919
documents as chapters, suitable for offline reading
20+
- [Issue documentation](checks/index.md.html) which lists all the
21+
available checks and provides documentation for each one.
2022
- [Performance Tuning Tips](usage/performance-tuning.md.html)
2123
- [How to suppress incidents](usage/suppressing.md.html)
2224
- [How to use baselines](usage/baselines.md.html)
@@ -37,6 +39,8 @@
3739
* Documents for lint internals, intended for developers of lint
3840
itself, in the `internal` folder:
3941
- [Guidelines](internal/guidelines.md.html)
42+
- [Generating Issue Documentation](internal/document-checks.md.html)
43+
4044
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4145

4246
Documentation History:

docs/api-guide.html

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,8 +3131,8 @@
31313131
</p><p>
31323132

31333133
</p><ol start="1">
3134-
<li class="number">Local analysis which doesn't depend on anything else. For example, a
3135-
lint check which flags typos can report incidents immediately.
3134+
<li class="number">Local analysis which doesn't depend on anything else. For example,
3135+
a lint check which flags typos can report incidents immediately.
31363136
Lint calls these “definite incidents”.
31373137

31383138
<p></p><p>
@@ -4266,8 +4266,8 @@
42664266
<li class="asterisk">Bytecode verification: Instead of warning about 3rd party lint checks
42674267
being obsolete because they were not compiled against the latest Lint
42684268
API, lint now run its own bytecode verification against the lint jar
4269-
and will silently accept accept older (and newer!) lint checks if
4270-
they do not reference APIs that are not available.
4269+
and will silently accept older (and newer!) lint checks if they do
4270+
not reference APIs that are not available.
42714271

42724272
<p></p><p>
42734273

@@ -4320,8 +4320,8 @@
43204320

43214321
</p></li>
43224322
<li class="asterisk">There are additional modifier lookup methods for Kotlin modifiers
4323-
on `JavaEvaluator, like isReified(), isCompanion(), isTailRec(), and
4324-
so on.
4323+
on <code>JavaEvaluator</code>, like <code>isReified()</code>, <code>isCompanion()</code>,
4324+
<code>isTailRec()</code>, and so on.
43254325

43264326
<p></p><p>
43274327

@@ -4331,19 +4331,19 @@
43314331
<p></p><p>
43324332

43334333
</p></li>
4334-
<li class="asterisk">Certain Kotlin PSI elements have new implementations known as
4335-
<em class="underscore">ultra light classes</em>. Ultra light classes improve performance
4336-
by answering PSI queries “directly from source” rather than
4337-
delegating to the Kotlin compiler backend. You may see ultra
4338-
light classes when accessing the <code>UElement.javaPsi</code> property of a
4339-
Kotlin UAST element. They can also appear when resolving references.
4340-
For example, resolving a Kotlin field reference to its declaration
4341-
may result in an instance of <code>KtUltraLightFieldForSourceDeclaration</code>.
4342-
As a reminder, Kotlin light classes represent the “Java view” of an
4334+
<li class="asterisk">Certain Kotlin PSI elements have new implementations known as <em class="underscore">ultra
4335+
light classes</em>. Ultra light classes improve performance by answering
4336+
PSI queries “directly from source” rather than delegating to the
4337+
Kotlin compiler backend. You may see ultra light classes when
4338+
accessing the <code>UElement.javaPsi</code> property of a Kotlin UAST element.
4339+
They can also appear when resolving references. For example,
4340+
resolving a Kotlin field reference to its declaration may result in
4341+
an instance of <code>KtUltraLightFieldForSourceDeclaration</code>. As a
4342+
reminder, Kotlin light classes represent the “Java view” of an
43434343
underlying Kotlin PSI element. To access the underlying Kotlin PSI
4344-
element you should use <code>UElement.sourcePsi</code> (preferred)
4345-
or otherwise the extension property <code>PsiElement.unwrapped</code> (declared
4346-
in <code>org.jetbrains.kotlin.asJava</code>).
4344+
element you should use <code>UElement.sourcePsi</code> (preferred) or otherwise
4345+
the extension property <code>PsiElement.unwrapped</code> (declared in
4346+
<code>org.jetbrains.kotlin.asJava</code>).
43474347

43484348
<p></p><p>
43494349

@@ -4358,7 +4358,19 @@
43584358
</p></li>
43594359
<li class="asterisk">Kotlin references to Java methods now trigger both the
43604360
<code>visitMethodCall()</code> callback <em class="underscore">and</em> the <code>visitReference()</code> callback.
4361-
Previously only <code>visitMethodCall()</code> was triggered.</li></ul>
4361+
Previously only <code>visitMethodCall()</code> was triggered.
4362+
4363+
<p></p><p>
4364+
4365+
</p></li>
4366+
<li class="asterisk">Quickfixes can now create and delete new files; see
4367+
<code>LintFix#newFile</code> and <code>LintFix#deleteFile</code>..
4368+
4369+
<p></p><p>
4370+
4371+
</p></li>
4372+
<li class="asterisk">For quickfixes, the <code>independent</code> property had inverted logic;
4373+
this has now been reversed to follow the meaning of the name.</li></ul>
43624374

43634375
<p></p>
43644376
<a class="target" name="appendix:environmentvariablesandsystemproperties">&nbsp;</a><a class="target" name="appendix:environmentvariablesandsystemproperties">&nbsp;</a><a class="target" name="toc10">&nbsp;</a><h1>Appendix: Environment Variables and System Properties</h1>
@@ -4515,5 +4527,8 @@
45154527

45164528
</p></dd></td></tr><tr valign="top"><td><dt><code>lint.do.not.reuse.uast.env</code></dt></td><td><dd><p> Alias for <code>$LINT_DO_NOT_REUSE_UAST_ENV</code>
45174529

4530+
</p></dd></td></tr><tr valign="top"><td><dt><code>android.lint.log-jar-problems</code></dt></td><td><dd><p> Controls whether lint will complain about custom check lint jar
4531+
loading problems. By default, true.
4532+
45184533
</p></dd></td></tr></tbody></table></dl><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility=&ldquo;visible&rdquo;)</script>
45194534
<p></p></span><div id="mdContextMenu" style="visibility:hidden"></div><div class="markdeepFooter"><i>formatted by <a href="https://casual-effects.com/markdeep" style="color:#999">Markdeep&nbsp;1.13&nbsp;&nbsp;</a></i><div style="display:inline-block;font-size:13px;font-family:'Times New Roman',serif;vertical-align:middle;transform:translate(-3px,-1px)rotate(135deg);"></div></div></body></html>

docs/api-guide/changes.md.html

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* Bytecode verification: Instead of warning about 3rd party lint checks
3232
being obsolete because they were not compiled against the latest Lint
3333
API, lint now run its own bytecode verification against the lint jar
34-
and will silently accept older (and newer!) lint checks if
35-
they do not reference APIs that are not available.
34+
and will silently accept older (and newer!) lint checks if they do
35+
not reference APIs that are not available.
3636

3737
* Android Lint checks can now always access the resource repository for
3838
random access to resources, instead of having to gather them in batch
@@ -67,24 +67,24 @@
6767
warnings or errors.
6868

6969
* There are additional modifier lookup methods for Kotlin modifiers
70-
on `JavaEvaluator, like isReified(), isCompanion(), isTailRec(), and
71-
so on.
70+
on `JavaEvaluator`, like `isReified()`, `isCompanion()`,
71+
`isTailRec()`, and so on.
7272

7373
* API documentation is now available.
7474

75-
* Certain Kotlin PSI elements have new implementations known as
76-
_ultra light classes_. Ultra light classes improve performance
77-
by answering PSI queries "directly from source" rather than
78-
delegating to the Kotlin compiler backend. You may see ultra
79-
light classes when accessing the `UElement.javaPsi` property of a
80-
Kotlin UAST element. They can also appear when resolving references.
81-
For example, resolving a Kotlin field reference to its declaration
82-
may result in an instance of `KtUltraLightFieldForSourceDeclaration`.
83-
As a reminder, Kotlin light classes represent the "Java view" of an
75+
* Certain Kotlin PSI elements have new implementations known as _ultra
76+
light classes_. Ultra light classes improve performance by answering
77+
PSI queries directly from source rather than delegating to the
78+
Kotlin compiler backend. You may see ultra light classes when
79+
accessing the `UElement.javaPsi` property of a Kotlin UAST element.
80+
They can also appear when resolving references. For example,
81+
resolving a Kotlin field reference to its declaration may result in
82+
an instance of `KtUltraLightFieldForSourceDeclaration`. As a
83+
reminder, Kotlin light classes represent the Java view of an
8484
underlying Kotlin PSI element. To access the underlying Kotlin PSI
85-
element you should use `UElement.sourcePsi` (preferred)
86-
or otherwise the extension property `PsiElement.unwrapped` (declared
87-
in `org.jetbrains.kotlin.asJava`).
85+
element you should use `UElement.sourcePsi` (preferred) or otherwise
86+
the extension property `PsiElement.unwrapped` (declared in
87+
`org.jetbrains.kotlin.asJava`).
8888

8989
* There is a new bug where calling `getNameIdentifier()` on Kotlin
9090
fields may return `null`
@@ -95,4 +95,10 @@
9595
`visitMethodCall()` callback _and_ the `visitReference()` callback.
9696
Previously only `visitMethodCall()` was triggered.
9797

98+
* Quickfixes can now create and delete new files; see
99+
`LintFix#newFile` and `LintFix#deleteFile`..
100+
101+
* For quickfixes, the `independent` property had inverted logic;
102+
this has now been reversed to follow the meaning of the name.
103+
98104
<!-- 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/partial-analysis.md.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
Detectors fit into one of the following categories (and these
6969
categories will be explained in subsequent sessions) :
7070

71-
1. Local analysis which doesn't depend on anything else. For example, a
72-
lint check which flags typos can report incidents immediately. Lint
73-
calls these “definite incidents”.
71+
1. Local analysis which doesn't depend on anything else. For example,
72+
a lint check which flags typos can report incidents immediately.
73+
Lint calls these “definite incidents”.
7474

7575
2. Local analysis which depends on a few, common conditions. For
7676
example, in Android, a check may only apply if the `minSdkVersion <

docs/book.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@
3737
</p><p>
3838

3939
</p><ol start="1">
40-
<li class="number"><a href="user-guide.html">User Guide</a> which documents how to
41-
use, configure and tune lint.
40+
<li class="number"><a href="user-guide.html">User Guide</a> which documents how to use,
41+
configure and tune lint.
4242

4343
<p></p><p>
4444

4545
</p></li>
46-
<li class="number"><a href="api-guide.html">API Guide</a> which documents how to
47-
write your own lint checks.</li></ol>
46+
<li class="number"><a href="api-guide.html">API Guide</a> which documents how to write your
47+
own lint checks.
48+
49+
<p></p><p>
50+
51+
</p></li>
52+
<li class="number"><a href="checks/index.md.html">Issue documentation</a> which lists all the
53+
available checks and provides documentation for each one.</li></ol>
4854

4955
<p></p><p>
5056

docs/book.md.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
There are two books:
66

7-
1. [User Guide](user-guide.md.html) which documents how to
8-
use, configure and tune lint.
7+
1. [User Guide](user-guide.md.html) which documents how to use,
8+
configure and tune lint.
99

10-
2. [API Guide](api-guide.md.html) which documents how to
11-
write your own lint checks.
10+
2. [API Guide](api-guide.md.html) which documents how to write your
11+
own lint checks.
12+
13+
3. [Issue documentation](checks/index.md.html) which lists all the
14+
available checks and provides documentation for each one.
1215

1316
<!-- 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/checks/AaptCrash.md.html

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<meta charset="utf-8">
2+
(#) Potential AAPT crash
3+
4+
!!! ERROR: Potential AAPT crash
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+
: `AaptCrash`
11+
Summary
12+
: Potential AAPT crash
13+
Severity
14+
: Fatal
15+
Category
16+
: Correctness
17+
Platform
18+
: Android
19+
Vendor
20+
: Android Open Source Project
21+
Affects
22+
: Resource files
23+
Editing
24+
: This check runs on the fly in the IDE editor
25+
Implementation
26+
: [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-master-dev:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ResourceCycleDetector.kt)
27+
Tests
28+
: [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-master-dev:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ResourceCycleDetectorTest.java)
29+
30+
Defining a style which sets `android:id` to a dynamically generated id
31+
can cause many versions of `aapt`, the resource packaging tool, to
32+
crash. To work around this, declare the id explicitly with `<item
33+
type="id" name="..." />` instead.
34+
35+
(##) Example
36+
37+
Here is an example of lint warnings produced by this check:
38+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
39+
res/values/aaptcrash.xml:5:Error: This construct can potentially crash
40+
aapt during a build. Change @+id/titlebar to @id/titlebar and define the
41+
id explicitly using <item type="id" name="titlebar"/> instead.
42+
[AaptCrash]
43+
44+
&lt;item name="android:id"&gt;@+id/titlebar&lt;/item&gt;
45+
--------------------------------------------
46+
47+
48+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49+
50+
Here is the source file referenced above:
51+
52+
`res/values/aaptcrash.xml`:
53+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
54+
&lt;?xml version="1.0" encoding="utf-8"?&gt;
55+
&lt;resources xmlns:android="http://schemas.android.com/apk/res/android"&gt;
56+
&lt;style name="TitleBar"&gt;
57+
&lt;item name="android:orientation"&gt;horizontal&lt;/item&gt;
58+
&lt;item name="android:id"&gt;@+id/titlebar&lt;/item&gt;
59+
&lt;item name="android:background"&gt;@drawable/bg_titlebar&lt;/item&gt;
60+
&lt;item name="android:layout_width"&gt;fill_parent&lt;/item&gt;
61+
&lt;item name="android:layout_height"&gt;@dimen/titlebar_height&lt;/item&gt;
62+
&lt;/style&gt;
63+
&lt;/resources&gt;
64+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65+
66+
You can also visit the
67+
[source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-master-dev:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ResourceCycleDetectorTest.java)
68+
for the unit tests for this check to see additional scenarios.
69+
70+
The above example was automatically extracted from the first unit test
71+
found for this lint check, `ResourceCycleDetector.testAaptCrash`.
72+
To report a problem with this extracted sample, visit
73+
https://issuetracker.google.com/issues/new?component=192708.
74+
75+
(##) Suppressing
76+
77+
You can suppress false positives using one of the following mechanisms:
78+
79+
* Adding the suppression attribute `tools:ignore="AaptCrash"` on the
80+
problematic XML element (or one of its enclosing elements). You may
81+
also need to add the following namespace declaration on the root
82+
element in the XML file if it's not already there:
83+
`xmlns:tools="http://schemas.android.com/tools"`
84+
85+
* Using a special `lint.xml` file in the source tree which turns off
86+
the check in that folder and any sub folder. A simple file might look
87+
like this:
88+
```xml
89+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
90+
&lt;lint&gt;
91+
&lt;issue id="AaptCrash" severity="ignore" /&gt;
92+
&lt;/lint&gt;
93+
```
94+
Instead of `ignore` you can also change the severity here, for
95+
example from `error` to `warning`. You can find additional
96+
documentation on how to filter issues by path, regular expression and
97+
so on
98+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
99+
100+
* In Gradle projects, using the DSL syntax to configure lint. For
101+
example, you can use something like
102+
```gradle
103+
lintOptions {
104+
disable 'AaptCrash'
105+
}
106+
```
107+
In Android projects this should be nested inside an `android { }`
108+
block.
109+
110+
* For manual invocations of `lint`, using the `--ignore` flag:
111+
```
112+
$ lint --ignore AaptCrash ...`
113+
```
114+
115+
* Last, but not least, using baselines, as discussed
116+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
117+
118+
<!-- 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)