Skip to content

Commit 9e7779e

Browse files
authored
Merge pull request #87 from googlesamples/update
Update lint documentation snapshot
2 parents ed5fc41 + e0ad65f commit 9e7779e

File tree

365 files changed

+10783
-4432
lines changed

Some content is hidden

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

365 files changed

+10783
-4432
lines changed

docs/api-guide.html

+470-97
Large diffs are not rendered by default.

docs/api-guide/basics.md.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@
432432
This is a \`code symbol\` | This is a `code symbol`
433433
This is `*italics*` | This is *italics*
434434
This is `**bold**` | This is **bold**
435+
This is `~~strikethrough~~` | This is ~~strikethrough~~
435436
http://, https:// | [](http://), [](https://)
436437
`\*not italics*` | `\*not italics*`
437438
\`\`\`language\n text\n\`\`\`| (preformatted text block)
@@ -787,7 +788,7 @@
787788
val incident = Incident(context, ISSUE)
788789
.message( "Use `<vector>` instead of `<bitmap>`")
789790
.at(element)
790-
context.report(incident))
791+
context.report(incident)
791792
}
792793
}
793794
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -894,7 +895,7 @@
894895
Line 1 says we want to have line 3 called whenever lint comes across a
895896
method to `setRepeating`.
896897

897-
On lines 8-4 we make sure we're talking about the correct method on the
898+
On lines 8-14 we make sure we're talking about the correct method on the
898899
correct class with the correct signature. This uses the `JavaEvaluator`
899900
to check that the called method is a member of the named class. This is
900901
necessary because the callback would also be invoked if lint came
@@ -1067,7 +1068,7 @@
10671068
wrappers yourself, via `UBinaryExpression.asCall()`,
10681069
`UUnaryExpression.asCall()`, and `UArrayAccessExpression.asCall()`.
10691070

1070-
There is also a visitor you can use to visit call calls --
1071+
There is also a visitor you can use to visit all calls --
10711072
`UastCallVisitor`, which will visit all calls, including those from
10721073
array accesses and unary operators and binary operators.
10731074

docs/api-guide/changes.md.html

+43
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,49 @@
55
information about user visible changes to lint, see the User
66
Guide.
77

8+
**8.4**
9+
10+
* You can now use `~~` in text messages (error messages, issue
11+
explanations, etc) to create strikethrough text. For example, “`Don't
12+
do this: ~~super.onCreate()~~`” will render as “Don't do this:
13+
~~super.onCreate()~~”.
14+
15+
**8.3**
16+
17+
* If you'd like to change your error message reported by your
18+
detector, you can now override your `Detector`'s `sameMessage`
19+
method: match the details in the previous error message with the
20+
new format. This is used by the baseline mechanism such that your
21+
message change doesn't suddenly invalidate all existing baseline
22+
files for your issue.
23+
24+
* The replace-string quickfix descriptor now lets you replace a string
25+
repeatedly. Example:
26+
```
27+
fix().replace().text("Foo").with("Bar").repeatedly().build()
28+
```
29+
30+
You can also match an element optionally. Example:
31+
```
32+
fix().composite(
33+
fix().replace().text("<Tag>").with("<tag>").build(),
34+
fix().replace().text("</Tag>").with("</tag>").optional().build()
35+
)
36+
```
37+
38+
* The quickfix machinery was improved significantly. It now does a
39+
better job inserting imports (in alphabetical order instead of always
40+
prepending to the import list), inserting new XML attributes in the
41+
right canonical Android order, cleaning up whitespace after edits,
42+
etc. This may result in some diffs in any quickfix-related unit tests
43+
(e.g. `lint().run().expectFixDiffs(...)`)
44+
45+
* The `getFileNameWithParent` utility method now always uses / as
46+
a file separator instead of the platform-specific one (e.g. \ on
47+
Windows). This ensures that baselines don't vary their error
48+
messages (where this utility method is typically used) based on
49+
which OS they were generated on.
50+
851
**8.2**
952

1053
* For unit tests, you can now specify the language level to be used

docs/api-guide/messages.md.html

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
This is a \`code symbol\` | This is a `code symbol`
3030
This is `*italics*` | This is *italics*
3131
This is `**bold**` | This is **bold**
32+
This is `~~strikethrough~~` | This is ~~strikethrough~~
3233
http://, https:// | [](http://), [](https://)
3334
`\*not italics*` | `\*not italics*`
3435
\`\`\`language\n text\n\`\`\`| (preformatted text block)

docs/api-guide/publishing.md.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
### lintPublish Configuration
5353

5454
The Android Gradle library plugin provides some special configurations,
55-
`lintConfig` and `lintPublish`.
55+
`lintChecks` and `lintPublish`.
5656

5757
The `lintPublish` configuration lets you reference another project, and
5858
it will take that project's output jar and package it as a `lint.jar`
@@ -94,7 +94,7 @@
9494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9595
apply plugin: 'com.android.application'
9696
dependencies {
97-
lintConfig project(':checks')
97+
lintChecks project(':checks')
9898
// other dependencies
9999
}
100100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/book.html

+2-2
Large diffs are not rendered by default.

docs/checks/ActivityIconColor.md.html

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<meta charset="utf-8">
2+
(#) Ongoing activity icon is not white
3+
4+
!!! WARNING: Ongoing activity icon is not white
5+
This is a warning.
6+
7+
Id
8+
: `ActivityIconColor`
9+
Summary
10+
: Ongoing activity icon is not white
11+
Severity
12+
: Warning
13+
Category
14+
: Usability: Icons
15+
Platform
16+
: Android
17+
Vendor
18+
: Android Open Source Project
19+
Feedback
20+
: https://issuetracker.google.com/issues/new?component=192708
21+
Affects
22+
: Kotlin and Java files, binary resource files and resource files
23+
Editing
24+
: This check can *not* run live in the IDE editor
25+
See
26+
: https://developer.android.com/training/wearables/ongoing-activity#best-practices
27+
Implementation
28+
: [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/ActivityIconColorDetector.kt)
29+
Tests
30+
: [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/ActivityIconColorDetectorTest.kt)
31+
Copyright Year
32+
: 2022
33+
34+
The resources passed to `setAnimatedIcon` and `setStaticIcon` should be
35+
white with a transparent background, preferably a VectorDrawable or
36+
AnimatedVectorDrawable.
37+
38+
(##) Example
39+
40+
Here is an example of lint warnings produced by this check:
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
42+
src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt:9:Warning: The
43+
animated icon for an ongoing activity should be white with a transparent
44+
background [ActivityIconColor]
45+
46+
.setAnimatedIcon(R.drawable.animated_walk)
47+
------------------------
48+
49+
50+
src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt:10:Warning: The
51+
static icon for an ongoing activity should be white with a transparent
52+
background [ActivityIconColor]
53+
54+
.setStaticIcon(R.drawable.ic_walk)
55+
------------------
56+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57+
58+
Here is the source file referenced above:
59+
60+
`src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt`:
61+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers
62+
package test.pkg;
63+
64+
import androidx.wear.ongoing.OngoingActivity
65+
66+
class ForegroundOnlyWalkingWorkoutService {
67+
private fun generateNotification(mainText: String) {
68+
val ongoingActivity =
69+
OngoingActivity.Builder()
70+
.setAnimatedIcon(R.drawable.animated_walk)
71+
.setStaticIcon(R.drawable.ic_walk)
72+
.build()
73+
}
74+
}
75+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
77+
You can also visit the
78+
[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/ActivityIconColorDetectorTest.kt)
79+
for the unit tests for this check to see additional scenarios.
80+
81+
(##) Suppressing
82+
83+
You can suppress false positives using one of the following mechanisms:
84+
85+
* Using a suppression annotation like this on the enclosing
86+
element:
87+
88+
```kt
89+
// Kotlin
90+
@Suppress("ActivityIconColor")
91+
fun method() {
92+
setAnimatedIcon(...)
93+
}
94+
```
95+
96+
or
97+
98+
```java
99+
// Java
100+
@SuppressWarnings("ActivityIconColor")
101+
void method() {
102+
setAnimatedIcon(...);
103+
}
104+
```
105+
106+
* Using a suppression comment like this on the line above:
107+
108+
```kt
109+
//noinspection ActivityIconColor
110+
problematicStatement()
111+
```
112+
113+
* Adding the suppression attribute `tools:ignore="ActivityIconColor"`
114+
on the problematic XML element (or one of its enclosing elements).
115+
You may also need to add the following namespace declaration on the
116+
root element in the XML file if it's not already there:
117+
`xmlns:tools="http://schemas.android.com/tools"`.
118+
119+
* Using a special `lint.xml` file in the source tree which turns off
120+
the check in that folder and any sub folder. A simple file might look
121+
like this:
122+
```xml
123+
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
124+
&lt;lint&gt;
125+
&lt;issue id="ActivityIconColor" severity="ignore" /&gt;
126+
&lt;/lint&gt;
127+
```
128+
Instead of `ignore` you can also change the severity here, for
129+
example from `error` to `warning`. You can find additional
130+
documentation on how to filter issues by path, regular expression and
131+
so on
132+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).
133+
134+
* In Gradle projects, using the DSL syntax to configure lint. For
135+
example, you can use something like
136+
```gradle
137+
lintOptions {
138+
disable 'ActivityIconColor'
139+
}
140+
```
141+
In Android projects this should be nested inside an `android { }`
142+
block.
143+
144+
* For manual invocations of `lint`, using the `--ignore` flag:
145+
```
146+
$ lint --ignore ActivityIconColor ...`
147+
```
148+
149+
* Last, but not least, using baselines, as discussed
150+
[here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).
151+
152+
<!-- 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/AlertDialogUsage.md.html

