Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
567 changes: 470 additions & 97 deletions docs/api-guide.html

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/api-guide/basics.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
This is a \`code symbol\` | This is a `code symbol`
This is `*italics*` | This is *italics*
This is `**bold**` | This is **bold**
This is `~~strikethrough~~` | This is ~~strikethrough~~
http://, https:// | [](http://), [](https://)
`\*not italics*` | `\*not italics*`
\`\`\`language\n text\n\`\`\`| (preformatted text block)
Expand Down Expand Up @@ -787,7 +788,7 @@
val incident = Incident(context, ISSUE)
.message( "Use `<vector>` instead of `<bitmap>`")
.at(element)
context.report(incident))
context.report(incident)
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -894,7 +895,7 @@
Line 1 says we want to have line 3 called whenever lint comes across a
method to `setRepeating`.

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

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

Expand Down
43 changes: 43 additions & 0 deletions docs/api-guide/changes.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,49 @@
information about user visible changes to lint, see the User
Guide.

**8.4**

* You can now use `~~` in text messages (error messages, issue
explanations, etc) to create strikethrough text. For example, “`Don't
do this: ~~super.onCreate()~~`” will render as “Don't do this:
~~super.onCreate()~~”.

**8.3**

* If you'd like to change your error message reported by your
detector, you can now override your `Detector`'s `sameMessage`
method: match the details in the previous error message with the
new format. This is used by the baseline mechanism such that your
message change doesn't suddenly invalidate all existing baseline
files for your issue.

* The replace-string quickfix descriptor now lets you replace a string
repeatedly. Example:
```
fix().replace().text("Foo").with("Bar").repeatedly().build()
```

You can also match an element optionally. Example:
```
fix().composite(
fix().replace().text("<Tag>").with("<tag>").build(),
fix().replace().text("</Tag>").with("</tag>").optional().build()
)
```

* The quickfix machinery was improved significantly. It now does a
better job inserting imports (in alphabetical order instead of always
prepending to the import list), inserting new XML attributes in the
right canonical Android order, cleaning up whitespace after edits,
etc. This may result in some diffs in any quickfix-related unit tests
(e.g. `lint().run().expectFixDiffs(...)`)

* The `getFileNameWithParent` utility method now always uses / as
a file separator instead of the platform-specific one (e.g. \ on
Windows). This ensures that baselines don't vary their error
messages (where this utility method is typically used) based on
which OS they were generated on.

**8.2**

* For unit tests, you can now specify the language level to be used
Expand Down
1 change: 1 addition & 0 deletions docs/api-guide/messages.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
This is a \`code symbol\` | This is a `code symbol`
This is `*italics*` | This is *italics*
This is `**bold**` | This is **bold**
This is `~~strikethrough~~` | This is ~~strikethrough~~
http://, https:// | [](http://), [](https://)
`\*not italics*` | `\*not italics*`
\`\`\`language\n text\n\`\`\`| (preformatted text block)
Expand Down
4 changes: 2 additions & 2 deletions docs/api-guide/publishing.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
### lintPublish Configuration

The Android Gradle library plugin provides some special configurations,
`lintConfig` and `lintPublish`.
`lintChecks` and `lintPublish`.

The `lintPublish` configuration lets you reference another project, and
it will take that project's output jar and package it as a `lint.jar`
Expand Down Expand Up @@ -94,7 +94,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
apply plugin: 'com.android.application'
dependencies {
lintConfig project(':checks')
lintChecks project(':checks')
// other dependencies
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions docs/book.html

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions docs/checks/ActivityIconColor.md.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<meta charset="utf-8">
(#) Ongoing activity icon is not white

!!! WARNING: Ongoing activity icon is not white
This is a warning.

Id
: `ActivityIconColor`
Summary
: Ongoing activity icon is not white
Severity
: Warning
Category
: Usability: Icons
Platform
: Android
Vendor
: Android Open Source Project
Feedback
: https://issuetracker.google.com/issues/new?component=192708
Affects
: Kotlin and Java files, binary resource files and resource files
Editing
: This check can *not* run live in the IDE editor
See
: https://developer.android.com/training/wearables/ongoing-activity#best-practices
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/ActivityIconColorDetector.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/ActivityIconColorDetectorTest.kt)
Copyright Year
: 2022

The resources passed to `setAnimatedIcon` and `setStaticIcon` should be
white with a transparent background, preferably a VectorDrawable or
AnimatedVectorDrawable.

(##) Example

Here is an example of lint warnings produced by this check:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt:9:Warning: The
animated icon for an ongoing activity should be white with a transparent
background [ActivityIconColor]

.setAnimatedIcon(R.drawable.animated_walk)
------------------------


src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt:10:Warning: The
static icon for an ongoing activity should be white with a transparent
background [ActivityIconColor]

.setStaticIcon(R.drawable.ic_walk)
------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is the source file referenced above:

`src/test/pkg/ForegroundOnlyWalkingWorkoutService.kt`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers
package test.pkg;

import androidx.wear.ongoing.OngoingActivity

class ForegroundOnlyWalkingWorkoutService {
private fun generateNotification(mainText: String) {
val ongoingActivity =
OngoingActivity.Builder()
.setAnimatedIcon(R.drawable.animated_walk)
.setStaticIcon(R.drawable.ic_walk)
.build()
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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/ActivityIconColorDetectorTest.kt)
for the unit tests for this check to see additional scenarios.

(##) Suppressing

You can suppress false positives using one of the following mechanisms:

* Using a suppression annotation like this on the enclosing
element:

```kt
// Kotlin
@Suppress("ActivityIconColor")
fun method() {
setAnimatedIcon(...)
}
```

or

```java
// Java
@SuppressWarnings("ActivityIconColor")
void method() {
setAnimatedIcon(...);
}
```

* Using a suppression comment like this on the line above:

```kt
//noinspection ActivityIconColor
problematicStatement()
```

* Adding the suppression attribute `tools:ignore="ActivityIconColor"`
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"`.