+6-41
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,21 @@
1919
Feedback
2020
: https://github.com/vanniktech/lint-rules/issues
2121
Min
22-
: Lint 7.3 and 7.4
22+
: Lint 8.0 and 8.1
2323
Compiled
24-
: Lint 7.3 and 7.4
24+
: Lint 8.0 and 8.1
2525
Artifact
2626
: [com.vanniktech:lint-rules-android](com_vanniktech_lint-rules-android.md.html)
2727

2828
Affects
2929
: Kotlin and Java files
3030
Editing
3131
: This check runs on the fly in the IDE editor
32-
Implementation
33-
: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/main/java/com/vanniktech/lintrules/android/AlertDialogUsageDetector.kt)
34-
Tests
35-
: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/java/com/vanniktech/lintrules/android/AlertDialogUsageDetectorTest.kt)
3632

3733
Support library AlertDialog is much more powerful and plays better
3834
together with the new theming / styling than the AlertDialog built into
3935
the framework.
4036

41-
(##) Example
42-
43-
Here is an example of lint warnings produced by this check:
44-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
45-
src/Test.java:4:Warning: Should not be using android.app.AlertDialog
46-
[AlertDialogUsage]
47-
48-
public Test(AlertDialog dialog) { }
49-
------------------
50-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51-
52-
Here is the source file referenced above:
53-
54-
`src/Test.java`:
55-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers
56-
import android.app.AlertDialog;
57-
58-
class Test {
59-
public Test(AlertDialog dialog) { }
60-
}
61-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62-
63-
You can also visit the
64-
[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/java/com/vanniktech/lintrules/android/AlertDialogUsageDetectorTest.kt)
65-
for the unit tests for this check to see additional scenarios.
66-
67-
The above example was automatically extracted from the first unit test
68-
found for this lint check, `AlertDialogUsageDetector.constructorParameterInJava`.
69-
To report a problem with this extracted sample, visit
70-
https://github.com/vanniktech/lint-rules/issues.
71-
7237
(##) Including
7338

7439
!!!
@@ -78,25 +43,25 @@
7843

7944
```
8045
// build.gradle.kts
81-
lintChecks("com.vanniktech:lint-rules-android:0.24.0")
46+
lintChecks("com.vanniktech:lint-rules-android:0.25.0")
8247

8348
// build.gradle
84-
lintChecks 'com.vanniktech:lint-rules-android:0.24.0'
49+
lintChecks 'com.vanniktech:lint-rules-android:0.25.0'
8550

8651
// build.gradle.kts with version catalogs:
8752
lintChecks(libs.lint-rules-android)
8853

8954
# libs.versions.toml
9055
[versions]
91-
lint-rules-android = "0.24.0"
56+
lint-rules-android = "0.25.0"
9257
[libraries]
9358
lint-rules-android = {
9459
module = "com.vanniktech:lint-rules-android",
9560
version.ref = "lint-rules-android"
9661
}
9762
```
9863

99-
0.24.0 is the version this documentation was generated from;
64+
0.25.0 is the version this documentation was generated from;
10065
there may be newer versions available.
10166

10267
[Additional details about com.vanniktech:lint-rules-android](com_vanniktech_lint-rules-android.md.html).

docs/checks/AndroidGradlePluginVersion.md.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
[AndroidGradlePluginVersion]
4949

5050
classpath 'com.android.tools.build:gradle:3.4.0-alpha3'
51-
-------------------------------------------------------
51+
---------------------------------------------
5252
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5353

5454
Here is the source file referenced above:

0 commit comments

Comments
 (0)