* 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
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;lint&gt;
&lt;issue id="ActivityIconColor" severity="ignore" /&gt;
&lt;/lint&gt;
```
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 'ActivityIconColor'
}
```
In Android projects this should be nested inside an `android { }`
block.

* For manual invocations of `lint`, using the `--ignore` flag:
```
$ lint --ignore ActivityIconColor ...`
```

* 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>
47 changes: 6 additions & 41 deletions docs/checks/AlertDialogUsage.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,21 @@
Feedback
: https://github.com/vanniktech/lint-rules/issues
Min
: Lint 7.3 and 7.4
: Lint 8.0 and 8.1
Compiled
: Lint 7.3 and 7.4
: Lint 8.0 and 8.1
Artifact
: [com.vanniktech:lint-rules-android](com_vanniktech_lint-rules-android.md.html)

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

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

(##) Example

Here is an example of lint warnings produced by this check:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
src/Test.java:4:Warning: Should not be using android.app.AlertDialog
[AlertDialogUsage]

public Test(AlertDialog dialog) { }
------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is the source file referenced above:

`src/Test.java`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers
import android.app.AlertDialog;

class Test {
public Test(AlertDialog dialog) { }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also visit the
[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/java/com/vanniktech/lintrules/android/AlertDialogUsageDetectorTest.kt)
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, `AlertDialogUsageDetector.constructorParameterInJava`.
To report a problem with this extracted sample, visit
https://github.com/vanniktech/lint-rules/issues.

(##) Including

!!!
Expand All @@ -78,25 +43,25 @@

```
// build.gradle.kts
lintChecks("com.vanniktech:lint-rules-android:0.24.0")
lintChecks("com.vanniktech:lint-rules-android:0.25.0")

// build.gradle
lintChecks 'com.vanniktech:lint-rules-android:0.24.0'
lintChecks 'com.vanniktech:lint-rules-android:0.25.0'

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

# libs.versions.toml
[versions]
lint-rules-android = "0.24.0"
lint-rules-android = "0.25.0"
[libraries]
lint-rules-android = {
module = "com.vanniktech:lint-rules-android",
version.ref = "lint-rules-android"
}
```

0.24.0 is the version this documentation was generated from;
0.25.0 is the version this documentation was generated from;
there may be newer versions available.

[Additional details about com.vanniktech:lint-rules-android](com_vanniktech_lint-rules-android.md.html).
Expand Down
2 changes: 1 addition & 1 deletion docs/checks/AndroidGradlePluginVersion.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
[AndroidGradlePluginVersion]

classpath 'com.android.tools.build:gradle:3.4.0-alpha3'
-------------------------------------------------------
---------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is the source file referenced above:
Expand Down
Loading