diff --git a/docs/checks/AaptCrash.md.html b/docs/checks/AaptCrash.md.html index cac7a4a..45ec8e2 100644 --- a/docs/checks/AaptCrash.md.html +++ b/docs/checks/AaptCrash.md.html @@ -44,7 +44,6 @@ aapt during a build. Change @+id/titlebar to @id/titlebar and define the id explicitly using instead. [AaptCrash] - <item name="android:id">@+id/titlebar</item> -------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AcceptsUserCertificates.md.html b/docs/checks/AcceptsUserCertificates.md.html index 82aed21..31202cd 100644 --- a/docs/checks/AcceptsUserCertificates.md.html +++ b/docs/checks/AcceptsUserCertificates.md.html @@ -34,10 +34,10 @@ : 2016 Allowing user certificates could allow eavesdroppers to intercept data -sent by your app, 'which could impact the privacy of your users. -Consider nesting your app's `trust-anchors` inside a `` -element to make sure they are only available when `android:debuggable` -is set to `"true"`. +sent by your app, which could impact the privacy of your users. Consider +nesting your app's `trust-anchors` inside a `` element +to make sure they are only available when `android:debuggable` is set to +`true`. (##) Example @@ -46,7 +46,6 @@ res/xml/network_config.xml:6:Warning: The Network Security Configuration allows the use of user certificates in the release version of your app [AcceptsUserCertificates] - <certificates src="user"/> -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AccessibilityFocus.md.html b/docs/checks/AccessibilityFocus.md.html index 809f440..73e309c 100644 --- a/docs/checks/AccessibilityFocus.md.html +++ b/docs/checks/AccessibilityFocus.md.html @@ -39,7 +39,6 @@ src/com/my/app/MyView.kt:12:Warning: Do not force accessibility focus, as this interferes with screen readers and gives an inconsistent user experience, especially across apps [AccessibilityFocus] - performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null) ---------------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AccessibilityScrollActions.md.html b/docs/checks/AccessibilityScrollActions.md.html index a95db9a..71afb02 100644 --- a/docs/checks/AccessibilityScrollActions.md.html +++ b/docs/checks/AccessibilityScrollActions.md.html @@ -41,7 +41,6 @@ and support ACTION_SCROLL_{FORWARD,BACKWARD} should also support ACTION_SCROLL_{LEFT,RIGHT} and/or ACTION_SCROLL_{UP,DOWN} [AccessibilityScrollActions] - override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo) { ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AccessibilityWindowStateChangedEvent.md.html b/docs/checks/AccessibilityWindowStateChangedEvent.md.html index 6805e3f..8967468 100644 --- a/docs/checks/AccessibilityWindowStateChangedEvent.md.html +++ b/docs/checks/AccessibilityWindowStateChangedEvent.md.html @@ -57,29 +57,22 @@ View.onInitializeAccessibilityNodeInfo, Activity.setTitle, ViewCompat.setAccessibilityPaneTitle, etc. to inform users of crucial changes to the UI. [AccessibilityWindowStateChangedEvent] - sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) -------------------------------------------------------------------- - - src/com/my/app/MyView.kt:16:Warning: Manually populating or sending TYPE_WINDOW_STATE_CHANGED events should be avoided. They may be ignored on certain versions of Android. Prefer setting UI metadata using View.onInitializeAccessibilityNodeInfo, Activity.setTitle, ViewCompat.setAccessibilityPaneTitle, etc. to inform users of crucial changes to the UI. [AccessibilityWindowStateChangedEvent] - if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { ------------------------- - - src/com/my/app/MyView.kt:23:Warning: Manually populating or sending TYPE_WINDOW_STATE_CHANGED events should be avoided. They may be ignored on certain versions of Android. Prefer setting UI metadata using View.onInitializeAccessibilityNodeInfo, Activity.setTitle, ViewCompat.setAccessibilityPaneTitle, etc. to inform users of crucial changes to the UI. [AccessibilityWindowStateChangedEvent] - if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AccidentalOctal.md.html b/docs/checks/AccidentalOctal.md.html index b0cc25a..1f02e78 100644 --- a/docs/checks/AccidentalOctal.md.html +++ b/docs/checks/AccidentalOctal.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:13:Error: The leading 0 turns this number into octal which is probably not what was intended (interpreted as 8) [AccidentalOctal] - versionCode 010 --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ActivityIconColor.md.html b/docs/checks/ActivityIconColor.md.html index f2d0b02..6e769be 100644 --- a/docs/checks/ActivityIconColor.md.html +++ b/docs/checks/ActivityIconColor.md.html @@ -42,15 +42,11 @@ 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) ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AdapterViewChildren.md.html b/docs/checks/AdapterViewChildren.md.html index 6ab2d4d..4972031 100644 --- a/docs/checks/AdapterViewChildren.md.html +++ b/docs/checks/AdapterViewChildren.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/has_children.xml:1:Warning: A list/grid should have no children declared in XML [AdapterViewChildren] - <ListView -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AddJavascriptInterface.md.html b/docs/checks/AddJavascriptInterface.md.html index c81aa6f..c3ebade 100644 --- a/docs/checks/AddJavascriptInterface.md.html +++ b/docs/checks/AddJavascriptInterface.md.html @@ -49,16 +49,12 @@ WebView.addJavascriptInterface should not be called with minSdkVersion < 17 for security reasons: JavaScript can use reflection to manipulate application [AddJavascriptInterface] - webView.addJavascriptInterface(object, string); ---------------------- - - src/test/pkg/AddJavascriptInterfaceTest.java:23:Warning: WebView.addJavascriptInterface should not be called with minSdkVersion < 17 for security reasons: JavaScript can use reflection to manipulate application [AddJavascriptInterface] - webView.addJavascriptInterface(object, string); ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AlertDialogUsage.md.html b/docs/checks/AlertDialogUsage.md.html index b957bc2..359ce86 100644 --- a/docs/checks/AlertDialogUsage.md.html +++ b/docs/checks/AlertDialogUsage.md.html @@ -1,13 +1,13 @@ -(#) Use the support library AlertDialog instead of android.app.AlertDialog. +(#) Use the support library AlertDialog instead of android.app.AlertDialog -!!! WARNING: Use the support library AlertDialog instead of android.app.AlertDialog. +!!! WARNING: Use the support library AlertDialog instead of android.app.AlertDialog This is a warning. Id : `AlertDialogUsage` Summary -: Use the support library AlertDialog instead of android.app.AlertDialog. +: Use the support library AlertDialog instead of android.app.AlertDialog Severity : Warning Category @@ -29,11 +29,45 @@ : 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/kotlin/com/vanniktech/lintrules/android/AlertDialogUsageDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/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/kotlin/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 !!! diff --git a/docs/checks/AllCaps.md.html b/docs/checks/AllCaps.md.html index fbd72a0..ccea5ed 100644 --- a/docs/checks/AllCaps.md.html +++ b/docs/checks/AllCaps.md.html @@ -41,12 +41,11 @@ res/layout/constraint.xml:12:Warning: Using textAllCaps with a string (has_markup) that contains markup; the markup will be dropped by the caps conversion [AllCaps] - android:textAllCaps="true" -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/constraint.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -78,6 +77,14 @@ </merge> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="plain">Home Sample</string> + <string name="has_markup">This is <b>bold</b></string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/AllCapsDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/AllowAllHostnameVerifier.md.html b/docs/checks/AllowAllHostnameVerifier.md.html index 1ec2c94..fdb4980 100644 --- a/docs/checks/AllowAllHostnameVerifier.md.html +++ b/docs/checks/AllowAllHostnameVerifier.md.html @@ -45,17 +45,13 @@ returns true, which could cause insecure network traffic due to trusting TLS/SSL server certificates for wrong hostnames [AllowAllHostnameVerifier] - connection.setHostnameVerifier(new AllowAllHostnameVerifier()); ------------------------------ - - src/test/pkg/InsecureHostnameVerifier.java:23:Warning: Using the ALLOW_ALL_HOSTNAME_VERIFIER HostnameVerifier is unsafe because it always returns true, which could cause insecure network traffic due to trusting TLS/SSL server certificates for wrong hostnames [AllowAllHostnameVerifier] - connection.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); -------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AlwaysShowAction.md.html b/docs/checks/AlwaysShowAction.md.html index ad057ea..c36eb33 100644 --- a/docs/checks/AlwaysShowAction.md.html +++ b/docs/checks/AlwaysShowAction.md.html @@ -54,7 +54,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/menu-land/actions.xml:6:Warning: Prefer "ifRoom" instead of "always" [AlwaysShowAction] - android:showAsAction="always|collapseActionView" ------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AndroidGradlePluginVersion.md.html b/docs/checks/AndroidGradlePluginVersion.md.html index 1c80057..1e80c08 100644 --- a/docs/checks/AndroidGradlePluginVersion.md.html +++ b/docs/checks/AndroidGradlePluginVersion.md.html @@ -43,32 +43,53 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -build.gradle:7:Warning: A newer version of -com.android.tools.build:gradle than 3.4.0-alpha3 is available: 3.5.0 +../gradle/libs.versions.toml:8:Warning: A newer version of +com.android.application than 8.0.0 is available: 8.0.2 [AndroidGradlePluginVersion] - - classpath 'com.android.tools.build:gradle:3.4.0-alpha3' - --------------------------------------------- +gradlePlugins-agp = "8.0.0" + ------- +../gradle/libs.versions.toml:9:Warning: A newer version of +com.android.application than 8.1.0-alpha01 is available: 8.1.0-rc01 +[AndroidGradlePluginVersion] +gradlePlugins-agp-alpha = "8.1.0-alpha01" + --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`build.gradle`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers -buildscript { - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.4.0-alpha3' - } -} -dependencies { - compile 'org.apache.httpcomponents:httpcomponents-core:4.2' - compile 'com.android.support:recyclerview-v7:25.0.0' - compile 'com.google.firebase:firebase-messaging:10.2.1' -} +`../gradle/libs.versions.toml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~toml linenumbers +[versions] +guavaVersion = "11.0.2" +appCompatVersion="13.0.0" +wearableVersion=" 1.2.0 " +# Test comment suppression: +#noinspection GradleDependency +multi-dex="1.0.0" +gradlePlugins-agp = "8.0.0" +gradlePlugins-agp-alpha = "8.1.0-alpha01" +gradlePlugins-agp-dev = "8.2.0-dev" +gradlePlugins-crashlytics = "2.9.2" +gradlePlugins-dependency-analysis = "1.0.0" + +[libraries] +com-google-guava = { module = "com.google.guava:guava", version.ref = "guavaVersion"} +appcompat = { module = "com.android.support:appcompat-v7", version.ref = "appCompatVersion" } +wearable-support = { group = " com.google.android.support ", name =" wearable ", version.ref = " wearableVersion " } +multidex-lib = { module = "com.android.support:multidex", version.ref = "multi-dex" } + +[bundles] +misc = [ + "com-google-guava", + "appcompat", +] + +[plugins] +android-application = { id = "com.android.application", version.ref = "gradlePlugins-agp" } +android-application2 = { id = "com.android.application", version.ref = "gradlePlugins-agp-alpha" } +android-application3 = { id = "com.android.application", version.ref = "gradlePlugins-agp-dev" } +crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "gradlePlugins-crashlytics" } +dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "gradlePlugins-dependency-analysis" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the @@ -76,7 +97,7 @@ 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, `GradleDetector.testVersionsFromGradleCache`. +found for this lint check, `GradleDetector.testTomlVersionCatalogFile`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. diff --git a/docs/checks/AnimatorKeep.md.html b/docs/checks/AnimatorKeep.md.html index 1daf421..a5254ee 100644 --- a/docs/checks/AnimatorKeep.md.html +++ b/docs/checks/AnimatorKeep.md.html @@ -45,115 +45,38 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/main/java/test/pkg/AnimatorTest.java:55:Warning: This method is -accessed from an ObjectAnimator so it should be annotated with @Keep to -ensure that it is not discarded or renamed in release builds -[AnimatorKeep] - +src/main/java/AnimationExample.java:14:Warning: This method is accessed +from an ObjectAnimator so it should be annotated with @Keep to ensure +that it is not discarded or renamed in release builds [AnimatorKeep] public void setProp1(int x) { --------------- - - -src/main/java/test/pkg/AnimatorTest.java:58:Warning: This method is -accessed from an ObjectAnimator so it should be annotated with @Keep to -ensure that it is not discarded or renamed in release builds -[AnimatorKeep] - - private void setProp2(float x) { - ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`src/main/java/test/pkg/AnimatorTest.java`: +`src/main/java/AnimationExample.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -package test.pkg; - - import android.animation.ObjectAnimator; -import android.animation.PropertyValuesHolder; -import androidx.annotation.Keep; -import android.view.View; -import android.widget.Button; -import android.animation.FloatEvaluator; -@SuppressWarnings("unused") -public class AnimatorTest { - - public void testObjectAnimator(Button button) { + +public class AnimationExample { + public void startAnimations() { Object myObject = new MyObject(); ObjectAnimator animator1 = ObjectAnimator.ofInt(myObject, "prop1", 0, 1, 2, 5); - animator1.setDuration(10); animator1.start(); - - // Incorrect type (float parameter) warning - ObjectAnimator.ofInt(myObject, "prop2", 0, 1, 2, 5).start(); - - // Missing method warning - ObjectAnimator.ofInt(myObject, "unknown", 0, 1, 2, 5).start(); - - // Static method warning - ObjectAnimator.ofInt(myObject, "prop3", 0, 1, 2, 5).start(); - - // OK: Already marked @Keep - ObjectAnimator.ofInt(myObject, "prop4", 0, 1, 2, 5).start(); - - // OK: multi int - ObjectAnimator.ofMultiInt(myObject, "prop4", new int[0][]).start(); - - // OK: multi int - ObjectAnimator.ofMultiFloat(myObject, "prop5", new float[0][]).start(); - - // View stuff - ObjectAnimator.ofFloat(button, "alpha", 1, 5); // TODO: Warn about better method?, e.g. button.animate().alpha(...) - ObjectAnimator.ofArgb(button, "alpha2", 1, 5); // Missing - } - - public void testPropertyHolder() { - Object myObject = new MyObject(); - - PropertyValuesHolder p1 = PropertyValuesHolder.ofInt("prop1", 50); - PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("prop2", 100f); - ObjectAnimator.ofPropertyValuesHolder(myObject, p1, p2).start(); - ObjectAnimator.ofPropertyValuesHolder(myObject, - PropertyValuesHolder.ofInt("prop1", 50), - PropertyValuesHolder.ofFloat("prop2", 100f)).start(); + ObjectAnimator animator2 = ObjectAnimator.ofInt(myObject, "prop2", 0, 1, 2, 5); + animator2.start(); } private static class MyObject { public void setProp1(int x) { + // Implementation here } private void setProp2(float x) { + // Implementation here } - - public static void setProp3(int x) { - } - - @Keep - public void setProp4(int[] x) { - } - - @Keep - public void setProp5(float[] x) { - } - - @Keep - public void setProp4(int x) { - } - - @Keep - public void setProp5(float x) { - } - } - - public void testEvaluators() { - Object myObject = new MyObject(); - PropertyValuesHolder p1 = PropertyValuesHolder.ofObject("prop5", new FloatEvaluator()); - ObjectAnimator.ofPropertyValuesHolder(myObject, p1); - ObjectAnimator.ofObject(myObject, "prop5", new FloatEvaluator(), 1f, 2f); } - } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -161,11 +84,6 @@ [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/ObjectAnimatorDetectorTest.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, `ObjectAnimatorDetector.testBasic`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/AnnotateVersionCheck.md.html b/docs/checks/AnnotateVersionCheck.md.html index 7dcb196..ad936fd 100644 --- a/docs/checks/AnnotateVersionCheck.md.html +++ b/docs/checks/AnnotateVersionCheck.md.html @@ -45,22 +45,15 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/test.kt:8:Warning: This method should be annotated with @ChecksSdkIntAtLeast(api=VERSION_CODES.N) [AnnotateVersionCheck] - fun isNougat(): Boolean { -------- - - src/test/pkg/test.kt:12:Warning: This method should be annotated with @ChecksSdkIntAtLeast(parameter=0) [AnnotateVersionCheck] - fun isAtLeast(api: Int): Boolean { --------- - - src/test/pkg/test.kt:16:Warning: This method should be annotated with @ChecksSdkIntAtLeast(api=Build.VERSION_CODES.O, lambda=1) [AnnotateVersionCheck] - inline fun <T> T.applyForOreoOrAbove(block: T.() -> Unit): T { ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AnnotationProcessorOnCompilePath.md.html b/docs/checks/AnnotationProcessorOnCompilePath.md.html index 9b99a2f..2c22490 100644 --- a/docs/checks/AnnotationProcessorOnCompilePath.md.html +++ b/docs/checks/AnnotationProcessorOnCompilePath.md.html @@ -42,47 +42,31 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:2:Warning: Add annotation processor to processor path using annotationProcessor instead of api [AnnotationProcessorOnCompilePath] - api 'com.jakewharton:butterknife-compiler:10.1.0' --- - - build.gradle:3:Warning: Add annotation processor to processor path using annotationProcessor instead of implementation [AnnotationProcessorOnCompilePath] - implementation 'com.github.bumptech.glide:compiler:4.9.0' -------------- - - build.gradle:4:Warning: Add annotation processor to processor path using annotationProcessor instead of compile [AnnotationProcessorOnCompilePath] - compile "androidx.lifecycle:lifecycle-compiler:2.2.0-alpha01" ------- - - build.gradle:5:Warning: Add annotation processor to processor path using testAnnotationProcessor instead of testImplementation [AnnotationProcessorOnCompilePath] - testImplementation "com.google.auto.value:auto-value:1.6.2" ------------------ - - build.gradle:6:Warning: Add annotation processor to processor path using androidTestAnnotationProcessor instead of androidTestCompile [AnnotationProcessorOnCompilePath] - androidTestCompile "org.projectlombok:lombok:1.18.8" ------------------ - - build.gradle:8:Warning: Add annotation processor to processor path using debugAnnotationProcessor instead of debugCompile [AnnotationProcessorOnCompilePath] - debugCompile "android.arch.persistence.room:compiler:1.1.1" ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AppBundleLocaleChanges.md.html b/docs/checks/AppBundleLocaleChanges.md.html index dcb255f..7475066 100644 --- a/docs/checks/AppBundleLocaleChanges.md.html +++ b/docs/checks/AppBundleLocaleChanges.md.html @@ -44,7 +44,6 @@ corresponding Play Core library calls for downloading languages and splitting by language is not disabled in the bundle configuration [AppBundleLocaleChanges] - configuration.locale = locale ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AppCompatCustomView.md.html b/docs/checks/AppCompatCustomView.md.html index d1fd257..7471f80 100644 --- a/docs/checks/AppCompatCustomView.md.html +++ b/docs/checks/AppCompatCustomView.md.html @@ -47,112 +47,72 @@ src/test/pkg/TestAppCompatSuperClasses.java:23:Error: This custom view should extend android.support.v7.widget.AppCompatButton instead [AppCompatCustomView] - public class MyButton1 extends Button { // ERROR ------ - - src/test/pkg/TestAppCompatSuperClasses.java:28:Error: This custom view should extend android.support.v7.widget.AppCompatButton instead [AppCompatCustomView] - public class MyButton2 extends Button implements Runnable { // ERROR ------ - - src/test/pkg/TestAppCompatSuperClasses.java:47:Error: This custom view should extend android.support.v7.widget.AppCompatEditText instead [AppCompatCustomView] - public class MyEditText extends EditText { // ERROR -------- - - src/test/pkg/TestAppCompatSuperClasses.java:51:Error: This custom view should extend android.support.v7.widget.AppCompatTextView instead [AppCompatCustomView] - public class MyTextView extends TextView { // ERROR -------- - - src/test/pkg/TestAppCompatSuperClasses.java:55:Error: This custom view should extend android.support.v7.widget.AppCompatCheckBox instead [AppCompatCustomView] - public class MyCheckBox extends CheckBox { // ERROR -------- - - src/test/pkg/TestAppCompatSuperClasses.java:59:Error: This custom view should extend android.support.v7.widget.AppCompatCheckedTextView instead [AppCompatCustomView] - public class MyCheckedTextView extends CheckedTextView { // ERROR --------------- - - src/test/pkg/TestAppCompatSuperClasses.java:63:Error: This custom view should extend android.support.v7.widget.AppCompatImageButton instead [AppCompatCustomView] - public class MyImageButton extends ImageButton { // ERROR ----------- - - src/test/pkg/TestAppCompatSuperClasses.java:67:Error: This custom view should extend android.support.v7.widget.AppCompatImageView instead [AppCompatCustomView] - public class MyImageView extends ImageView { // ERROR --------- - - src/test/pkg/TestAppCompatSuperClasses.java:71:Error: This custom view should extend android.support.v7.widget.AppCompatMultiAutoCompleteTextView instead [AppCompatCustomView] - public class MyMultiAutoCompleteTextView extends MultiAutoCompleteTextView { // ERROR ------------------------- - - src/test/pkg/TestAppCompatSuperClasses.java:75:Error: This custom view should extend android.support.v7.widget.AppCompatAutoCompleteTextView instead [AppCompatCustomView] - public class MyAutoCompleteTextView extends AutoCompleteTextView { // ERROR -------------------- - - src/test/pkg/TestAppCompatSuperClasses.java:79:Error: This custom view should extend android.support.v7.widget.AppCompatRadioButton instead [AppCompatCustomView] - public class MyRadioButton extends RadioButton { // ERROR ----------- - - src/test/pkg/TestAppCompatSuperClasses.java:83:Error: This custom view should extend android.support.v7.widget.AppCompatRatingBar instead [AppCompatCustomView] - public class MyRatingBar extends RatingBar { // ERROR --------- - - src/test/pkg/TestAppCompatSuperClasses.java:87:Error: This custom view should extend android.support.v7.widget.AppCompatSeekBar instead [AppCompatCustomView] - public class MySeekBar extends SeekBar { // ERROR ------- - - src/test/pkg/TestAppCompatSuperClasses.java:91:Error: This custom view should extend android.support.v7.widget.AppCompatSpinner instead [AppCompatCustomView] - public class MySpinner extends Spinner { // ERROR ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AppCompatMethod.md.html b/docs/checks/AppCompatMethod.md.html index 526a6a3..8e28cf5 100644 --- a/docs/checks/AppCompatMethod.md.html +++ b/docs/checks/AppCompatMethod.md.html @@ -47,47 +47,31 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/AppCompatTest.java:5:Warning: Should use getSupportActionBar instead of getActionBar name [AppCompatMethod] - getActionBar(); // ERROR -------------- - - src/test/pkg/AppCompatTest.java:8:Warning: Should use startSupportActionMode instead of startActionMode name [AppCompatMethod] - startActionMode(null); // ERROR --------------------- - - src/test/pkg/AppCompatTest.java:11:Warning: Should use supportRequestWindowFeature instead of requestWindowFeature name [AppCompatMethod] - requestWindowFeature(0); // ERROR ----------------------- - - src/test/pkg/AppCompatTest.java:14:Warning: Should use setSupportProgressBarVisibility instead of setProgressBarVisibility name [AppCompatMethod] - setProgressBarVisibility(true); // ERROR ------------------------------ - - src/test/pkg/AppCompatTest.java:15:Warning: Should use setSupportProgressBarIndeterminate instead of setProgressBarIndeterminate name [AppCompatMethod] - setProgressBarIndeterminate(true); // ERROR --------------------------------- - - src/test/pkg/AppCompatTest.java:16:Warning: Should use setSupportProgressBarIndeterminateVisibility instead of setProgressBarIndeterminateVisibility name [AppCompatMethod] - setProgressBarIndeterminateVisibility(true); // ERROR ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AppCompatResource.md.html b/docs/checks/AppCompatResource.md.html index 557c19f..7bfe48c 100644 --- a/docs/checks/AppCompatResource.md.html +++ b/docs/checks/AppCompatResource.md.html @@ -46,7 +46,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/menu/showAction1.xml:6:Error: Should use android:showAsAction when not using the appcompat library [AppCompatResource] - app:showAsAction="never" /> ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AppIndexingService.md.html b/docs/checks/AppIndexingService.md.html index 681ec4e..e9d4936 100644 --- a/docs/checks/AppIndexingService.md.html +++ b/docs/checks/AppIndexingService.md.html @@ -43,12 +43,11 @@ src/main/AndroidManifest.xml:10:Warning: UPDATE_INDEX is configured as a service in your app, which is no longer supported for the API level you're targeting. Use a BroadcastReceiver instead. [AppIndexingService] - <action android:name="com.google.firebase.appindexing.UPDATE_INDEX" /> ----------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/main/AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -69,6 +68,15 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +apply plugin: 'com.android.application' + +dependencies { + compile 'com.google.firebase:firebase-appindexing:11.0.4' +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/AppLinkUrlError.md.html b/docs/checks/AppLinkUrlError.md.html index 4cec55a..8a3558c 100644 --- a/docs/checks/AppLinkUrlError.md.html +++ b/docs/checks/AppLinkUrlError.md.html @@ -45,7 +45,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:15:Error: Expected testUrl attribute [AppLinkUrlError] - <tools:validation /> -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AppLinksAutoVerify.md.html b/docs/checks/AppLinksAutoVerify.md.html index 00e5924..5a1d9b9 100644 --- a/docs/checks/AppLinksAutoVerify.md.html +++ b/docs/checks/AppLinksAutoVerify.md.html @@ -46,7 +46,6 @@ AndroidManifest.xml:12:Error: This host does not support app links to your app. Checks the Digital Asset Links JSON file: http://example.com/.well-known/assetlinks.json [AppLinksAutoVerify] - android:host="example.com" -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ApplySharedPref.md.html b/docs/checks/ApplySharedPref.md.html index c7b7ef3..abd7759 100644 --- a/docs/checks/ApplySharedPref.md.html +++ b/docs/checks/ApplySharedPref.md.html @@ -43,7 +43,6 @@ src/test/pkg/SharedPrefsTest.java:16:Warning: Consider using apply() instead; commit writes its data to persistent storage immediately, whereas apply will handle it in the background [ApplySharedPref] - editor.commit(); -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ArcAnimationSpecTypeIssue.md.html b/docs/checks/ArcAnimationSpecTypeIssue.md.html index 02bde02..34cf1c6 100644 --- a/docs/checks/ArcAnimationSpecTypeIssue.md.html +++ b/docs/checks/ArcAnimationSpecTypeIssue.md.html @@ -51,16 +51,12 @@ such as Offset, IntOffset or DpOffset. Otherwise, the animation might not be what you expect. [ArcAnimationSpecTypeIssue] - ArcAnimationSpec<Float>(ArcAbove) ---------------- - - src/foo/test.kt:15:Information: Arc animation is intended for 2D values such as Offset, IntOffset or DpOffset. Otherwise, the animation might not be what you expect. [ArcAnimationSpecTypeIssue] - ArcAnimationSpec<String>(ArcAbove) ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -103,17 +99,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.animation:animation-core-android:1.7.0-beta04") +implementation("androidx.compose.animation:animation-core-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.animation:animation-core-android:1.7.0-beta04' +implementation 'androidx.compose.animation:animation-core-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.animation-core-android) # libs.versions.toml [versions] -animation-core-android = "1.7.0-beta04" +animation-core-android = "1.7.0-beta05" [libraries] animation-core-android = { module = "androidx.compose.animation:animation-core-android", @@ -121,7 +117,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.animation:animation-core-android](androidx_compose_animation_animation-core-android.md.html). diff --git a/docs/checks/ArgInFormattedQuantityStringRes.md.html b/docs/checks/ArgInFormattedQuantityStringRes.md.html index c63f921..2f37cd1 100644 --- a/docs/checks/ArgInFormattedQuantityStringRes.md.html +++ b/docs/checks/ArgInFormattedQuantityStringRes.md.html @@ -1,13 +1,13 @@ -(#) Count value in formatted string resource. +(#) Count value in formatted string resource -!!! WARNING: Count value in formatted string resource. +!!! WARNING: Count value in formatted string resource This is a warning. Id : `ArgInFormattedQuantityStringRes` Summary -: Count value in formatted string resource. +: Count value in formatted string resource Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/ArgInFormattedQuantityStringResDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/ArgInFormattedQuantityStringResDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/ArgInFormattedQuantityStringResDetectorTest.kt) Copyright Year @@ -54,7 +54,6 @@ count modifier. If so, use LocalizationUtils.getFormattedCount(). Consult #plz-localization if you are unsure. [ArgInFormattedQuantityStringRes] - String s = res.getQuantityString(0, 3, 3, "asdf"); ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AssertionSideEffect.md.html b/docs/checks/AssertionSideEffect.md.html index 01955ac..7ea7b8e 100644 --- a/docs/checks/AssertionSideEffect.md.html +++ b/docs/checks/AssertionSideEffect.md.html @@ -44,19 +44,15 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test.kt:5:Warning: Assertion condition has a side effect: setOf(42) [AssertionSideEffect] - assert(42 != f.setOf(42)) // WARN 1 ----------- - - src/test.kt:6:Warning: Assertion condition has a side effect: f.of = 2024 [AssertionSideEffect] - assert(2024 != (f.of = 2024)) // WARN 2 ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -69,6 +65,22 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/Foo.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; +public class Foo { + private int OF = 0; + public int getOf() { + return OF; + } + public int setOf(int v) { + int prev = OF; + OF = v; + return prev; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/AssertDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/AssertjImport.md.html b/docs/checks/AssertjImport.md.html index a7f408c..0c20757 100644 --- a/docs/checks/AssertjImport.md.html +++ b/docs/checks/AssertjImport.md.html @@ -1,13 +1,13 @@ -(#) Flags Java 6 incompatible imports. +(#) Flags Java 6 incompatible imports -!!! WARNING: Flags Java 6 incompatible imports. +!!! WARNING: Flags Java 6 incompatible imports This is a warning. Id : `AssertjImport` Summary -: Flags Java 6 incompatible imports. +: Flags Java 6 incompatible imports Severity : Warning Category @@ -29,12 +29,19 @@ : Kotlin and Java files and test sources 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/kotlin/com/vanniktech/lintrules/android/AssertjDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AssertjDetectorTest.kt) Importing org.assertj.core.api.Assertions is not ideal. Since it can require Java 8. It's simple as instead org.assertj.core.api.Java6Assertions can be imported and provides guarantee to run on Java 6 as well. +!!! Tip + This lint check has an associated quickfix available in the IDE. + (##) Including !!! diff --git a/docs/checks/AuthLeak.md.html b/docs/checks/AuthLeak.md.html index cbe7629..fd94e61 100644 --- a/docs/checks/AuthLeak.md.html +++ b/docs/checks/AuthLeak.md.html @@ -40,13 +40,9 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/AuthDemo.java:2:Warning: Possible credential leak [AuthLeak] - private static final String AUTH_IP = "scheme://user:pwd@127.0.0.1:8000"; // WARN 1 --------------------------- - - src/AuthDemo.java:4:Warning: Possible credential leak [AuthLeak] - private static final String LEAK = "http://someuser:%restofmypass@example.com"; // WARN 2 ----------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AutoDispose.md.html b/docs/checks/AutoDispose.md.html index 5c9ac22..647b117 100644 --- a/docs/checks/AutoDispose.md.html +++ b/docs/checks/AutoDispose.md.html @@ -1,13 +1,13 @@ -(#) Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode. +(#) Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode -!!! ERROR: Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode. +!!! ERROR: Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode This is an error. Id : `AutoDispose` Summary -: Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode. +: Missing Disposable handling: Apply AutoDispose or cache the Disposable instance manually and enable lenient mode Severity : Error Category @@ -52,7 +52,6 @@ Observable.just(1).subscribe() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/foo/MyActivity.kt:12: Error: [AutoDispose] - Observable.just(2).subscribe() ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/AutoboxingStateCreation.md.html b/docs/checks/AutoboxingStateCreation.md.html index 627f135..cd6b813 100644 --- a/docs/checks/AutoboxingStateCreation.md.html +++ b/docs/checks/AutoboxingStateCreation.md.html @@ -58,7 +58,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/androidx/compose/runtime/lint/test/test.kt:8:Information: Prefer mutableStateOf instead of mutableStateOf [AutoboxingStateCreation] - val state = mutableStateOf<>() -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -95,17 +94,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -113,7 +112,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/AutoboxingStateValueProperty.md.html b/docs/checks/AutoboxingStateValueProperty.md.html index 4165d64..d158f40 100644 --- a/docs/checks/AutoboxingStateValueProperty.md.html +++ b/docs/checks/AutoboxingStateValueProperty.md.html @@ -54,7 +54,6 @@ src/androidx/compose/runtime/lint/test/test.kt:7:Warning: Reading value will cause an autoboxing operation. Use intValue to avoid unnecessary allocations. [AutoboxingStateValueProperty] - val value = state.value ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -90,17 +89,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -108,7 +107,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/Autofill.md.html b/docs/checks/Autofill.md.html index 9896898..30b2832 100644 --- a/docs/checks/Autofill.md.html +++ b/docs/checks/Autofill.md.html @@ -57,7 +57,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/autofill.xml:6:Warning: Missing autofillHints attribute [Autofill] - <EditText -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BackButton.md.html b/docs/checks/BackButton.md.html index 8da30d9..db805cc 100644 --- a/docs/checks/BackButton.md.html +++ b/docs/checks/BackButton.md.html @@ -50,12 +50,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/buttonbar.xml:183:Warning: Back buttons are not standard on Android; see design guide's navigation section [BackButton] - <Button ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/buttonbar.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -249,6 +248,25 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/buttonbar-values.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="button"> Button </string> + <string name="ok"> OK </string> + <string name="cancel"> Cancel </string> + <string name="resume"> OK </string> + <string name="giveup"> Cancel </string> + <string name="resume2"> Ok </string> + <string name="giveup2">"CANCEL"</string> + <string name="send"> Send </string> + <string name="abort">Abort</string> + <string name="goback">'Back'</string> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ButtonDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/BadConfigurationProvider.md.html b/docs/checks/BadConfigurationProvider.md.html index 2ac6a8f..5be8b65 100644 --- a/docs/checks/BadConfigurationProvider.md.html +++ b/docs/checks/BadConfigurationProvider.md.html @@ -44,6 +44,50 @@ `androidx.work.Configuration.Provider` for on-demand initialization. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/App.kt:Error: Expected Application subtype to implement +Configuration.Provider [BadConfigurationProvider] +1 errors, 0 warnings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`com/example/App.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import android.app.Application + +class App: Application() { + override fun onCreate() { + + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`com/example/CustomProvider.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import androidx.work.Configuration + +class Provider: Configuration.Provider { + override fun getWorkManagerConfiguration(): Configuration = TODO() +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/work-lint/src/test/java/androidx/work/lint/BadConfigurationProviderTest.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, `BadConfigurationProviderIssueDetector.testWithInvalidConfigurationProvider`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=409906. + (##) Including !!! diff --git a/docs/checks/BadHostnameVerifier.md.html b/docs/checks/BadHostnameVerifier.md.html index fb27f54..4473bcc 100644 --- a/docs/checks/BadHostnameVerifier.md.html +++ b/docs/checks/BadHostnameVerifier.md.html @@ -43,7 +43,6 @@ src/test/pkg/InsecureHostnameVerifier.java:9:Warning: verify always returns true, which could cause insecure network traffic due to trusting TLS/SSL server certificates for wrong hostnames [BadHostnameVerifier] - public boolean verify(String hostname, SSLSession session) { ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BatteryLife.md.html b/docs/checks/BatteryLife.md.html index 8414f8e..680dc4a 100644 --- a/docs/checks/BatteryLife.md.html +++ b/docs/checks/BatteryLife.md.html @@ -49,40 +49,37 @@ android.net.conn.CONNECTIVITY_CHANGE is deprecated for apps targeting N and higher. In general, apps should not rely on this broadcast and instead use WorkManager. [BatteryLife] - <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> ------------------------------------ - - AndroidManifest.xml:10:Warning: Use of REQUEST_IGNORE_BATTERY_OPTIMIZATIONS violates the Play Store Content Policy regarding acceptable use cases, as described in https://developer.android.com/training/monitoring-device-state/doze-standby.html [BatteryLife] - <action android:name="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> ----------------------------------------------------- - - AndroidManifest.xml:11:Warning: Use of com.android.camera.NEW_PICTURE is deprecated for all apps starting with the N release independent of the target SDK. Apps should not rely on these broadcasts and instead use WorkManager [BatteryLife] - <action android:name="com.android.camera.NEW_PICTURE" /> ------------------------------ - - AndroidManifest.xml:12:Warning: Use of android.hardware.action.NEW_PICTURE is deprecated for all apps starting with the N release independent of the target SDK. Apps should not rely on these broadcasts and instead use WorkManager [BatteryLife] - <action android:name="android.hardware.action.NEW_PICTURE" /> ----------------------------------- +src/test/pkg/BatteryTest.java:15:Warning: Use of +REQUEST_IGNORE_BATTERY_OPTIMIZATIONS violates the Play Store Content +Policy regarding acceptable use cases, as described in +https://developer.android.com/training/monitoring-device-state/doze-standby.html +[BatteryLife] + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -104,15 +101,33 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/BatteryTest.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.provider.Settings; + +@SuppressWarnings("unused") +public class BatteryTest extends Activity { + @TargetApi(Build.VERSION_CODES.M) + public void testNoNo() throws ActivityNotFoundException { + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + intent.setData(Uri.parse("package:my.pkg")); + startActivity(intent); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/BatteryDetectorTest.java) 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, `BatteryDetector.testConnectivityChange`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/BidiSpoofing.md.html b/docs/checks/BidiSpoofing.md.html index 62b25f5..d7f06f6 100644 --- a/docs/checks/BidiSpoofing.md.html +++ b/docs/checks/BidiSpoofing.md.html @@ -45,21 +45,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/StretchedString.java:5:Error: String contains misleading Unicode bidirectional text [BidiSpoofing] - if (accessLevel != "user‮ ⁦// Check if admin⁩ ⁦") { ----------------------------- - - src/CommentingOut.java:5:Error: Comment contains misleading Unicode bidirectional text [BidiSpoofing] - /*‮ } ⁦if (isAdmin)⁩ ⁦ begin admins only */ ------------------------------------------- - - src/CommentingOut.java:7:Error: Comment contains misleading Unicode bidirectional text [BidiSpoofing] - /* end admins only ‮ { ⁦*/ -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BinaryOperationInTimber.md.html b/docs/checks/BinaryOperationInTimber.md.html index 68b1444..ee534f0 100644 --- a/docs/checks/BinaryOperationInTimber.md.html +++ b/docs/checks/BinaryOperationInTimber.md.html @@ -45,12 +45,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/Example.java:6:Warning: Replace String concatenation with Timber's string formatting [BinaryOperationInTimber] - Timber.d(foo + "bar"); ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/foo/Example.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -64,6 +63,18 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/foo/Example.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import timber.log.Timber +class Example { + fun log() { + val foo = "foo" + Timber.d("${foo}bar") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://github.com/JakeWharton/timber/tree/trunk/timber-lint/src/test/java/timber/lint/WrongTimberUsageDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/BinderGetCallingInMainThread.md.html b/docs/checks/BinderGetCallingInMainThread.md.html index b45eeab..aca3341 100644 --- a/docs/checks/BinderGetCallingInMainThread.md.html +++ b/docs/checks/BinderGetCallingInMainThread.md.html @@ -41,14 +41,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/MyService.kt:10:Error: Binder.getCallingUid() should not be used inside onBind() [BinderGetCallingInMainThread] - Binder.getCallingUid() ---------------------- - - src/test/pkg/MyService.kt:11:Error: Binder.getCallingPid() should not be used inside onBind() [BinderGetCallingInMainThread] - Binder.getCallingPid() ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BindingReceiverParameter.md.html b/docs/checks/BindingReceiverParameter.md.html index 6d7b394..5f37757 100644 --- a/docs/checks/BindingReceiverParameter.md.html +++ b/docs/checks/BindingReceiverParameter.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -50,63 +50,38 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:12:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Int.bind(): Number --- - - src/foo/MyQualifier.kt:13:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Long.bind(): Number ---- - - src/foo/MyQualifier.kt:14:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Double.bind(): Number ------ - - src/foo/MyQualifier.kt:15:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Float.bind(): Number ----- - - src/foo/MyQualifier.kt:16:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Short.bind(): Number ----- - - src/foo/MyQualifier.kt:17:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Byte.bind(): Number ---- - - src/foo/MyQualifier.kt:18:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun Char.bind(): Comparable<Char> ---- - - src/foo/MyQualifier.kt:19:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun String.bind(): Comparable<String> ------ - - src/foo/MyQualifier.kt:20:Error: @Binds/@Provides functions cannot be extensions [BindingReceiverParameter] - @Binds fun @receiver:MyQualifier Boolean.bind(): Comparable<Boolean> ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BindingReturnType.md.html b/docs/checks/BindingReturnType.md.html index 89217c0..19c4c8a 100644 --- a/docs/checks/BindingReturnType.md.html +++ b/docs/checks/BindingReturnType.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -49,14 +49,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:14:Error: @Binds/@Provides must have a return type [BindingReturnType] - @Provides fun invalidBind3() { ^ - - src/foo/MyQualifier.kt:17:Error: @Binds/@Provides must have a return type [BindingReturnType] - @Provides fun invalidBind4(): Unit { ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BindsMustBeAbstract.md.html b/docs/checks/BindsMustBeAbstract.md.html index f62dc21..ec16d7c 100644 --- a/docs/checks/BindsMustBeAbstract.md.html +++ b/docs/checks/BindsMustBeAbstract.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -48,14 +48,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:12:Error: @Binds functions must be abstract [BindsMustBeAbstract] - @Binds fun invalidBind1(@MyQualifier real: Unit) ------------------------------------------------ - - src/foo/MyQualifier.kt:13:Error: @Binds functions must be abstract [BindsMustBeAbstract] - @Binds fun invalidBind2(@MyQualifier real: Unit): Unit ------------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BindsTypeMismatch.md.html b/docs/checks/BindsTypeMismatch.md.html index 1c6673d..6a7e3d2 100644 --- a/docs/checks/BindsTypeMismatch.md.html +++ b/docs/checks/BindsTypeMismatch.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -49,21 +49,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/TestModule.kt:18:Error: @Binds parameter/return must be type-assignable [BindsTypeMismatch] - @Binds fun invalidBind(real: Long): String ------------------------------------------ - - src/foo/TestModule.kt:19:Error: @Binds parameter/return must be type-assignable [BindsTypeMismatch] - @Binds fun invalidBind(real: Long): Comparable<Boolean> ------------------------------------------------------- - - src/foo/TestModule.kt:23:Error: @Binds parameter/return must be type-assignable [BindsTypeMismatch] - @Binds fun invalidComplexBinding(real: DetailTypeAItemMapper): ItemMapper<ItemDetail> ------------------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BindsWrongParameterCount.md.html b/docs/checks/BindsWrongParameterCount.md.html index 25dfa81..68f8c47 100644 --- a/docs/checks/BindsWrongParameterCount.md.html +++ b/docs/checks/BindsWrongParameterCount.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -48,14 +48,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyModule.kt:8:Error: @Binds must have one parameter [BindsWrongParameterCount] - @Binds fun invalidBind(real: Int, second: Int): Number ------------------------ - - src/foo/MyModule.kt:9:Error: @Binds must have one parameter [BindsWrongParameterCount] - @Binds fun invalidBind(): Number -------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BlockedPrivateApi.md.html b/docs/checks/BlockedPrivateApi.md.html index 11a40db..a768984 100644 --- a/docs/checks/BlockedPrivateApi.md.html +++ b/docs/checks/BlockedPrivateApi.md.html @@ -45,7 +45,6 @@ src/test/pkg/TestReflection.java:12:Error: Reflective access to NETWORK_TYPES is forbidden when targeting API 28 and above [BlockedPrivateApi] - Field deniedField = TelephonyManager.class.getDeclaredField("NETWORK_TYPES"); // ERROR 1 -------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/BomWithoutPlatform.md.html b/docs/checks/BomWithoutPlatform.md.html index f2ff833..0ce5678 100644 --- a/docs/checks/BomWithoutPlatform.md.html +++ b/docs/checks/BomWithoutPlatform.md.html @@ -40,33 +40,31 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:6:Warning: BOM should be added with a call to platform() [BomWithoutPlatform] - implementation(libs.compose.bom) ---------------- - - build.gradle:7:Warning: BOM should be added with a call to platform() [BomWithoutPlatform] - testImplementation(libs.compose.bom) ---------------- - - build.gradle:8:Warning: BOM should be added with a call to platform() [BomWithoutPlatform] - testImplementation "androidx.compose:compose-bom:2023.01.00" ----------------------------------------- - - build.gradle:9:Warning: BOM should be added with a call to platform() [BomWithoutPlatform] - api("androidx.compose:compose-bom:2023.01.00") ----------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/libs.versions.toml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~toml linenumbers +[versions] +composeBom = "2023.01.00" +[libraries] +compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `build.gradle`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers diff --git a/docs/checks/BottomAppBar.md.html b/docs/checks/BottomAppBar.md.html index 9621712..ea9c21a 100644 --- a/docs/checks/BottomAppBar.md.html +++ b/docs/checks/BottomAppBar.md.html @@ -38,12 +38,40 @@ res/layout/wrong1.xml:9:Error: This BottomAppBar must be wrapped in a CoordinatorLayout (android.support.design.widget.CoordinatorLayout) [BottomAppBar] - <android.support.design.bottomappbar.BottomAppBar ------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/layout/ok.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<androidx.coordinatorlayout.widget.CoordinatorLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="#eeeeee"> + + <com.google.android.material.bottomappbar.BottomAppBar + android:id="@+id/bottom_app_bar" + style="@style/Widget.MaterialComponents.BottomAppBar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + app:navigationIcon="@drawable/ic_menu_black_24dp"/> + + <com.google.android.material.floatingactionbutton.FloatingActionButton + android:id="@+id/fab" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:tint="@android:color/white" + app:layout_anchor="@id/bottom_app_bar" + app:srcCompat="@drawable/ic_add_black_24dp" + tools:ignore="RtlHardcoded"/> +</androidx.coordinatorlayout.widget.CoordinatorLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/layout/wrong1.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -66,6 +94,19 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/wrong2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers + <com.google.android.material.bottomappbar.BottomAppBar + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/bottom_app_bar" + style="@style/Widget.MaterialComponents.BottomAppBar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" +app:navigationIcon="@drawable/ic_menu_black_24dp"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/BottomAppBarDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/BrokenIterator.md.html b/docs/checks/BrokenIterator.md.html index 531226f..7e2ab19 100644 --- a/docs/checks/BrokenIterator.md.html +++ b/docs/checks/BrokenIterator.md.html @@ -61,48 +61,35 @@ LinkedHashMap#spliterator was broken in API 24 and 25. Workaround: Use java.util.Spliterators.spliterator(c2a, c2a.spliterator().characteristics()) [BrokenIterator] - Spliterator<String> keys2a = c2a.spliterator(); // Warn ----------------- - - src/test/pkg/LinkedHashmapTest.java:35:Warning: LinkedHashMap#spliterator was broken in API 24 and 25. Workaround: Use java.util.Spliterators.spliterator(c2b, c2b.spliterator().characteristics()) [BrokenIterator] - Spliterator<String> keys2b = c2b.spliterator(); // Warn ----------------- - - src/test/pkg/LinkedHashmapTest.java:36:Warning: LinkedHashMap#spliterator was broken in API 24 and 25. Workaround: Use java.util.Spliterators.spliterator(c2c, c2c.spliterator().characteristics()) [BrokenIterator] - Spliterator<Entry<String, String>> keys2c = c2c.spliterator(); // Warn ----------------- - - src/test/pkg/LinkedHashmapTest.java:39:Warning: LinkedHashMap#stream was broken in API 24 and 25. Workaround: Use java.util.stream.StreamSupport.stream(spliterator, false) [BrokenIterator] - Stream<String> stream1 = c2a.stream(); // Warn ------------ - - src/test/pkg/LinkedHashmapTest.java:40:Warning: LinkedHashMap#spliterator was broken in API 24 and 25. Workaround: Use java.util.Spliterators.spliterator(c2a, c2a.spliterator().characteristics()) [BrokenIterator] - StreamSupport.stream(c2a.spliterator(), false); // Warn ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/LinkedHashmapTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -153,6 +140,46 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/LinkedHashmapTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.os.Build +import androidx.annotation.RequiresApi +import java.util.* +import java.util.stream.StreamSupport + +class LinkedHashmapTest { + @RequiresApi(api = Build.VERSION_CODES.N) + fun test() { + val map1 = HashMap() + val c1a = map1.keys + val c1b = map1.values + val c1c = map1.entries + val keys1a = c1a.spliterator() + val keys1b = c1b.spliterator() + val keys1c = c1c.spliterator() // OK (not a LinkedHashMap) + val keys1 = Spliterators.spliterator(c1a, c1a.spliterator().characteristics())// OK + + val map2 = LinkedHashMap() + val c2a = map2.keys + val c2b = map2.values + val c2c = map2.entries + + val keys2a = c2a.spliterator() // Warn + val keys2b = c2b.spliterator() // Warn + val keys2c = c2c.spliterator() // Warn + val keys2 = Spliterators.spliterator(c2a, c2a.spliterator().characteristics())// OK + + val stream1 = c2a.stream() // Warn + StreamSupport.stream(c2a.spliterator(), false) // Warn + + Spliterators.spliterator(c2a, c2a.spliterator().characteristics()) // OK + StreamSupport.stream(keys2, false) // OK + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/IteratorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/BuildListAdds.md.html b/docs/checks/BuildListAdds.md.html index be7c68c..e318b17 100644 --- a/docs/checks/BuildListAdds.md.html +++ b/docs/checks/BuildListAdds.md.html @@ -38,7 +38,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/Cubic.kt:4:Warning: No add calls within buildList lambda; this is usually a mistake [BuildListAdds] - return buildList { // ERROR --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -52,15 +51,7 @@ fun asCubics_broken(progress: Float): List { return buildList { // ERROR for (i in _morphMatch.indices) { - Cubic(i) - } - } -} - -fun asCubics_correct(progress: Float): List { - return buildList { // OK - for (i in _morphMatch.indices) { - add(Cubic(i)) + Cubic(i) // ERROR: Should have been wrapped in an add call. } } } diff --git a/docs/checks/ButtonCase.md.html b/docs/checks/ButtonCase.md.html index 30acb18..4641c67 100644 --- a/docs/checks/ButtonCase.md.html +++ b/docs/checks/ButtonCase.md.html @@ -40,20 +40,208 @@ res/values/buttonbar-values.xml:9:Warning: The standard Android way to capitalize Ok is "OK" (tip: use @android:string/ok instead) [ButtonCase] - <string name="resume2"> Ok </string> -- - - res/values/buttonbar-values.xml:10:Warning: The standard Android way to capitalize CANCEL is "Cancel" (tip: use @android:string/cancel instead) [ButtonCase] - <string name="giveup2">"CANCEL"</string> -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/layout/buttonbar.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <!-- Hardcoded strings, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="OK" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Cancel" /> + </LinearLayout> + + <!-- Hardcoded strings, right order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Cancel" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="OK" /> + </LinearLayout> + + <!-- @android:string resources, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@android:string/ok" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@android:string/cancel" /> + </LinearLayout> + + <!-- @android:string resources, right order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@android:string/cancel" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@android:string/ok" /> + </LinearLayout> + + <!-- @string/ok/cancel resources, right order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/cancel" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/ok" /> + </LinearLayout> + + <!-- @string/ok/cancel resources, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/ok" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/cancel" /> + </LinearLayout> + + <!-- Random name resources, right order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/giveup" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/resume" /> + </LinearLayout> + + <!-- Random name resources, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/resume" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/giveup" /> + </LinearLayout> + + <!-- Random name resources with varying case, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/resume2" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/giveup2" /> + </LinearLayout> + + <!-- Resources with only one of OK and Cancel, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/ok" /> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/abort" /> + </LinearLayout> + + <!-- Resources with only one of OK and Cancel, wrong order --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <Button + android:layout_width="wrap_content" android:background="?android:attr/selectableItemBackground" + android:layout_height="wrap_content" + android:text="@string/send" /> + + <Button + android:layout_width="wrap_content" android:background="?android:attr/selectableItemBackground" + android:layout_height="wrap_content" + android:text="@string/cancel" /> + </LinearLayout> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/goback" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values/buttonbar-values.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers diff --git a/docs/checks/ButtonOrder.md.html b/docs/checks/ButtonOrder.md.html index 0240ec1..0c53e57 100644 --- a/docs/checks/ButtonOrder.md.html +++ b/docs/checks/ButtonOrder.md.html @@ -50,54 +50,35 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/buttonbar.xml:12:Warning: OK button should be on the right (was "OK | Cancel", should be "Cancel | OK") [ButtonOrder] - <Button ------ - - res/layout/buttonbar.xml:44:Warning: OK button should be on the right (was "OK | Cancel", should be "Cancel | OK") [ButtonOrder] - <Button ------ - - res/layout/buttonbar.xml:92:Warning: OK button should be on the right (was "OK | Cancel", should be "Cancel | OK") [ButtonOrder] - <Button ------ - - res/layout/buttonbar.xml:124:Warning: OK button should be on the right (was "OK | Cancel", should be "Cancel | OK") [ButtonOrder] - <Button ------ - - res/layout/buttonbar.xml:140:Warning: OK button should be on the right (was "Ok | CANCEL", should be "CANCEL | Ok") [ButtonOrder] - <Button ------ - - res/layout/buttonbar.xml:156:Warning: OK button should be on the right (was "OK | Abort", should be "Abort | OK") [ButtonOrder] - <Button ------ - - res/layout/buttonbar.xml:177:Warning: Cancel button should be on the left (was "Send | Cancel", should be "Cancel | Send") [ButtonOrder] - <Button ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/buttonbar.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -291,6 +272,25 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/buttonbar-values.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="button"> Button </string> + <string name="ok"> OK </string> + <string name="cancel"> Cancel </string> + <string name="resume"> OK </string> + <string name="giveup"> Cancel </string> + <string name="resume2"> Ok </string> + <string name="giveup2">"CANCEL"</string> + <string name="send"> Send </string> + <string name="abort">Abort</string> + <string name="goback">'Back'</string> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ButtonDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ButtonStyle.md.html b/docs/checks/ButtonStyle.md.html index edef8b4..dd15c0d 100644 --- a/docs/checks/ButtonStyle.md.html +++ b/docs/checks/ButtonStyle.md.html @@ -46,164 +46,106 @@ res/layout/buttonbar.xml:12:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:17:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:28:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:33:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:44:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:49:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:60:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:65:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:76:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:81:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:92:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:97:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:108:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:113:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:124:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:129:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:140:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:145:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:156:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ - - res/layout/buttonbar.xml:161:Warning: Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle] - <Button ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/buttonbar.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -397,6 +339,120 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/buttonbar2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" > + + <ProgressBar + android:id="@+id/loading_progress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:layout_marginBottom="60dip" + android:layout_marginLeft="40dip" + android:layout_marginTop="40dip" + android:max="10000" /> + + <TextView + android:id="@+id/text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_alignWithParentIfMissing="true" + android:layout_marginBottom="60dip" + android:layout_marginLeft="40dip" + android:layout_marginTop="40dip" + android:layout_toRightOf="@id/loading_progress" + android:ellipsize="end" + android:maxLines="3" + android:paddingRight="120dip" + android:text="@string/creating_instant_mix" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <Button + android:id="@+id/cancel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignRight="@id/text" + android:layout_below="@id/text" + android:background="@null" + android:text="@string/cancel" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@id/cancel" + android:layout_alignLeft="@id/cancel" + android:layout_alignRight="@id/cancel" + android:scaleType="fitXY" + android:src="@drawable/menu_list_divider" /> + +</RelativeLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/buttonbar3.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:text="@string/weekpicker_title" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="#ffffff" + android:padding="6dip" > + + <Button + android:id="@+id/set" + android:layout_width="120dip" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:text="@string/weekpicker_set" /> + + <Button + android:id="@+id/cancel" + android:layout_width="120dip" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:text="@string/cancel" /> + </RelativeLayout> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/buttonbar-values.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="button"> Button </string> + <string name="ok"> OK </string> + <string name="cancel"> Cancel </string> + <string name="resume"> OK </string> + <string name="giveup"> Cancel </string> + <string name="resume2"> Ok </string> + <string name="giveup2">"CANCEL"</string> + <string name="send"> Send </string> + <string name="abort">Abort</string> + <string name="goback">'Back'</string> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ButtonDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ByteOrderMark.md.html b/docs/checks/ByteOrderMark.md.html index 31ec3b6..2ed8f21 100644 --- a/docs/checks/ByteOrderMark.md.html +++ b/docs/checks/ByteOrderMark.md.html @@ -48,12 +48,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:1:Error: Found byte-order-mark in the middle of a file [ByteOrderMark] - <manifest package='foo.bar'> - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -61,6 +60,49 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-zh-rCN/bom.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:tools="http://schemas.android.com/tools"> + <string name="hanping_chinese_lite_app_name">(Translated name)</string> + <string tools:ignore='ByteOrderMark' name="something">testtest2</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/raw/bom_allowed.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:tools="http://schemas.android.com/tools"> + <string name="hanping_chinese_lite_app_name">(Translated name)</string> + <string tools:ignore='ByteOrderMark' name="something">testtest2</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyTest.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; +import android.annotation.SuppressLint; +public class MyTest { + public void test1() { + String s = "\uFEFF"; // OK + String t = ""; // ERROR + } + @SuppressLint("ByteOrderMark") + public void test2() { + String s = ""; //OK/suppressed + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`proguard.cfg`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~proguard linenumbers +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ByteOrderMarkDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/CanvasSize.md.html b/docs/checks/CanvasSize.md.html index e709295..c87bf02 100644 --- a/docs/checks/CanvasSize.md.html +++ b/docs/checks/CanvasSize.md.html @@ -56,35 +56,25 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/MyCustomView1.java:27:Warning: Calling Canvas.getWidth() is usually wrong; you should be calling getWidth() instead [CanvasSize] - int width4 = canvas.getWidth(); // WARN ----------------- - - src/test/pkg/MyCustomView1.java:28:Warning: Calling Canvas.getHeight() is usually wrong; you should be calling getHeight() instead [CanvasSize] - int height4 = canvas.getHeight(); // WARN ------------------ - - src/test/pkg/MyCustomView1.java:34:Warning: Calling Canvas.getWidth() is usually wrong; you should be calling getWidth() instead [CanvasSize] - int width4 = canvas.getWidth(); // WARN ----------------- - - src/test/pkg/MyCustomView1.java:35:Warning: Calling Canvas.getHeight() is usually wrong; you should be calling getHeight() instead [CanvasSize] - int height4 = canvas.getHeight(); // WARN ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyCustomView1.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -132,6 +122,66 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyCustomView2.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Canvas +import android.os.Build +import android.util.AttributeSet +import android.view.View + +@SuppressLint("ViewConstructor") +class MyCustomView2(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : View(context, attrs, defStyleAttr, defStyleRes) { + + override fun onDraw(canvas: Canvas) { + val view = this + val width3 = view.width // OK + val height3 = view.height // OK + val width4 = canvas.width // WARN + val height4 = canvas.height // WARN + val width5 = canvas.getWidth() // WARN + val height5 = canvas.getHeight() // WARN + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyDrawable.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; + +@SuppressWarnings({"unused", "ClassNameDiffersFromFileName","MethodMayBeStatic", "NullableProblems"}) +public abstract class MyDrawable extends Drawable { + @Override + public void draw(Canvas canvas) { + int width1 = getBounds().width(); // OK + int width2 = canvas.getWidth(); // WARN + int height2 = canvas.getHeight(); // WARN + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyDrawable.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.graphics.Canvas +import android.graphics.drawable.Drawable + +abstract class MyDrawable : Drawable() { + override fun draw(canvas: Canvas) { + val width1 = bounds.width() // OK + val width2 = canvas.width // WARN + val height2 = canvas.height // WARN + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/CanvasSizeDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/CastingViewContextToActivity.md.html b/docs/checks/CastingViewContextToActivity.md.html index 9190533..e7aab05 100644 --- a/docs/checks/CastingViewContextToActivity.md.html +++ b/docs/checks/CastingViewContextToActivity.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/ViewContextDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/ViewContextDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/ViewContextDetectorTest.kt) Copyright Year diff --git a/docs/checks/CheckResult.md.html b/docs/checks/CheckResult.md.html index 62908f1..e297152 100644 --- a/docs/checks/CheckResult.md.html +++ b/docs/checks/CheckResult.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/test.kt:10:Warning: The result of double is not used [CheckResult] - score.double() -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ChromeOsAbiSupport.md.html b/docs/checks/ChromeOsAbiSupport.md.html index 8db74d9..605bf7b 100644 --- a/docs/checks/ChromeOsAbiSupport.md.html +++ b/docs/checks/ChromeOsAbiSupport.md.html @@ -47,7 +47,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:10:Warning: Missing x86_64 ABI support for ChromeOS [ChromeOsAbiSupport] - abiFilters 'arm64-v8a' ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ChromeOsOnConfigurationChanged.md.html b/docs/checks/ChromeOsOnConfigurationChanged.md.html index 14904cf..34a6ec8 100644 --- a/docs/checks/ChromeOsOnConfigurationChanged.md.html +++ b/docs/checks/ChromeOsOnConfigurationChanged.md.html @@ -46,7 +46,6 @@ src/test/pkg/MainActivity.java:19:Warning: Calling finish() within onConfigurationChanged() can lead to redraws [ChromeOsOnConfigurationChanged] - finish(); // ERROR 1 -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ClickableViewAccessibility.md.html b/docs/checks/ClickableViewAccessibility.md.html index 0757959..9017748 100644 --- a/docs/checks/ClickableViewAccessibility.md.html +++ b/docs/checks/ClickableViewAccessibility.md.html @@ -43,7 +43,6 @@ src/test/pkg/ClickableViewAccessibilityTest.java:15:Warning: Custom view ViewOverridesOnTouchEventButNotPerformClick overrides onTouchEvent but not performClick [ClickableViewAccessibility] - public boolean onTouchEvent(MotionEvent event) { ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CoarseFineLocation.md.html b/docs/checks/CoarseFineLocation.md.html index 68daa28..fce521a 100644 --- a/docs/checks/CoarseFineLocation.md.html +++ b/docs/checks/CoarseFineLocation.md.html @@ -41,7 +41,6 @@ AndroidManifest.xml:3:Error: If you need access to FINE location, you must request both ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION [CoarseFineLocation] - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> ------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ColorCasing.md.html b/docs/checks/ColorCasing.md.html index a7028c5..fe7a90c 100644 --- a/docs/checks/ColorCasing.md.html +++ b/docs/checks/ColorCasing.md.html @@ -1,13 +1,13 @@ -(#) Raw colors should be defined with uppercase letters. +(#) Raw colors should be defined with uppercase letters -!!! WARNING: Raw colors should be defined with uppercase letters. +!!! WARNING: Raw colors should be defined with uppercase letters This is a warning. Id : `ColorCasing` Summary -: Raw colors should be defined with uppercase letters. +: Raw colors should be defined with uppercase letters Severity : Warning Category @@ -29,10 +29,44 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/ColorCasingDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ColorCasingDetectorTest.kt) Colors should have uppercase letters. #FF0099 is valid while #ff0099 isn't since the ff should be written in uppercase. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/layout.xml:2:Warning: Should be using uppercase letters +[ColorCasing] + tools:textColor="#fff"/> + ---- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView xmlns:tools="http://schemas.android.com/tools" + tools:textColor="#fff"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ColorCasingDetectorTest.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, `ColorCasingDetector.lowercaseColor`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/CommitPrefEdits.md.html b/docs/checks/CommitPrefEdits.md.html index 7995b18..0c6ef8f 100644 --- a/docs/checks/CommitPrefEdits.md.html +++ b/docs/checks/CommitPrefEdits.md.html @@ -41,14 +41,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/SharedPrefsTest.java:54:Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits] - SharedPreferences.Editor editor = preferences.edit(); ------------------ - - src/test/pkg/SharedPrefsTest.java:62:Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits] - SharedPreferences.Editor editor = preferences.edit(); ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CommitTransaction.md.html b/docs/checks/CommitTransaction.md.html index 4f4cf0a..6feb688 100644 --- a/docs/checks/CommitTransaction.md.html +++ b/docs/checks/CommitTransaction.md.html @@ -38,42 +38,26 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/CommitTest.java:25:Warning: This transaction should be completed with a commit() call [CommitTransaction] - getFragmentManager().beginTransaction(); // ERROR 1 ---------------- - - src/test/pkg/CommitTest.java:30:Warning: This transaction should be completed with a commit() call [CommitTransaction] - FragmentTransaction transaction2 = getFragmentManager().beginTransaction(); // ERROR 2 ---------------- - - src/test/pkg/CommitTest.java:39:Warning: This transaction should be completed with a commit() call [CommitTransaction] - getFragmentManager().beginTransaction(); // ERROR 3 ---------------- - - src/test/pkg/CommitTest.java:65:Warning: This transaction should be completed with a commit() call [CommitTransaction] - getSupportFragmentManager().beginTransaction(); // ERROR 4 ---------------- - - src/test/pkg/CommitTest.java:123:Warning: This transaction should be completed with a commit() call [CommitTransaction] - transaction = getFragmentManager().beginTransaction(); // ERROR 5 ---------------- - - src/test/pkg/CommitTest.java:132:Warning: This transaction should be completed with a commit() call [CommitTransaction] - transaction = getFragmentManager().beginTransaction(); // ERROR 6 ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposableDestinationInComposeScope.md.html b/docs/checks/ComposableDestinationInComposeScope.md.html deleted file mode 100644 index 2837cb2..0000000 --- a/docs/checks/ComposableDestinationInComposeScope.md.html +++ /dev/null @@ -1,180 +0,0 @@ - -(#) Building composable destination in compose scope - -!!! ERROR: Building composable destination in compose scope - This is an error. - -Id -: `ComposableDestinationInComposeScope` -Summary -: Building composable destination in compose scope -Severity -: Error -Category -: Correctness -Platform -: Any -Vendor -: Jetpack Navigation Compose -Identifier -: androidx.navigation.compose -Min -: Lint 7.0 -Compiled -: Lint 8.0 and 8.1 -Artifact -: [androidx.navigation:navigation-compose](androidx_navigation_navigation-compose.md.html) - -Affects -: Kotlin and Java files and test sources -Editing -: This check runs on the fly in the IDE editor -Implementation -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-compose-lint/src/main/java/androidx/navigation/compose/lint/ComposableDestinationInComposeScopeDetector.kt) -Tests -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-compose-lint/src/test/java/androidx/navigation/compose/lint/ComposableDestinationInComposeScopeDetectorTest.kt) -Copyright Year -: 2021 - -Composable destinations should only be constructed directly within a -NavGraphBuilder scope. Composable destinations cannot not be nested, and -you should use the `navigation` function to create a nested graph -instead. - -(##) Example - -Here is an example of lint warnings produced by this check: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/com/example/test.kt:13:Error: Using composable inside of a compose -scope [ComposableDestinationInComposeScope] - - composable("wrong") { } - ---------- -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here is the source file referenced above: - -`src/com/example/test.kt`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers -package com.example - -import androidx.compose.runtime.* -import androidx.navigation.compose.composable -import androidx.navigation.compose.NavHost -import androidx.navigation.NavGraphBuilder - -@Composable -fun Test() { - NavHost("host") { - composable("right") { - composable("wrong") { } - } - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can also visit the -[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-compose-lint/src/test/java/androidx/navigation/compose/lint/ComposableDestinationInComposeScopeDetectorTest.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, `ComposableDestinationInComposeScopeDetector.nestedComposableBuilders`. -To report a problem with this extracted sample, contact -Jetpack Navigation Compose. - -(##) Including - -!!! - This is not a built-in check. To include it, add the below dependency - to your project. - -``` -// build.gradle.kts -implementation("androidx.navigation:navigation-compose:2.8.0-beta01") - -// build.gradle -implementation 'androidx.navigation:navigation-compose:2.8.0-beta01' - -// build.gradle.kts with version catalogs: -implementation(libs.navigation-compose) - -# libs.versions.toml -[versions] -navigation-compose = "2.8.0-beta01" -[libraries] -navigation-compose = { - module = "androidx.navigation:navigation-compose", - version.ref = "navigation-compose" -} -``` - -2.8.0-beta01 is the version this documentation was generated from; -there may be newer versions available. - -[Additional details about androidx.navigation:navigation-compose](androidx_navigation_navigation-compose.md.html). -(##) 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("ComposableDestinationInComposeScope") - fun method() { - composable(...) - } - ``` - - or - - ```java - // Java - @SuppressWarnings("ComposableDestinationInComposeScope") - void method() { - composable(...); - } - ``` - -* Using a suppression comment like this on the line above: - - ```kt - //noinspection ComposableDestinationInComposeScope - problematicStatement() - ``` - -* 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="ComposableDestinationInComposeScope" 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 'ComposableDestinationInComposeScope' - } - ``` - In Android projects this should be nested inside an `android { }` - block. - -* For manual invocations of `lint`, using the `--ignore` flag: - ``` - $ lint --ignore ComposableDestinationInComposeScope ...` - ``` - -* Last, but not least, using baselines, as discussed - [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). - - \ No newline at end of file diff --git a/docs/checks/ComposableLambdaParameterNaming.md.html b/docs/checks/ComposableLambdaParameterNaming.md.html index bb3510a..95c1698 100644 --- a/docs/checks/ComposableLambdaParameterNaming.md.html +++ b/docs/checks/ComposableLambdaParameterNaming.md.html @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/androidx/compose/ui/foo/test.kt:7:Warning: Composable lambda parameter should be named content [ComposableLambdaParameterNaming] - fun Button(foo: Int, text: @Composable () -> Unit) { ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -85,17 +84,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -103,7 +102,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/ComposableLambdaParameterPosition.md.html b/docs/checks/ComposableLambdaParameterPosition.md.html index 06dbf8e..70f4526 100644 --- a/docs/checks/ComposableLambdaParameterPosition.md.html +++ b/docs/checks/ComposableLambdaParameterPosition.md.html @@ -51,7 +51,6 @@ src/androidx/compose/ui/foo/test.kt:7:Warning: Composable lambda parameter should be the last parameter so it can be used as a trailing lambda [ComposableLambdaParameterPosition] - fun Button(content: @Composable () -> Unit, foo: Int) { ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -87,17 +86,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -105,7 +104,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/ComposableNaming.md.html b/docs/checks/ComposableNaming.md.html index e6a226d..bee510d 100644 --- a/docs/checks/ComposableNaming.md.html +++ b/docs/checks/ComposableNaming.md.html @@ -53,7 +53,6 @@ src/androidx/compose/runtime/foo/test.kt:7:Warning: Composable functions that return Unit should start with an uppercase letter [ComposableNaming] - fun button() {} ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -87,17 +86,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -105,7 +104,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/ComposableNavGraphInComposeScope.md.html b/docs/checks/ComposableNavGraphInComposeScope.md.html deleted file mode 100644 index 47f38ec..0000000 --- a/docs/checks/ComposableNavGraphInComposeScope.md.html +++ /dev/null @@ -1,179 +0,0 @@ - -(#) Building navigation graph in compose scope - -!!! ERROR: Building navigation graph in compose scope - This is an error. - -Id -: `ComposableNavGraphInComposeScope` -Summary -: Building navigation graph in compose scope -Severity -: Error -Category -: Correctness -Platform -: Any -Vendor -: Jetpack Navigation Compose -Identifier -: androidx.navigation.compose -Min -: Lint 7.0 -Compiled -: Lint 8.0 and 8.1 -Artifact -: [androidx.navigation:navigation-compose](androidx_navigation_navigation-compose.md.html) - -Affects -: Kotlin and Java files and test sources -Editing -: This check runs on the fly in the IDE editor -Implementation -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-compose-lint/src/main/java/androidx/navigation/compose/lint/ComposableDestinationInComposeScopeDetector.kt) -Tests -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-compose-lint/src/test/java/androidx/navigation/compose/lint/ComposableDestinationInComposeScopeDetectorTest.kt) -Copyright Year -: 2021 - -Composable destinations should only be constructed directly within a -NavGraphBuilder scope. - -(##) Example - -Here is an example of lint warnings produced by this check: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/com/example/test.kt:14:Error: Using navigation inside of a compose -scope [ComposableNavGraphInComposeScope] - - navigation("wrong") { } - ---------- -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here is the source file referenced above: - -`src/com/example/test.kt`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers -package com.example - -import androidx.compose.runtime.* -import androidx.navigation.compose.composable -import androidx.navigation.compose.navigation -import androidx.navigation.compose.NavHost -import androidx.navigation.NavGraphBuilder - -@Composable -fun Test() { - NavHost("host") { - composable("right") { - navigation("wrong") { } - } - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can also visit the -[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-compose-lint/src/test/java/androidx/navigation/compose/lint/ComposableDestinationInComposeScopeDetectorTest.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, `ComposableDestinationInComposeScopeDetector.navigationBuilderInsideComposable`. -To report a problem with this extracted sample, contact -Jetpack Navigation Compose. - -(##) Including - -!!! - This is not a built-in check. To include it, add the below dependency - to your project. - -``` -// build.gradle.kts -implementation("androidx.navigation:navigation-compose:2.8.0-beta01") - -// build.gradle -implementation 'androidx.navigation:navigation-compose:2.8.0-beta01' - -// build.gradle.kts with version catalogs: -implementation(libs.navigation-compose) - -# libs.versions.toml -[versions] -navigation-compose = "2.8.0-beta01" -[libraries] -navigation-compose = { - module = "androidx.navigation:navigation-compose", - version.ref = "navigation-compose" -} -``` - -2.8.0-beta01 is the version this documentation was generated from; -there may be newer versions available. - -[Additional details about androidx.navigation:navigation-compose](androidx_navigation_navigation-compose.md.html). -(##) 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("ComposableNavGraphInComposeScope") - fun method() { - composable(...) - } - ``` - - or - - ```java - // Java - @SuppressWarnings("ComposableNavGraphInComposeScope") - void method() { - composable(...); - } - ``` - -* Using a suppression comment like this on the line above: - - ```kt - //noinspection ComposableNavGraphInComposeScope - problematicStatement() - ``` - -* 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="ComposableNavGraphInComposeScope" 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 'ComposableNavGraphInComposeScope' - } - ``` - In Android projects this should be nested inside an `android { }` - block. - -* For manual invocations of `lint`, using the `--ignore` flag: - ``` - $ lint --ignore ComposableNavGraphInComposeScope ...` - ``` - -* Last, but not least, using baselines, as discussed - [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). - - \ No newline at end of file diff --git a/docs/checks/ComposeComposableModifier.md.html b/docs/checks/ComposeComposableModifier.md.html index 65942a0..1ea2c3e 100644 --- a/docs/checks/ComposeComposableModifier.md.html +++ b/docs/checks/ComposeComposableModifier.md.html @@ -55,18 +55,14 @@ the modifier instance, rather than the whole function tree.See https://slackhq.github.io/compose-lints/rules/#avoid-modifier-extension-factory-functions for more information. [ComposeComposableModifier] - @Composable ^ - - src/test.kt:6:Error: Using @Composable builder functions for modifiers is not recommended, as they cause unnecessary recompositions.You should use the Modifier.Node API instead, as it limits recomposition to just the modifier instance, rather than the whole function tree.See https://slackhq.github.io/compose-lints/rules/#avoid-modifier-extension-factory-functions for more information. [ComposeComposableModifier] - @Composable ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeCompositionLocalGetter.md.html b/docs/checks/ComposeCompositionLocalGetter.md.html index 799925d..ed0188f 100644 --- a/docs/checks/ComposeCompositionLocalGetter.md.html +++ b/docs/checks/ComposeCompositionLocalGetter.md.html @@ -68,15 +68,11 @@ src/test.kt:2:Error: `CompositionLocal`s should be singletons and not use getters. Otherwise a new instance will be returned every call. [ComposeCompositionLocalGetter] - val LocalBanana get() = compositionLocalOf { "Prune" } --- - - src/test.kt:3:Error: `CompositionLocal`s should be singletons and not use getters. Otherwise a new instance will be returned every call. [ComposeCompositionLocalGetter] - val LocalPotato get() { --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeCompositionLocalUsage.md.html b/docs/checks/ComposeCompositionLocalUsage.md.html index 81405cb..b8a7de8 100644 --- a/docs/checks/ComposeCompositionLocalUsage.md.html +++ b/docs/checks/ComposeCompositionLocalUsage.md.html @@ -71,34 +71,24 @@ creating new ones should be avoided. See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage] - private val LocalApple = staticCompositionLocalOf<String> { "Apple" } --------------------------------------------------------------------- - - src/test.kt:3:Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided. See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage] - internal val LocalPlum: String = staticCompositionLocalOf { "Plum" } -------------------------------------------------------------------- - - src/test.kt:4:Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided. See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage] - val LocalPrune = compositionLocalOf { "Prune" } ----------------------------------------------- - - src/test.kt:5:Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided. See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage] - private val LocalKiwi: String = compositionLocalOf { "Kiwi" } ------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeContentEmitterReturningValues.md.html b/docs/checks/ComposeContentEmitterReturningValues.md.html index 8403a7c..501f5cf 100644 --- a/docs/checks/ComposeContentEmitterReturningValues.md.html +++ b/docs/checks/ComposeContentEmitterReturningValues.md.html @@ -77,11 +77,8 @@ function by the caller.See https://slackhq.github.io/compose-lints/rules/#do-not-emit-content-and-return-a-result for more information. [ComposeContentEmitterReturningValues] - @Composable ^ - - src/test.kt:8:Error: Composable functions should either emit content into the composition or return a value, but not both.If a composable should offer additional control surfaces to its caller, those control @@ -89,7 +86,6 @@ function by the caller.See https://slackhq.github.io/compose-lints/rules/#do-not-emit-content-and-return-a-result for more information. [ComposeContentEmitterReturningValues] - @Composable ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeM2Api.md.html b/docs/checks/ComposeM2Api.md.html index 1fdd8c2..e005072 100644 --- a/docs/checks/ComposeM2Api.md.html +++ b/docs/checks/ComposeM2Api.md.html @@ -89,34 +89,24 @@ (M3). Please use M3 APIs.See https://slackhq.github.io/compose-lints/rules/#use-material-3 for more information. [ComposeM2Api] - Text("Hello, world!") --------------------- - - src/test.kt:23:Error: Compose Material 2 (M2) is succeeded by Material 3 (M3). Please use M3 APIs.See https://slackhq.github.io/compose-lints/rules/#use-material-3 for more information. [ComposeM2Api] - Text("Hello, world!") --------------------- - - src/test.kt:24:Error: Compose Material 2 (M2) is succeeded by Material 3 (M3). Please use M3 APIs.See https://slackhq.github.io/compose-lints/rules/#use-material-3 for more information. [ComposeM2Api] - val elevation = BottomNavigationDefaults.Elevation ---------------------------------- - - src/test.kt:25:Error: Compose Material 2 (M2) is succeeded by Material 3 (M3). Please use M3 APIs.See https://slackhq.github.io/compose-lints/rules/#use-material-3 for more information. [ComposeM2Api] - val drawerValue = BottomDrawerValue.Closed ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeModifierComposed.md.html b/docs/checks/ComposeModifierComposed.md.html index 6bb24ac..5f0b61f 100644 --- a/docs/checks/ComposeModifierComposed.md.html +++ b/docs/checks/ComposeModifierComposed.md.html @@ -54,33 +54,37 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:6:Error: Modifier.composed { ... } is no longer recommended due to performance issues. - You should use the Modifier.Node API instead, as it was designed from the ground up to be far more performant than composed modifiers. - See https://slackhq.github.io/compose-lints/rules/#migrate-to-modifiernode for more information. [ComposeModifierComposed] - fun Modifier.something1() = Modifier.composed { } --------------------- - - src/test/test.kt:7:Error: Modifier.composed { ... } is no longer recommended due to performance issues. - You should use the Modifier.Node API instead, as it was designed from the ground up to be far more performant than composed modifiers. - See https://slackhq.github.io/compose-lints/rules/#migrate-to-modifiernode for more information. [ComposeModifierComposed] - fun Modifier.something2() = composed { } ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`test/androidx/compose/ui/ComposedModifier.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package androidx.compose.ui + +fun Modifier.composed( + inspectorInfo: InspectorInfo.() -> Unit = NoInspectorInfo, + factory: Modifier.() -> Modifier +): Modifier { + TODO() +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/ComposeModifierMissing.md.html b/docs/checks/ComposeModifierMissing.md.html index 7c7d7f3..70c9856 100644 --- a/docs/checks/ComposeModifierMissing.md.html +++ b/docs/checks/ComposeModifierMissing.md.html @@ -88,25 +88,18 @@ have a modifier parameter.See https://slackhq.github.io/compose-lints/rules/#when-should-i-expose-modifier-parameters for more information. [ComposeModifierMissing] - fun Something1() { ---------- - - src/test.kt:10:Error: This @Composable function emits content but doesn't have a modifier parameter.See https://slackhq.github.io/compose-lints/rules/#when-should-i-expose-modifier-parameters for more information. [ComposeModifierMissing] - fun Something2() { ---------- - - src/test.kt:15:Error: This @Composable function emits content but doesn't have a modifier parameter.See https://slackhq.github.io/compose-lints/rules/#when-should-i-expose-modifier-parameters for more information. [ComposeModifierMissing] - fun Something3(): Unit { ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeModifierReused.md.html b/docs/checks/ComposeModifierReused.md.html index 5f26df3..05f1208 100644 --- a/docs/checks/ComposeModifierReused.md.html +++ b/docs/checks/ComposeModifierReused.md.html @@ -76,11 +76,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - Row(modifier) { ^ - - src/test.kt:7:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -88,11 +85,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - SomethingElse(modifier) ----------------------- - - src/test.kt:12:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -100,11 +94,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - Column(modifier = modifier) { ^ - - src/test.kt:14:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -112,11 +103,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - SomethingDifferent(modifier = modifier) --------------------------------------- - - src/test.kt:19:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -124,11 +112,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - Column(modifier = modifier) { ^ - - src/test.kt:22:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -136,11 +121,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - SomethingElse(modifier = modifier) ---------------------------------- - - src/test.kt:23:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -148,11 +130,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - SomethingElse(modifier = modifier.padding12()) ---------------------------------------------- - - src/test.kt:28:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -160,11 +139,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - SomethingElse(myMod) -------------------- - - src/test.kt:29:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -172,11 +148,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - SomethingElse(myMod) -------------------- - - src/test.kt:34:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -184,11 +157,8 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - Box( ^ - - src/test.kt:40:Error: Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a @@ -196,7 +166,6 @@ composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information. [ComposeModifierReused] - Box( ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeModifierWithoutDefault.md.html b/docs/checks/ComposeModifierWithoutDefault.md.html index c942f2d..8200f20 100644 --- a/docs/checks/ComposeModifierWithoutDefault.md.html +++ b/docs/checks/ComposeModifierWithoutDefault.md.html @@ -54,16 +54,12 @@ but it doesn't have a default value.See https://slackhq.github.io/compose-lints/rules/#modifiers-should-have-default-parameters for more information. [ComposeModifierWithoutDefault] - fun Something(modifier: Modifier) { } ------------------ - - src/test.kt:7:Error: This @Composable function has a modifier parameter but it doesn't have a default value.See https://slackhq.github.io/compose-lints/rules/#modifiers-should-have-default-parameters for more information. [ComposeModifierWithoutDefault] - fun Something(modifier: Modifier = Modifier, modifier2: Modifier) { } ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeMultipleContentEmitters.md.html b/docs/checks/ComposeMultipleContentEmitters.md.html index f742a3e..ac7b07d 100644 --- a/docs/checks/ComposeMultipleContentEmitters.md.html +++ b/docs/checks/ComposeMultipleContentEmitters.md.html @@ -71,22 +71,16 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test.kt:3:Error: Composable functions should only be emitting content into the composition from one source at their top level. - See https://slackhq.github.io/compose-lints/rules/#do-not-emit-multiple-pieces-of-content for more information. [ComposeMultipleContentEmitters] - @Composable ^ - - src/test.kt:8:Error: Composable functions should only be emitting content into the composition from one source at their top level. - See https://slackhq.github.io/compose-lints/rules/#do-not-emit-multiple-pieces-of-content for more information. [ComposeMultipleContentEmitters] - @Composable ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeMutableParameters.md.html b/docs/checks/ComposeMutableParameters.md.html index 34af6ae..125f3d2 100644 --- a/docs/checks/ComposeMutableParameters.md.html +++ b/docs/checks/ComposeMutableParameters.md.html @@ -56,11 +56,8 @@ change.See https://slackhq.github.io/compose-lints/rules/#do-not-use-inherently-mutable-types-as-parameters for more information. [ComposeMutableParameters] - fun Something(a: MutableState<String>) {} -------------------- - - src/test.kt:7:Error: Using mutable objects as state in Compose will cause your users to see incorrect or stale data in your app.Mutable objects that are not observable, such as ArrayList or a mutable data @@ -68,11 +65,8 @@ change.See https://slackhq.github.io/compose-lints/rules/#do-not-use-inherently-mutable-types-as-parameters for more information. [ComposeMutableParameters] - fun Something(a: ArrayList<String>) {} ----------------- - - src/test.kt:9:Error: Using mutable objects as state in Compose will cause your users to see incorrect or stale data in your app.Mutable objects that are not observable, such as ArrayList or a mutable data @@ -80,11 +74,8 @@ change.See https://slackhq.github.io/compose-lints/rules/#do-not-use-inherently-mutable-types-as-parameters for more information. [ComposeMutableParameters] - fun Something(a: HashSet<String>) {} --------------- - - src/test.kt:11:Error: Using mutable objects as state in Compose will cause your users to see incorrect or stale data in your app.Mutable objects that are not observable, such as ArrayList or a mutable data @@ -92,7 +83,6 @@ change.See https://slackhq.github.io/compose-lints/rules/#do-not-use-inherently-mutable-types-as-parameters for more information. [ComposeMutableParameters] - fun Something(a: MutableMap<String, String>) {} -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeNamingLowercase.md.html b/docs/checks/ComposeNamingLowercase.md.html index 4cebd52..0b66958 100644 --- a/docs/checks/ComposeNamingLowercase.md.html +++ b/docs/checks/ComposeNamingLowercase.md.html @@ -76,7 +76,6 @@ @Composable functions.See https://slackhq.github.io/compose-lints/rules/#naming-composable-functions-properly for more information. [ComposeNamingLowercase] - fun MyComposable(): Something { } ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeNamingUppercase.md.html b/docs/checks/ComposeNamingUppercase.md.html index 78b0467..dd4a299 100644 --- a/docs/checks/ComposeNamingUppercase.md.html +++ b/docs/checks/ComposeNamingUppercase.md.html @@ -75,18 +75,14 @@ the naming rules for classes.See https://slackhq.github.io/compose-lints/rules/#naming-composable-functions-properly for more information. [ComposeNamingUppercase] - fun myComposable() { } ------------ - - src/test.kt:7:Error: Composable functions that return Unit should start with an uppercase letter.They are considered declarative entities that can be either present or absent in a composition and therefore follow the naming rules for classes.See https://slackhq.github.io/compose-lints/rules/#naming-composable-functions-properly for more information. [ComposeNamingUppercase] - fun myComposable(): Unit { } ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeParameterOrder.md.html b/docs/checks/ComposeParameterOrder.md.html index 3f3e070..4017a3c 100644 --- a/docs/checks/ComposeParameterOrder.md.html +++ b/docs/checks/ComposeParameterOrder.md.html @@ -57,11 +57,8 @@ See https://slackhq.github.io/compose-lints/rules/#ordering-composable-parameters-properly for more information. [ComposeParameterOrder] - fun MyComposable(modifier: Modifier = Modifier, other: String, other2: String) { } -------------------------------------------------------------- - - src/test.kt:8:Error: Parameters in a composable function should be ordered following this pattern: params without defaults, modifiers, params with defaults and optionally, a trailing function that might not @@ -72,11 +69,8 @@ See https://slackhq.github.io/compose-lints/rules/#ordering-composable-parameters-properly for more information. [ComposeParameterOrder] - fun MyComposable(text: String = "deffo", modifier: Modifier = Modifier) { } ------------------------------------------------------- - - src/test.kt:11:Error: Parameters in a composable function should be ordered following this pattern: params without defaults, modifiers, params with defaults and optionally, a trailing function that might not @@ -87,11 +81,8 @@ See https://slackhq.github.io/compose-lints/rules/#ordering-composable-parameters-properly for more information. [ComposeParameterOrder] - fun MyComposable(modifier: Modifier = Modifier, text: String = "123", modifier2: Modifier = Modifier) { } ------------------------------------------------------------------------------------- - - src/test.kt:14:Error: Parameters in a composable function should be ordered following this pattern: params without defaults, modifiers, params with defaults and optionally, a trailing function that might not @@ -102,11 +93,8 @@ See https://slackhq.github.io/compose-lints/rules/#ordering-composable-parameters-properly for more information. [ComposeParameterOrder] - fun MyComposable(text: String = "123", modifier: Modifier = Modifier, lambda: () -> Unit) { } ------------------------------------------------------------------------- - - src/test.kt:17:Error: Parameters in a composable function should be ordered following this pattern: params without defaults, modifiers, params with defaults and optionally, a trailing function that might not @@ -118,7 +106,6 @@ See https://slackhq.github.io/compose-lints/rules/#ordering-composable-parameters-properly for more information. [ComposeParameterOrder] - fun MyComposable(text1: String, m2: Modifier = Modifier, modifier: Modifier = Modifier, trailing: () -> Unit) { } --------------------------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposePreviewNaming.md.html b/docs/checks/ComposePreviewNaming.md.html index 2a46ad1..c0a3d09 100644 --- a/docs/checks/ComposePreviewNaming.md.html +++ b/docs/checks/ComposePreviewNaming.md.html @@ -49,27 +49,20 @@ See https://slackhq.github.io/compose-lints/rules/#naming-multipreview-annotations-properly for more information. [ComposePreviewNaming] - @Preview ^ - - src/Banana.kt:5:Error: Preview annotations with 1 preview annotations should end with the Preview suffix. See https://slackhq.github.io/compose-lints/rules/#naming-multipreview-annotations-properly for more information. [ComposePreviewNaming] - @Preview ^ - - src/Banana.kt:7:Error: Preview annotations with 1 preview annotations should end with the Preview suffix. See https://slackhq.github.io/compose-lints/rules/#naming-multipreview-annotations-properly for more information. [ComposePreviewNaming] - @BananaPreviews ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposePreviewPublic.md.html b/docs/checks/ComposePreviewPublic.md.html index f7e5603..30298c6 100644 --- a/docs/checks/ComposePreviewPublic.md.html +++ b/docs/checks/ComposePreviewPublic.md.html @@ -54,16 +54,12 @@ only for previewing the UI should not be public.See https://slackhq.github.io/compose-lints/rules/#preview-composables-should-not-be-public for more information. [ComposePreviewPublic] - @Preview ^ - - src/test.kt:7:Error: Composables annotated with @Preview that are used only for previewing the UI should not be public.See https://slackhq.github.io/compose-lints/rules/#preview-composables-should-not-be-public for more information. [ComposePreviewPublic] - @CombinedPreviews ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeRememberMissing.md.html b/docs/checks/ComposeRememberMissing.md.html index 7dcad1c..8ec6514 100644 --- a/docs/checks/ComposeRememberMissing.md.html +++ b/docs/checks/ComposeRememberMissing.md.html @@ -51,11 +51,8 @@ See https://slackhq.github.io/compose-lints/rules/#state-should-be-remembered-in-composables for more information. [ComposeRememberMissing] - val something = mutableStateOf("X") ------------------- - - src/test.kt:10:Error: Using mutableStateOf in a @Composable function without it being inside of a remember function. If you don't remember the state instance, a new state instance will be @@ -63,7 +60,6 @@ See https://slackhq.github.io/compose-lints/rules/#state-should-be-remembered-in-composables for more information. [ComposeRememberMissing] - fun MyComposable(something: State<String> = mutableStateOf("X")) { ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeUnstableCollections.md.html b/docs/checks/ComposeUnstableCollections.md.html index 9354fe1..4551c6e 100644 --- a/docs/checks/ComposeUnstableCollections.md.html +++ b/docs/checks/ComposeUnstableCollections.md.html @@ -53,11 +53,8 @@ See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information. [ComposeUnstableCollections] - fun Something(a: Collection<String>) {} ------------------ - - src/test.kt:6:Warning: The Compose Compiler cannot infer the stability of a parameter if a List is used in it, even if the item type is stable. @@ -67,11 +64,8 @@ See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information. [ComposeUnstableCollections] - fun Something(a: List<String>) {} ------------ - - src/test.kt:8:Warning: The Compose Compiler cannot infer the stability of a parameter if a Set is used in it, even if the item type is stable. @@ -81,11 +75,8 @@ See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information. [ComposeUnstableCollections] - fun Something(a: Set<String>) {} ----------- - - src/test.kt:10:Warning: The Compose Compiler cannot infer the stability of a parameter if a Map is used in it, even if the item type is stable. @@ -95,7 +86,6 @@ See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information. [ComposeUnstableCollections] - fun Something(a: Map<String, Int>) {} ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeUnstableReceiver.md.html b/docs/checks/ComposeUnstableReceiver.md.html index b59cc01..18e3257 100644 --- a/docs/checks/ComposeUnstableReceiver.md.html +++ b/docs/checks/ComposeUnstableReceiver.md.html @@ -53,57 +53,41 @@ receiver type stable or refactor this function if that isn't possible. See https://slackhq.github.io/compose-lints/rules/#unstable-receivers for more information. [ComposeUnstableReceiver] - @Composable fun Content() ------- - - src/ExampleInterface.kt:8:Warning: Instance composable functions on non-stable classes will always be recomposed. If possible, make the receiver type stable or refactor this function if that isn't possible. See https://slackhq.github.io/compose-lints/rules/#unstable-receivers for more information. [ComposeUnstableReceiver] - @Composable fun Content() {} ------- - - src/ExampleInterface.kt:12:Warning: Instance composable functions on non-stable classes will always be recomposed. If possible, make the receiver type stable or refactor this function if that isn't possible. See https://slackhq.github.io/compose-lints/rules/#unstable-receivers for more information. [ComposeUnstableReceiver] - fun Example.OtherContent() {} ------- - - src/ExampleInterface.kt:15:Warning: Instance composable functions on non-stable classes will always be recomposed. If possible, make the receiver type stable or refactor this function if that isn't possible. See https://slackhq.github.io/compose-lints/rules/#unstable-receivers for more information. [ComposeUnstableReceiver] - val Example.OtherContentProperty get() {} ------- - - src/ExampleInterface.kt:19:Warning: Instance composable functions on non-stable classes will always be recomposed. If possible, make the receiver type stable or refactor this function if that isn't possible. See https://slackhq.github.io/compose-lints/rules/#unstable-receivers for more information. [ComposeUnstableReceiver] - @Composable fun present(): T ------- - - src/ExampleInterface.kt:23:Warning: Instance composable functions on non-stable classes will always be recomposed. If possible, make the receiver type stable or refactor this function if that isn't possible. See https://slackhq.github.io/compose-lints/rules/#unstable-receivers for more information. [ComposeUnstableReceiver] - @Composable override fun present(): String { return "hi" } ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeViewModelForwarding.md.html b/docs/checks/ComposeViewModelForwarding.md.html index 58cd846..9d18adc 100644 --- a/docs/checks/ComposeViewModelForwarding.md.html +++ b/docs/checks/ComposeViewModelForwarding.md.html @@ -52,7 +52,6 @@ hoisting.See https://slackhq.github.io/compose-lints/rules/#hoist-all-the-things for more information. [ComposeViewModelForwarding] - AnotherComposable(viewModel) ---------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ComposeViewModelInjection.md.html b/docs/checks/ComposeViewModelInjection.md.html index d2d5407..0f33776 100644 --- a/docs/checks/ComposeViewModelInjection.md.html +++ b/docs/checks/ComposeViewModelInjection.md.html @@ -70,29 +70,22 @@ parameters, so that it is more testable and flexible. See https://slackhq.github.io/compose-lints/rules/#viewmodels for more information. [ComposeViewModelInjection] - val viewModel = <MyVM>() ------------------------ - - src/test.kt:11:Error: Implicit dependencies of composables should be made explicit. Usages of to acquire a ViewModel should be done in composable default parameters, so that it is more testable and flexible. See https://slackhq.github.io/compose-lints/rules/#viewmodels for more information. [ComposeViewModelInjection] - val viewModel: MyVM = () ------------------------ - - src/test.kt:16:Error: Implicit dependencies of composables should be made explicit. Usages of to acquire a ViewModel should be done in composable default parameters, so that it is more testable and flexible. See https://slackhq.github.io/compose-lints/rules/#viewmodels for more information. [ComposeViewModelInjection] - val viewModel: MyVM = () ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CompositionLocalNaming.md.html b/docs/checks/CompositionLocalNaming.md.html index 7e06677..5d4c84d 100644 --- a/docs/checks/CompositionLocalNaming.md.html +++ b/docs/checks/CompositionLocalNaming.md.html @@ -50,21 +50,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/androidx/compose/runtime/foo/Test.kt:6:Warning: CompositionLocal properties should be prefixed with Local [CompositionLocalNaming] - val FooCompositionLocal = compositionLocalOf { 5 } ------------------- - - src/androidx/compose/runtime/foo/Test.kt:9:Warning: CompositionLocal properties should be prefixed with Local [CompositionLocalNaming] - val BarCompositionLocal: CompositionLocal<String?> = staticCompositionLocalOf { ------------------- - - src/androidx/compose/runtime/foo/Test.kt:16:Warning: CompositionLocal properties should be prefixed with Local [CompositionLocalNaming] - val BazCompositionLocal: ProvidableCompositionLocal<Int> = ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,17 +103,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -128,7 +121,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/ConflictingOnColor.md.html b/docs/checks/ConflictingOnColor.md.html index 21cb1b0..7085db2 100644 --- a/docs/checks/ConflictingOnColor.md.html +++ b/docs/checks/ConflictingOnColor.md.html @@ -53,84 +53,50 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/androidx/compose/material/foo/test.kt:15:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:16:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:17:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:18:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:19:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.Red, --------- - - src/androidx/compose/material/foo/test.kt:31:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:32:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.Blue, ---------- - - src/androidx/compose/material/foo/test.kt:34:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - onSurface = Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:51:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.White, ----------- - - src/androidx/compose/material/foo/test.kt:52:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - yellow400, --------- - - src/androidx/compose/material/foo/test.kt:53:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - Color.Blue, ---------- - - src/androidx/compose/material/foo/test.kt:55:Error: Conflicting 'on' color for a given background [ConflictingOnColor] - yellow500, --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -214,17 +180,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.material:material-android:1.7.0-beta04") +implementation("androidx.compose.material:material-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.material:material-android:1.7.0-beta04' +implementation 'androidx.compose.material:material-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.material-android) # libs.versions.toml [versions] -material-android = "1.7.0-beta04" +material-android = "1.7.0-beta05" [libraries] material-android = { module = "androidx.compose.material:material-android", @@ -232,7 +198,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.material:material-android](androidx_compose_material_material-android.md.html). diff --git a/docs/checks/ConstantLocale.md.html b/docs/checks/ConstantLocale.md.html index e03ee79..82e8c05 100644 --- a/docs/checks/ConstantLocale.md.html +++ b/docs/checks/ConstantLocale.md.html @@ -40,12 +40,11 @@ Locale.getDefault() to a final static field is suspicious; this code will not work correctly if the user changes locale while the app is running [ConstantLocale] - static final Locale errorLocale = Locale.getDefault(); ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/TestLocaleJava.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -65,6 +64,57 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/TestLocaleKotlin.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import java.util.Locale + +@Suppress("HasPlatformType","JoinDeclarationAndAssignment") +class TestLocaleKotlin { + companion object { + var okLocale1 = Locale.getDefault() + val errorLocale = Locale.getDefault() + } + var okLocale2 = Locale.getDefault() + val okLocale3 = Locale.getDefault() + fun test() { + val okLocale4 = Locale.getDefault() + } + val okLocale5: Locale + init { + okLocale5 = Locale.getDefault() + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MainActivity.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.app.Activity +import android.util.Log +import java.text.SimpleDateFormat +import java.util.* + +class MainActivity : Activity() { + companion object { + val PROBLEMATIC_DESCRIPTION_DATE_FORMAT = SimpleDateFormat("MMM dd", Locale.getDefault()) + //same for the single parameter CTOR : SimpleDateFormat("MMM dd") + } + + @Suppress("PropertyName") + val SAFE_DESCRIPTION_DATE_FORMAT = SimpleDateFormat("MMM dd", Locale.getDefault()) + + override fun onResume() { + super.onResume() + val today = Calendar.getInstance().time + Log.d("AppLog", "problematic:" + PROBLEMATIC_DESCRIPTION_DATE_FORMAT.format(today)) + Log.d("AppLog", "safe:" + SAFE_DESCRIPTION_DATE_FORMAT.format(today)) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LocaleDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ConstraintLayoutToolsEditorAttribute.md.html b/docs/checks/ConstraintLayoutToolsEditorAttribute.md.html index 502323d..c18dbb5 100644 --- a/docs/checks/ConstraintLayoutToolsEditorAttribute.md.html +++ b/docs/checks/ConstraintLayoutToolsEditorAttribute.md.html @@ -1,13 +1,13 @@ -(#) Flags tools:layout_editor xml properties. +(#) Flags tools:layout_editor xml properties -!!! WARNING: Flags tools:layout_editor xml properties. +!!! WARNING: Flags tools:layout_editor xml properties This is a warning. Id : `ConstraintLayoutToolsEditorAttribute` Summary -: Flags tools:layout_editor xml properties. +: Flags tools:layout_editor xml properties Severity : Warning Category @@ -29,11 +29,46 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/ConstraintLayoutToolsEditorAttributeDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ConstraintLayoutToolsEditorAttributeDetectorTest.kt) The tools:layout_editor xml properties are only used for previewing and won't be used in your APK hence they're unnecessary and just add overhead. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/layout.xml:3:Warning: Don't use tools:layout_editor_absoluteX +[ConstraintLayoutToolsEditorAttribute] + tools:layout_editor_absoluteX="4dp"/> + ----------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView + xmlns:tools="http://schemas.android.com/tools" + tools:layout_editor_absoluteX="4dp"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ConstraintLayoutToolsEditorAttributeDetectorTest.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, `ConstraintLayoutToolsEditorAttributeDetector.toolsLayoutEditor`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/ContentDescription.md.html b/docs/checks/ContentDescription.md.html index 4d896cb..13eb250 100644 --- a/docs/checks/ContentDescription.md.html +++ b/docs/checks/ContentDescription.md.html @@ -56,43 +56,27 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/accessibility.xml:4:Warning: Missing `contentDescription` attribute on image [ContentDescription] - <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> --------- - - res/layout/accessibility.xml:5:Warning: Missing `contentDescription` attribute on image [ContentDescription] - <ImageButton android:importantForAccessibility="yes" android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> ----------- - - res/layout/accessibility.xml:9:Warning: Do not set both `contentDescription` and `hint`: the `contentDescription` will mask the `hint` [ContentDescription] - <EditText android:hint="@string/label" android:id="@+android:id/summary" android:contentDescription="@string/label" /> ------------------------------------------ - - res/layout/accessibility.xml:12:Warning: Empty `contentDescription` attribute on image [ContentDescription] - <ImageButton android:id="@+android:id/summary" android:contentDescription="TODO" /> --------------------------------- - - res/layout/accessibility.xml:13:Warning: Empty `contentDescription` attribute on image [ContentDescription] - <ImageButton android:id="@+id/summary2" android:contentDescription="" /> ----------------------------- - - res/layout/accessibility.xml:14:Warning: Empty `contentDescription` attribute on image [ContentDescription] - <ImageButton android:id="@+id/summary3" android:contentDescription="TODO" /> --------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CoroutineCreationDuringComposition.md.html b/docs/checks/CoroutineCreationDuringComposition.md.html index 7d73245..182efa1 100644 --- a/docs/checks/CoroutineCreationDuringComposition.md.html +++ b/docs/checks/CoroutineCreationDuringComposition.md.html @@ -54,167 +54,106 @@ src/androidx/compose/runtime/foo/test.kt:10:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:11:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:12:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- - - src/androidx/compose/runtime/foo/test.kt:16:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:17:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:18:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- - - src/androidx/compose/runtime/foo/test.kt:22:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:23:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:24:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- - - src/androidx/compose/runtime/foo/test.kt:33:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:34:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:35:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- - - src/androidx/compose/runtime/foo/test.kt:38:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:39:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:40:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- - - src/androidx/compose/runtime/foo/test.kt:46:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:47:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:48:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- - - src/androidx/compose/runtime/foo/test.kt:52:Error: Calls to async should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.async {} ----- - - src/androidx/compose/runtime/foo/test.kt:53:Error: Calls to launch should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - CoroutineScope.launch {} ------ - - src/androidx/compose/runtime/foo/test.kt:54:Error: Calls to launchIn should happen inside a LaunchedEffect and not composition [CoroutineCreationDuringComposition] - flowOf(Unit).launchIn(CoroutineScope) -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -297,17 +236,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -315,7 +254,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/CredManMissingDal.md.html b/docs/checks/CredManMissingDal.md.html index c3646d7..a55a788 100644 --- a/docs/checks/CredManMissingDal.md.html +++ b/docs/checks/CredManMissingDal.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:3:Error: Missing tag for asset statements for Credential Manager [CredManMissingDal] - <application> ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -64,7 +63,7 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`src/test.kt`: +`src/com/example/app/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers package com.example.app diff --git a/docs/checks/CustomPermissionTypo.md.html b/docs/checks/CustomPermissionTypo.md.html index 712a21c..2f8d82d 100644 --- a/docs/checks/CustomPermissionTypo.md.html +++ b/docs/checks/CustomPermissionTypo.md.html @@ -42,14 +42,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:9:Warning: Did you mean my.custom.permission.FOOBAR? [CustomPermissionTypo] - <service android:permission="my.custom.permission.FOOBOB" /> ------------------------------------------------------------ - - AndroidManifest.xml:11:Warning: Did you mean my.custom.permission.BAZQUXX? [CustomPermissionTypo] - <activity android:permission="my.custom.permission.BAZQXX" /> ------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CustomSplashScreen.md.html b/docs/checks/CustomSplashScreen.md.html index 475d0f3..69852d1 100644 --- a/docs/checks/CustomSplashScreen.md.html +++ b/docs/checks/CustomSplashScreen.md.html @@ -43,7 +43,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/SplashActivity.kt:6:Warning: The application should not provide its own launch screen [CustomSplashScreen] - class SplashActivity : AppCompatActivity() { -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CustomViewStyleable.md.html b/docs/checks/CustomViewStyleable.md.html index 7f92639..f906871 100644 --- a/docs/checks/CustomViewStyleable.md.html +++ b/docs/checks/CustomViewStyleable.md.html @@ -44,54 +44,38 @@ (CustomView1) and the declare-styleable (MyDeclareStyleable) should have the same name (various editor features rely on this convention) [CustomViewStyleable] - context.obtainStyledAttributes(R.styleable.MyDeclareStyleable); ------------------------------ - - src/test/pkg/CustomView1.java:19:Warning: By convention, the custom view (CustomView1) and the declare-styleable (MyDeclareStyleable) should have the same name (various editor features rely on this convention) [CustomViewStyleable] - context.obtainStyledAttributes(defStyleRes, R.styleable.MyDeclareStyleable); ------------------------------ - - src/test/pkg/CustomView1.java:20:Warning: By convention, the custom view (CustomView1) and the declare-styleable (MyDeclareStyleable) should have the same name (various editor features rely on this convention) [CustomViewStyleable] - context.obtainStyledAttributes(attrs, R.styleable.MyDeclareStyleable); ------------------------------ - - src/test/pkg/CustomView1.java:21:Warning: By convention, the custom view (CustomView1) and the declare-styleable (MyDeclareStyleable) should have the same name (various editor features rely on this convention) [CustomViewStyleable] - context.obtainStyledAttributes(attrs, R.styleable.MyDeclareStyleable, defStyleAttr, ------------------------------ - - src/test/pkg/CustomView1.java:46:Warning: By convention, the declare-styleable (MyLayout) for a layout parameter class (MyLayoutParams) is expected to be the surrounding class (MyLayout) plus "_Layout", e.g. MyLayout_Layout. (Various editor features rely on this convention.) [CustomViewStyleable] - context.obtainStyledAttributes(R.styleable.MyLayout); // Wrong -------------------- - - src/test/pkg/CustomView1.java:47:Warning: By convention, the declare-styleable (MyDeclareStyleable) for a layout parameter class (MyLayoutParams) is expected to be the surrounding class (MyLayout) plus "_Layout", e.g. MyLayout_Layout. (Various editor features rely on this convention.) [CustomViewStyleable] - context.obtainStyledAttributes(R.styleable.MyDeclareStyleable); // Wrong ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CustomX509TrustManager.md.html b/docs/checks/CustomX509TrustManager.md.html index 7f7f219..6a9dc1d 100644 --- a/docs/checks/CustomX509TrustManager.md.html +++ b/docs/checks/CustomX509TrustManager.md.html @@ -42,7 +42,6 @@ likely to disable certificate validation altogether, and is non-trivial to implement correctly without calling Android's default implementation. [CustomX509TrustManager] - TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/CutPasteId.md.html b/docs/checks/CutPasteId.md.html index bceb77e..8e562b0 100644 --- a/docs/checks/CutPasteId.md.html +++ b/docs/checks/CutPasteId.md.html @@ -44,7 +44,6 @@ src/test/pkg/PasteError.java:10:Warning: The id R.id.previous has already been looked up in this method; possible cut & paste error? [CutPasteId] - next = (Button) findViewById(R.id.previous); // TYPO, meant R.id.next --------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -68,7 +67,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `test.pkg`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers @id/next ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DalvikOverride.md.html b/docs/checks/DalvikOverride.md.html index 86090d0..10f2348 100644 --- a/docs/checks/DalvikOverride.md.html +++ b/docs/checks/DalvikOverride.md.html @@ -50,12 +50,44 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/pkg2/Class2.java:7:Error: This package private method may be unintentionally overriding method in pkg1.Class1 [DalvikOverride] - void method() { // Flag this as an accidental override ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/pkg1/Class1.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package pkg1; + +public class Class1 { + void method() { + } + + void method2(int foo) { + } + + void method3() { + } + + void method4() { + } + + void method5() { + } + + void method6() { + } + + void method7() { + } + + public static class Class4 extends Class1 { + void method() { // Not an error: same package + } + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/pkg2/Class2.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/DataBindingWithoutKapt.md.html b/docs/checks/DataBindingWithoutKapt.md.html index 7dc3dc3..91fc609 100644 --- a/docs/checks/DataBindingWithoutKapt.md.html +++ b/docs/checks/DataBindingWithoutKapt.md.html @@ -41,7 +41,6 @@ build.gradle:6:Warning: If you plan to use data binding in a Kotlin project, you should apply the kotlin-kapt plugin. [DataBindingWithoutKapt] - enabled true ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DataExtractionRules.md.html b/docs/checks/DataExtractionRules.md.html index 7bcb020..4da45b8 100644 --- a/docs/checks/DataExtractionRules.md.html +++ b/docs/checks/DataExtractionRules.md.html @@ -56,12 +56,11 @@ AndroidManifest.xml:11:Warning: The attribute android:allowBackup is deprecated from Android 12 and the default allows backup [DataExtractionRules] - android:allowBackup="true" > ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -81,6 +80,40 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DeepLinkInActivityDestination.md.html b/docs/checks/DeepLinkInActivityDestination.md.html index 3aa06bf..af0edf2 100644 --- a/docs/checks/DeepLinkInActivityDestination.md.html +++ b/docs/checks/DeepLinkInActivityDestination.md.html @@ -55,7 +55,6 @@ destination. Attach the deeplink directly to the second activity or the start destination of a nav host in the second activity instead. [DeepLinkInActivityDestination] - <deepLink app:uri="www.example.com" /> -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -102,17 +101,17 @@ ``` // build.gradle.kts -implementation("androidx.navigation:navigation-runtime:2.8.0-beta04") +implementation("androidx.navigation:navigation-runtime:2.8.0-beta05") // build.gradle -implementation 'androidx.navigation:navigation-runtime:2.8.0-beta04' +implementation 'androidx.navigation:navigation-runtime:2.8.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.navigation-runtime) # libs.versions.toml [versions] -navigation-runtime = "2.8.0-beta04" +navigation-runtime = "2.8.0-beta05" [libraries] navigation-runtime = { module = "androidx.navigation:navigation-runtime", @@ -120,7 +119,7 @@ } ``` -2.8.0-beta04 is the version this documentation was generated from; +2.8.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.navigation:navigation-runtime](androidx_navigation_navigation-runtime.md.html). diff --git a/docs/checks/DefaultCleartextTraffic.md.html b/docs/checks/DefaultCleartextTraffic.md.html new file mode 100644 index 0000000..225292f --- /dev/null +++ b/docs/checks/DefaultCleartextTraffic.md.html @@ -0,0 +1,147 @@ + +(#) Application by default permits cleartext traffic + +!!! WARNING: Application by default permits cleartext traffic + This is a warning. + +Id +: `DefaultCleartextTraffic` +Summary +: Application by default permits cleartext traffic +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/DefaultCleartextTraffic +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/MissingNetworkSecurityConfigDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MissingNetworkSecurityConfigDetectorTest.kt) +Copyright Year +: 2023 + +Apps targeting SDK versions earlier than 28 trust cleartext traffic by +default. The application must explicitly opt out of this in order to +only use secure connections. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:3:Warning: On SDK versions below 28, the application +by default trusts cleartext traffic. Add a Network Security Config file +to opt out of these insecure connections. [DefaultCleartextTraffic] +<application> + ----------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<uses-sdk android:targetSdkVersion='27'/> +<application> + <activity android:name='com.example.MainActivity'></activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MissingNetworkSecurityConfigDetectorTest.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, `MissingNetworkSecurityConfigDetector.testWhenNoNetworkSecurityConfig_defaultCleartextTrafficSdkLevel_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="DefaultCleartextTraffic"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <application tools:ignore="DefaultCleartextTraffic" .../> + ... + </manifest> + ``` + +* 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="DefaultCleartextTraffic" 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 'DefaultCleartextTraffic' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore DefaultCleartextTraffic ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/DefaultEncoding.md.html b/docs/checks/DefaultEncoding.md.html index 0dc8e6c..5b425dc 100644 --- a/docs/checks/DefaultEncoding.md.html +++ b/docs/checks/DefaultEncoding.md.html @@ -56,70 +56,48 @@ src/test/pkg/Test.java:14:Error: This file will be written with the default system encoding instead of a specific charset which is usually a mistake; add StandardCharsets.UTF_8? [DefaultEncoding] - new FileWriter("/path"); // ERROR 1 ----------------------- - - src/test/pkg/Test.java:15:Error: This file will be written with the default system encoding instead of a specific charset which is usually a mistake; add charset argument, FileWriter(..., UTF_8)? [DefaultEncoding] - new FileWriter(file); // ERROR 2 -------------------- - - src/test/pkg/Test.java:16:Error: This file will be written with the default system encoding instead of a specific charset which is usually a mistake; add charset argument, FileWriter(..., UTF_8)? [DefaultEncoding] - new FileWriter(file, true); // ERROR 3 -------------------------- - - src/test/pkg/Test.java:17:Error: This file will be written with the default system encoding instead of a specific charset which is usually a mistake; add charset argument, FileWriter(..., UTF_8)? [DefaultEncoding] - new PrintWriter(new BufferedWriter(new FileWriter(file))); // ERROR 4 -------------------- - - src/test/pkg/Test.java:24:Error: This PrintWriter will use the default system encoding instead of a specific charset which is usually a mistake; add charset argument, PrintWriter(..., UTF_8)? [DefaultEncoding] - new PrintWriter(System.out, true); // ERROR 5 --------------------------------- - - src/test/pkg/Test.java:25:Error: This PrintWriter will use the default system encoding instead of a specific charset which is usually a mistake; add charset argument, PrintWriter(..., UTF_8)? [DefaultEncoding] - new PrintWriter("/path"); // ERROR 6 ------------------------ - - src/test/pkg/Test.java:26:Error: This PrintWriter will use the default system encoding instead of a specific charset which is usually a mistake; add charset argument, PrintWriter(..., UTF_8)? [DefaultEncoding] - new PrintWriter(file); // ERROR 7 --------------------- - - src/test/pkg/Test.java:36:Error: This string will be interpreted with the default system encoding instead of a specific charset which is usually a mistake; add charset argument, String(..., UTF_8)? [DefaultEncoding] - new String(bytes); // ERROR 8 ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DefaultLayoutAttribute.md.html b/docs/checks/DefaultLayoutAttribute.md.html index b736339..0f7ce98 100644 --- a/docs/checks/DefaultLayoutAttribute.md.html +++ b/docs/checks/DefaultLayoutAttribute.md.html @@ -1,13 +1,13 @@ -(#) Flags default layout values. +(#) Flags default layout values -!!! WARNING: Flags default layout values. +!!! WARNING: Flags default layout values This is a warning. Id : `DefaultLayoutAttribute` Summary -: Flags default layout values. +: Flags default layout values Severity : Warning Category @@ -29,10 +29,47 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/DefaultLayoutAttributeDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/DefaultLayoutAttributeDetectorTest.kt) Flags default layout values that are not needed. One for instance is the textStyle="normal" that can be just removed. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:5:Warning: This is the default and hence you don't +need to specify it [DefaultLayoutAttribute] + android:textStyle="normal"/> + ------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textStyle="normal"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/DefaultLayoutAttributeDetectorTest.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, `DefaultLayoutAttributeDetector.textStyleNormal`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/DefaultLocale.md.html b/docs/checks/DefaultLocale.md.html index 6387b12..7e85d20 100644 --- a/docs/checks/DefaultLocale.md.html +++ b/docs/checks/DefaultLocale.md.html @@ -54,72 +54,47 @@ locale is a common source of bugs: Use toUpperCase(Locale) instead. For strings meant to be internal use Locale.ROOT, otherwise Locale.getDefault(). [DefaultLocale] - System.out.println("WRONG".toUpperCase()); ----------- - - src/test/pkg/LocaleTest.java:16:Warning: Implicitly using the default locale is a common source of bugs: Use toLowerCase(Locale) instead. For strings meant to be internal use Locale.ROOT, otherwise Locale.getDefault(). [DefaultLocale] - System.out.println("WRONG".toLowerCase()); ----------- - - src/test/pkg/LocaleTest.java:20:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %f", 1.0f); // Implies locale -------------------------------- - - src/test/pkg/LocaleTest.java:21:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %1$f", 1.0f); ---------------------------------- - - src/test/pkg/LocaleTest.java:22:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %e", 1.0f); -------------------------------- - - src/test/pkg/LocaleTest.java:23:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %d", 1.0f); -------------------------------- - - src/test/pkg/LocaleTest.java:24:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %g", 1.0f); -------------------------------- - - src/test/pkg/LocaleTest.java:25:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %g", 1.0f); -------------------------------- - - src/test/pkg/LocaleTest.java:26:Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale] - String.format("WRONG: %1$tm %1$te,%1$tY", ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DefaultTrustedUserCerts.md.html b/docs/checks/DefaultTrustedUserCerts.md.html new file mode 100644 index 0000000..6a16707 --- /dev/null +++ b/docs/checks/DefaultTrustedUserCerts.md.html @@ -0,0 +1,149 @@ + +(#) Application by default trusts user-added CA certificates + +!!! WARNING: Application by default trusts user-added CA certificates + This is a warning. + +Id +: `DefaultTrustedUserCerts` +Summary +: Application by default trusts user-added CA certificates +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/DefaultTrustedUserCerts +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/MissingNetworkSecurityConfigDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MissingNetworkSecurityConfigDetectorTest.kt) +Copyright Year +: 2023 + +Apps targeting SDK versions earlier than 24 trust user-added CA +certificates by default. In practice, it is better to limit the set of +trusted CAs so only trusted CAs are used for an app's secure +connections. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:3:Warning: On SDK versions below 24, the application +by default trusts user-added CA certificates. Add a Network Security +Config file to opt out of this insecure behavior. +[DefaultTrustedUserCerts] +<application> + ----------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<uses-sdk android:targetSdkVersion='23'/> +<application> + <activity android:name='com.example.MainActivity'></activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MissingNetworkSecurityConfigDetectorTest.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, `MissingNetworkSecurityConfigDetector.testWhenNoNetworkSecurityConfig_defaultUserCerts_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="DefaultTrustedUserCerts"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <application tools:ignore="DefaultTrustedUserCerts" .../> + ... + </manifest> + ``` + +* 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="DefaultTrustedUserCerts" 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 'DefaultTrustedUserCerts' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore DefaultTrustedUserCerts ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/DeletedProvider.md.html b/docs/checks/DeletedProvider.md.html index 008934f..94d3b53 100644 --- a/docs/checks/DeletedProvider.md.html +++ b/docs/checks/DeletedProvider.md.html @@ -46,7 +46,6 @@ src/test/pkg/RemovedGeneratorTest.java:24:Error: The Crypto provider has been deleted in Android P (and was deprecated in Android N), so the code will crash [DeletedProvider] - SecureRandom instance2 = SecureRandom.getInstance("SHA1PRNG", "Crypto"); -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DenyListedApi.md.html b/docs/checks/DenyListedApi.md.html index 422929c..ecb03a6 100644 --- a/docs/checks/DenyListedApi.md.html +++ b/docs/checks/DenyListedApi.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/denylistedapis/DenyListedApiDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/denylistedapis/DenyListedApiDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/denylistedapis/DenyListedApiDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/SomeView.kt:9:Error: Use Context#getDrawableCompat() instead [DenyListedApi] - ContextCompat.getDrawable(context, 42) ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DenyListedBlockingApi.md.html b/docs/checks/DenyListedBlockingApi.md.html index 154af08..0744396 100644 --- a/docs/checks/DenyListedBlockingApi.md.html +++ b/docs/checks/DenyListedBlockingApi.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/denylistedapis/DenyListedApiDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/denylistedapis/DenyListedApiDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/denylistedapis/DenyListedApiDetectorTest.kt) Copyright Year @@ -52,7 +52,6 @@ suspend function or refactoring this in a way to use non-blocking calls. If running in a test, use runTest {} or Turbine to test synchronous values. [DenyListedBlockingApi] - val result = runBlocking {} ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Deprecated.md.html b/docs/checks/Deprecated.md.html index 75b250b..64b55d5 100644 --- a/docs/checks/Deprecated.md.html +++ b/docs/checks/Deprecated.md.html @@ -38,70 +38,42 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/deprecation.xml:1:Warning: AbsoluteLayout is deprecated [Deprecated] - <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" -------------- - - res/layout/deprecation.xml:15:Warning: android:autoText is deprecated: Use inputType instead [Deprecated] - android:autoText="true" ----------------------- - - res/layout/deprecation.xml:16:Warning: android:capitalize is deprecated: Use inputType instead [Deprecated] - android:capitalize="true" ------------------------- - - res/layout/deprecation.xml:17:Warning: android:editable is deprecated: Use an to make it editable [Deprecated] - android:editable="true" ----------------------- - - res/layout/deprecation.xml:19:Warning: android:inputMethod is deprecated: Use inputType instead [Deprecated] - android:inputMethod="@+id/foo" ------------------------------ - - res/layout/deprecation.xml:20:Warning: android:numeric is deprecated: Use inputType instead [Deprecated] - android:numeric="true" ---------------------- - - res/layout/deprecation.xml:21:Warning: android:password is deprecated: Use inputType instead [Deprecated] - android:password="true" ----------------------- - - res/layout/deprecation.xml:22:Warning: android:phoneNumber is deprecated: Use inputType instead [Deprecated] - android:phoneNumber="true" -------------------------- - - res/layout/deprecation.xml:25:Warning: android:editable is deprecated: is already editable [Deprecated] - <EditText android:editable="true" /> ----------------------- - - res/layout/deprecation.xml:26:Warning: android:editable is deprecated: Use inputType instead [Deprecated] - <EditText android:editable="false" /> ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DeprecatedCall.md.html b/docs/checks/DeprecatedCall.md.html index e449d5d..c20fde7 100644 --- a/docs/checks/DeprecatedCall.md.html +++ b/docs/checks/DeprecatedCall.md.html @@ -1,13 +1,13 @@ -(#) This class or method is deprecated; consider using an alternative. +(#) This class or method is deprecated; consider using an alternative -!!! WARNING: This class or method is deprecated; consider using an alternative. +!!! WARNING: This class or method is deprecated; consider using an alternative This is a warning. Id : `DeprecatedCall` Summary -: This class or method is deprecated; consider using an alternative. +: This class or method is deprecated; consider using an alternative Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DeprecatedAnnotationDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DeprecatedAnnotationDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DeprecatedAnnotationDetectorTest.kt) Copyright Year @@ -49,12 +49,21 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/test/TestClass.java:8:Warning: This class or method is deprecated; consider using an alternative. [DeprecatedCall] - new ThisIsDeprecated(); ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/slack/test/ThisIsDeprecated.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package slack.test; + +@Deprecated() +class ThisIsDeprecated { + +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/test/TestClass.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/DeprecatedProvider.md.html b/docs/checks/DeprecatedProvider.md.html index 207a5a4..901eeed 100644 --- a/docs/checks/DeprecatedProvider.md.html +++ b/docs/checks/DeprecatedProvider.md.html @@ -44,34 +44,24 @@ deprecated and when targetSdkVersion is moved to P this method will throw a NoSuchAlgorithmException. To fix this you should stop specifying a provider and use the default implementation [DeprecatedProvider] - Cipher.getInstance("AES/CBC/PKCS7PADDING", "BC"); // Error ---- - - src/test/pkg/BCProviderTest.java:17:Warning: The BC provider is deprecated and when targetSdkVersion is moved to P this method will throw a NoSuchAlgorithmException. To fix this you should stop specifying a provider and use the default implementation [DeprecatedProvider] - Cipher.getInstance("AES/CBC/PKCS7PADDING", BC_PROVIDER); // Error ----------- - - src/test/pkg/BCProviderTest.java:19:Warning: The BC provider is deprecated and when targetSdkVersion is moved to P this method will throw a NoSuchAlgorithmException. To fix this you should stop specifying a provider and use the default implementation [DeprecatedProvider] - Cipher.getInstance("AES/CBC/PKCS7PADDING", Security.getProvider("BC")); // Error -------------------------- - - src/test/pkg/BCProviderTest.java:20:Warning: The BC provider is deprecated and when targetSdkVersion is moved to P this method will throw a NoSuchAlgorithmException. To fix this you should stop specifying a provider and use the default implementation [DeprecatedProvider] - Cipher.getInstance("AES/CBC/PKCS7PADDING", Security.getProvider(BC_PROVIDER)); // Error --------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DeprecatedSinceApi.md.html b/docs/checks/DeprecatedSinceApi.md.html index 5c86b95..56701c0 100644 --- a/docs/checks/DeprecatedSinceApi.md.html +++ b/docs/checks/DeprecatedSinceApi.md.html @@ -41,42 +41,26 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/Test.kt:9:Warning: This method is deprecated as of API level 21 [DeprecatedSinceApi] - api.noLongerNecessary1(0) // WARN 1 ------------------------- - - src/test/pkg/Test.kt:10:Warning: This method is deprecated as of API level 23; Use AlarmManager.notify instead [DeprecatedSinceApi] - api.noLongerNecessary2(0) // WARN 2 ------------------------- - - src/test/pkg/Test.kt:11:Warning: This method is deprecated as of API level 24 [DeprecatedSinceApi] - api.noLongerNecessary3(0) // WARN 3 ------------------------- - - src/test/pkg/Test.kt:18:Warning: This class is deprecated as of API level 19 [DeprecatedSinceApi] - val clz = Api2::class.java // WARN 4 ----------- - - src/test/pkg/Test.kt:19:Warning: This method is deprecated as of API level 23 [DeprecatedSinceApi] - val method1 = api2::someMethod1 // WARN 5 ----------------- - - src/test/pkg/Test.kt:20:Warning: This method is deprecated as of API level 21 [DeprecatedSinceApi] - val method2 = api2::someMethod2 // WARN 6 ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DeprecatedSqlUsage.md.html b/docs/checks/DeprecatedSqlUsage.md.html index 5530277..9e470e6 100644 --- a/docs/checks/DeprecatedSqlUsage.md.html +++ b/docs/checks/DeprecatedSqlUsage.md.html @@ -1,13 +1,13 @@ -(#) Use SqlDelight! +(#) Use SqlDelight -!!! WARNING: Use SqlDelight! +!!! WARNING: Use SqlDelight This is a warning. Id : `DeprecatedSqlUsage` Summary -: Use SqlDelight! +: Use SqlDelight Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DeprecatedSqlUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DeprecatedSqlUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DeprecatedSqlUsageDetectorTest.kt) Copyright Year @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/SqlUsageTestFailure.java:7:Warning: All SQL querying should be performed using SqlDelight [DeprecatedSqlUsage] - db.execSQL("DROP TABLE IF EXISTS foo"); -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DevModeObsolete.md.html b/docs/checks/DevModeObsolete.md.html index 89268ca..4bd3251 100644 --- a/docs/checks/DevModeObsolete.md.html +++ b/docs/checks/DevModeObsolete.md.html @@ -50,15 +50,11 @@ build.gradle:9:Warning: You no longer need a dev mode to enable multi-dexing during development, and this can break API version checks [DevModeObsolete] - minSdkVersion 21 ---------------- - - build.gradle:10:Warning: You no longer need a dev mode to enable multi-dexing during development, and this can break API version checks [DevModeObsolete] - minSdk 21 --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DeviceAdmin.md.html b/docs/checks/DeviceAdmin.md.html index a938041..b52bdce 100644 --- a/docs/checks/DeviceAdmin.md.html +++ b/docs/checks/DeviceAdmin.md.html @@ -48,21 +48,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:30:Warning: You must have an intent filter for action android.app.action.DEVICE_ADMIN_ENABLED [DeviceAdmin] - <meta-data android:name="android.app.device_admin" --------------------------------------- - - AndroidManifest.xml:43:Warning: You must have an intent filter for action android.app.action.DEVICE_ADMIN_ENABLED [DeviceAdmin] - <meta-data android:name="android.app.device_admin" --------------------------------------- - - AndroidManifest.xml:55:Warning: You must have an intent filter for action android.app.action.DEVICE_ADMIN_ENABLED [DeviceAdmin] - <meta-data android:name="android.app.device_admin" --------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DialogFragmentCallbacksDetector.md.html b/docs/checks/DialogFragmentCallbacksDetector.md.html index 3dd2f33..1b274b7 100644 --- a/docs/checks/DialogFragmentCallbacksDetector.md.html +++ b/docs/checks/DialogFragmentCallbacksDetector.md.html @@ -52,7 +52,6 @@ src/foo/TestFragment.java:11:Warning: Use onCancel() instead of calling setOnCancelListener() from onCreateDialog() [DialogFragmentCallbacksDetector] - dialog.setOnCancelListener({ }); ------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DiffUtilEquals.md.html b/docs/checks/DiffUtilEquals.md.html index 205e0f7..db05cfb 100644 --- a/docs/checks/DiffUtilEquals.md.html +++ b/docs/checks/DiffUtilEquals.md.html @@ -42,12 +42,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/test.kt:10:Error: Suspicious equality check: Did you mean == instead of === ? [DiffUtilEquals] - oldItem === newItem // ERROR --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -64,6 +63,34 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyCallback.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import androidx.recyclerview.widget.DiffUtil; + +public class MyCallback extends DiffUtil.ItemCallback { + @Override + public boolean areItemsTheSame(Cheese oldItem, Cheese newItem) { + return oldItem.getId() == newItem.getId(); + } + + @Override + public boolean areContentsTheSame(Cheese oldItem, Cheese newItem) { + return oldItem == newItem; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/Cheese.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +public class Cheese { + public String id; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/DiffUtilDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DisableBaselineAlignment.md.html b/docs/checks/DisableBaselineAlignment.md.html index a19b1cd..33bc017 100644 --- a/docs/checks/DisableBaselineAlignment.md.html +++ b/docs/checks/DisableBaselineAlignment.md.html @@ -43,7 +43,6 @@ res/layout/baseline_weights.xml:2:Warning: Set android:baselineAligned="false" on this element for better performance [DisableBaselineAlignment] - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DisabledAllSafeBrowsing.md.html b/docs/checks/DisabledAllSafeBrowsing.md.html new file mode 100644 index 0000000..fc73fcb --- /dev/null +++ b/docs/checks/DisabledAllSafeBrowsing.md.html @@ -0,0 +1,148 @@ + +(#) Application has disabled safe browsing for all WebView objects + +!!! WARNING: Application has disabled safe browsing for all WebView objects + This is a warning. + +Id +: `DisabledAllSafeBrowsing` +Summary +: Application has disabled safe browsing for all WebView objects +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/DisabledAllSafeBrowsing +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/SafeBrowsingDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/SafeBrowsingDetectorTest.kt) +Copyright Year +: 2024 + +Safe Browsing is a service to help applications check URLs against a +known list of unsafe web resources. We recommend keeping Safe Browsing +enabled at all times and designing your app around any constraints this +causes. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:3:Warning: Safe Browsing should be kept enabled at +all times, as it aims to keep users from unsafe URLs +[DisabledAllSafeBrowsing] + <meta-data android:name='android.webkit.WebView.EnableSafeBrowsing' android:value='false'/> + ------------------------------------------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<application android:debuggable='false'> + <meta-data android:name='android.webkit.WebView.EnableSafeBrowsing' android:value='false'/> + <activity android:name='com.example.MainActivity'></activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/SafeBrowsingDetectorTest.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, `SafeBrowsingDetector.testWhenSafeBrowsingDisabledInManifest_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="DisabledAllSafeBrowsing"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <meta-data tools:ignore="DisabledAllSafeBrowsing" .../> + ... + </manifest> + ``` + +* 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="DisabledAllSafeBrowsing" 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 'DisabledAllSafeBrowsing' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore DisabledAllSafeBrowsing ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/DiscouragedApi.md.html b/docs/checks/DiscouragedApi.md.html index cc2eb47..d09487a 100644 --- a/docs/checks/DiscouragedApi.md.html +++ b/docs/checks/DiscouragedApi.md.html @@ -40,12 +40,11 @@ It is more efficient to retrieve resources by identifier than by name. See getValue(int id, TypedValue outValue, boolean resolveRefs). [DiscouragedApi] - Resources.getValue("name", testValue, false); -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here are the relevant source files: +Here is the source file referenced above: `src/test/pkg/Test1.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -63,42 +62,6 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`src/android/content/res/Resources.java`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -package android.content.res; - -import android.util.TypedValue; -import androidx.annotation.Discouraged; - -public class Resources { - - @Discouraged(message="Use of this function is discouraged. It is more efficient " - + "to retrieve resources by identifier than by name.\n" - + "See `getValue(int id, TypedValue outValue, boolean " - + "resolveRefs)`.") - public int getValue(String name, TypedValue outValue, boolean resolveRefs) { } - - public int getValue(int id, TypedValue outValue, boolean resolveRefs) { } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -`src/androidx/annotation/Discouraged.java`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -package androidx.annotation; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.SOURCE; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -// Stub annotation for unit test. -@Retention(SOURCE) -@Target({METHOD}) -public @interface Discouraged { - String message() default ""; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 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/DiscouragedDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DiscouragedPrivateApi.md.html b/docs/checks/DiscouragedPrivateApi.md.html index 34354ce..1b44938 100644 --- a/docs/checks/DiscouragedPrivateApi.md.html +++ b/docs/checks/DiscouragedPrivateApi.md.html @@ -44,30 +44,23 @@ access to addAssetPath, which is not part of the public SDK and therefore likely to change in future Android releases [DiscouragedPrivateApi] - Method m1 = AssetManager.class.getDeclaredMethod("addAssetPath", String.class); ------------------------------------------------------------------ - - src/test/pkg/application/ReflectionTestJava.java:12:Warning: Reflective access to addAssetPath, which is not part of the public SDK and therefore likely to change in future Android releases [DiscouragedPrivateApi] - Method m2 = assetManager.getClass().getDeclaredMethod("addAssetPath", String.class); ----------------------------------------------------------------------- - - src/test/pkg/application/ReflectionTestJava.java:13:Warning: Reflective access to addAssetPath, which is not part of the public SDK and therefore likely to change in future Android releases [DiscouragedPrivateApi] - Method m3 = AssetManager.class.getDeclaredMethod("addAssetPath", path.getClass()); --------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/application/ReflectionTestJava.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -94,6 +87,28 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/application/ReflectionTestKotlin.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg.application; + +import android.content.res.AssetManager + +class ReflectionTestKotlin { + private fun addAssetPath(assetManager: AssetManager) { + val path = "foo/bar" + val m1 = AssetManager::class.java.getDeclaredMethod("addAssetPath", String::class.java) + val m2 = assetManager.javaClass.getDeclaredMethod("invalidateCachesLocked", Int::class.javaPrimitiveType) + val m3 = assetManager.javaClass.getDeclaredMethod("invalidateCachesLocked", Int::class.java) // OK, doesn't exist + val m4 = AssetManager::class.java.getDeclaredMethod("addAssetPath", path.javaClass) + + val activityClass = Class.forName("android.app.Activity") + val bundleClass = Class.forName("android.os.Bundle") + val m5 = activityClass.getDeclaredMethod("dispatchActivityPostCreated", bundleClass) + + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/PrivateApiDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DoNotCallProviders.md.html b/docs/checks/DoNotCallProviders.md.html index 119abdc..458ab18 100644 --- a/docs/checks/DoNotCallProviders.md.html +++ b/docs/checks/DoNotCallProviders.md.html @@ -1,13 +1,13 @@ -(#) Dagger provider methods should not be called directly by user code. +(#) Dagger provider methods should not be called directly by user code -!!! ERROR: Dagger provider methods should not be called directly by user code. +!!! ERROR: Dagger provider methods should not be called directly by user code This is an error. Id : `DoNotCallProviders` Summary -: Dagger provider methods should not be called directly by user code. +: Dagger provider methods should not be called directly by user code Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DoNotCallProvidersDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DoNotCallProvidersDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DoNotCallProvidersDetectorTest.kt) Copyright Year @@ -50,28 +50,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyModule.kt:15:Error: Dagger provider methods should not be called directly by user code. [DoNotCallProviders] - binds1("this is bad") --------------------- - - src/foo/MyModule.kt:16:Error: Dagger provider methods should not be called directly by user code. [DoNotCallProviders] - "this is bad".binds2() --------------------- - - src/foo/MyModule.kt:17:Error: Dagger provider methods should not be called directly by user code. [DoNotCallProviders] - provider() ---------- - - src/foo/MyModule.kt:18:Error: Dagger provider methods should not be called directly by user code. [DoNotCallProviders] - producer() ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DoNotExposeEitherNetInRepositories.md.html b/docs/checks/DoNotExposeEitherNetInRepositories.md.html index c0e86f7..9df8053 100644 --- a/docs/checks/DoNotExposeEitherNetInRepositories.md.html +++ b/docs/checks/DoNotExposeEitherNetInRepositories.md.html @@ -1,13 +1,13 @@ -(#) Repository APIs should not expose EitherNet types directly. +(#) Repository APIs should not expose EitherNet types directly -!!! ERROR: Repository APIs should not expose EitherNet types directly. +!!! ERROR: Repository APIs should not expose EitherNet types directly This is an error. Id : `DoNotExposeEitherNetInRepositories` Summary -: Repository APIs should not expose EitherNet types directly. +: Repository APIs should not expose EitherNet types directly Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/eithernet/DoNotExposeEitherNetInRepositoriesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/eithernet/DoNotExposeEitherNetInRepositoriesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/eithernet/DoNotExposeEitherNetInRepositoriesDetectorTest.kt) Copyright Year @@ -49,12 +49,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/MyRepository.java:8:Error: Repository APIs should not expose EitherNet types directly. [DoNotExposeEitherNetInRepositories] - ApiResult<String, Exception> getResult(); ---------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/com/slack/eithernet/ApiResult.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.slack.eithernet + +interface ApiResult +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/MyRepository.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -73,6 +79,30 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/MyClassRepository.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test; + +import com.slack.eithernet.ApiResult; + +abstract class MyClassRepository { + // Bad + + public abstract ApiResult getResultPublic(); + public ApiResult resultField = null; + + // Good + + ApiResult resultFieldPackagePrivate = null; + private final ApiResult resultFieldPrivate = null; + protected ApiResult resultFieldProtected = null; + abstract ApiResult getResultPackagePrivate(); + private ApiResult getResultPrivate(); + private ApiResult getResultProtected(); + public abstract String getString(); +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/eithernet/DoNotExposeEitherNetInRepositoriesDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DoNotMock.md.html b/docs/checks/DoNotMock.md.html index 485a475..8f27f93 100644 --- a/docs/checks/DoNotMock.md.html +++ b/docs/checks/DoNotMock.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year @@ -106,33 +106,23 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text test/test/slack/test/TestClass.kt:6:Error: Do not mock TestClass: Use fake() [DoNotMock] - @Mock lateinit var mock1: TestClass ----------------------------------- - - test/test/slack/test/TestClass.kt:7:Error: Do not mock TestClass2: Use fake() [DoNotMock] - @Mock lateinit var mock2: TestClass2 ------------------------------------ - - test/test/slack/test/TestClass.kt:8:Error: Do not mock TestClass3: BECAUSE REASONS [DoNotMock] - @Mock lateinit var mock3: TestClass3 ------------------------------------ - - test/test/slack/test/TestClass.kt:9:Error: Do not mock TestClass4: BECAUSE REASONS [DoNotMock] - @Mock lateinit var mock4: TestClass4 ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `test/test/slack/test/TestClass.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -159,6 +149,20 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`test/test/slack/test/TestClass.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package slack.test + +import org.mockito.Mock + +class MyTests { + @Mock lateinit var mock1: TestClass + @Mock lateinit var mock2: TestClass2 + @Mock lateinit var mock3: TestClass3 + @Mock lateinit var mock4: TestClass4 +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DoNotMockAnything.md.html b/docs/checks/DoNotMockAnything.md.html index e1eacbd..f095924 100644 --- a/docs/checks/DoNotMockAnything.md.html +++ b/docs/checks/DoNotMockAnything.md.html @@ -1,13 +1,13 @@ -(#) Do not add new mocks. +(#) Do not add new mocks -!!! ERROR: Do not add new mocks. +!!! ERROR: Do not add new mocks This is an error. Id : `DoNotMockAnything` Summary -: Do not add new mocks. +: Do not add new mocks Note : **This issue is disabled by default**; use `--enable DoNotMockAnything` Severity @@ -36,7 +36,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DoNotMockAutoValue.md.html b/docs/checks/DoNotMockAutoValue.md.html index fc99814..108c39b 100644 --- a/docs/checks/DoNotMockAutoValue.md.html +++ b/docs/checks/DoNotMockAutoValue.md.html @@ -1,13 +1,13 @@ -(#) AutoValue classes represent pure data classes, so mocking them should not be necessary. +(#) AutoValue classes represent pure data classes, so mocking them should not be necessary -!!! ERROR: AutoValue classes represent pure data classes, so mocking them should not be necessary. +!!! ERROR: AutoValue classes represent pure data classes, so mocking them should not be necessary This is an error. Id : `DoNotMockAutoValue` Summary -: AutoValue classes represent pure data classes, so mocking them should not be necessary. +: AutoValue classes represent pure data classes, so mocking them should not be necessary Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DoNotMockDataClass.md.html b/docs/checks/DoNotMockDataClass.md.html index cfb4576..102123c 100644 --- a/docs/checks/DoNotMockDataClass.md.html +++ b/docs/checks/DoNotMockDataClass.md.html @@ -1,13 +1,13 @@ -(#) data classes represent pure data classes, so mocking them should not be necessary. +(#) data classes represent pure data classes, so mocking them should not be necessary -!!! ERROR: data classes represent pure data classes, so mocking them should not be necessary. +!!! ERROR: data classes represent pure data classes, so mocking them should not be necessary This is an error. Id : `DoNotMockDataClass` Summary -: data classes represent pure data classes, so mocking them should not be necessary. +: data classes represent pure data classes, so mocking them should not be necessary Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DoNotMockObjectClass.md.html b/docs/checks/DoNotMockObjectClass.md.html index 62c6364..8cef152 100644 --- a/docs/checks/DoNotMockObjectClass.md.html +++ b/docs/checks/DoNotMockObjectClass.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DoNotMockPlatformTypes.md.html b/docs/checks/DoNotMockPlatformTypes.md.html index 34927f2..31d3d84 100644 --- a/docs/checks/DoNotMockPlatformTypes.md.html +++ b/docs/checks/DoNotMockPlatformTypes.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DoNotMockRecordClass.md.html b/docs/checks/DoNotMockRecordClass.md.html index e7e54e6..7881a56 100644 --- a/docs/checks/DoNotMockRecordClass.md.html +++ b/docs/checks/DoNotMockRecordClass.md.html @@ -1,13 +1,13 @@ -(#) record classes represent pure data classes, so mocking them should not be necessary. +(#) record classes represent pure data classes, so mocking them should not be necessary -!!! ERROR: record classes represent pure data classes, so mocking them should not be necessary. +!!! ERROR: record classes represent pure data classes, so mocking them should not be necessary This is an error. Id : `DoNotMockRecordClass` Summary -: record classes represent pure data classes, so mocking them should not be necessary. +: record classes represent pure data classes, so mocking them should not be necessary Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DoNotMockSealedClass.md.html b/docs/checks/DoNotMockSealedClass.md.html index 014805d..46a9f16 100644 --- a/docs/checks/DoNotMockSealedClass.md.html +++ b/docs/checks/DoNotMockSealedClass.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/MockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockMockDetectorTest.kt) Copyright Year diff --git a/docs/checks/DrawAllocation.md.html b/docs/checks/DrawAllocation.md.html index 0b75aab..7475de8 100644 --- a/docs/checks/DrawAllocation.md.html +++ b/docs/checks/DrawAllocation.md.html @@ -44,294 +44,37 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/test/pkg/JavaPerformanceTest.java:31:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - new String("foo"); - ----------------- - - -src/test/pkg/JavaPerformanceTest.java:32:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - String s = new String("bar"); - ----------------- - - -src/test/pkg/JavaPerformanceTest.java:95:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - new String("flag me"); - --------------------- - - -src/test/pkg/JavaPerformanceTest.java:101:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - new String("flag me"); - --------------------- - - -src/test/pkg/JavaPerformanceTest.java:104:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - Bitmap.createBitmap(100, 100, null); - ----------------------------------- - - -src/test/pkg/JavaPerformanceTest.java:105:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false); - ----------------------------------------------------------------- - - -src/test/pkg/JavaPerformanceTest.java:106:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - BitmapFactory.decodeFile(null); - ------------------------------ - - -src/test/pkg/JavaPerformanceTest.java:108:Warning: Avoid object -allocations during draw operations: Use Canvas.getClipBounds(Rect) -instead of Canvas.getClipBounds() which allocates a temporary Rect -[DrawAllocation] - - canvas.getClipBounds(); // allocates on your behalf - ---------------------- - - -src/test/pkg/JavaPerformanceTest.java:132:Warning: Avoid object -allocations during draw/layout operations (preallocate and reuse -instead) [DrawAllocation] - - new String("foo"); - ----------------- +src/test/pkg/MyView.java:18:Warning: Avoid object allocations during +draw/layout operations (preallocate and reuse instead) [DrawAllocation] + bitmap = Bitmap.createBitmap(100, 100, null); + ----------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`src/test/pkg/JavaPerformanceTest.java`: +`src/test/pkg/MyView.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers package test.pkg; -import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; -import android.graphics.LinearGradient; -import android.graphics.Rect; -import android.graphics.Shader.TileMode; import android.util.AttributeSet; -import android.util.SparseArray; -import android.widget.Button; -import java.util.HashMap; -import java.util.Map; +import android.view.View; -/** Some test data for the JavaPerformanceDetector */ -@SuppressWarnings("unused") -public class JavaPerformanceTest extends Button { - public JavaPerformanceTest(Context context, AttributeSet attrs, int defStyle) { +public abstract class MyView extends View { + public MyView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } - private Rect cachedRect; - @Override - protected void onDraw(android.graphics.Canvas canvas) { + protected void onDraw(Canvas canvas) { super.onDraw(canvas); - // Various allocations: - new String("foo"); - String s = new String("bar"); - - // This one should not be reported: - @SuppressLint("DrawAllocation") - Integer i = new Integer(5); - - // Cached object initialized lazily: should not complain about these - if (cachedRect == null) { - cachedRect = new Rect(0, 0, 100, 100); - } - if (cachedRect == null || cachedRect.width() != 50) { - cachedRect = new Rect(0, 0, 50, 100); - } - - boolean b = Boolean.valueOf(true); // auto-boxing - sample(1, 2); - - // Non-allocations - super.animate(); - sample2(1, 2); - int x = 4 + '5'; - - // This will involve allocations, but we don't track - // inter-procedural stuff here - someOtherMethod(); - } - - void sample(Integer foo, int bar) { - sample2(foo, bar); - } - - void sample2(int foo, int bar) { - } - - void someOtherMethod() { - // Allocations are okay here - new String("foo"); - String s = new String("bar"); - boolean b = Boolean.valueOf(true); // auto-boxing - } - - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec, - boolean x) { // wrong signature - new String("not an error"); + bitmap = Bitmap.createBitmap(100, 100, null); } - protected void onMeasure(int widthMeasureSpec) { // wrong signature - new String("not an error"); - } - - protected void onLayout(boolean changed, int left, int top, int right, - int bottom, int wrong) { // wrong signature - new String("not an error"); - } - - protected void onLayout(boolean changed, int left, int top, int right) { - // wrong signature - new String("not an error"); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, - int bottom) { - new String("flag me"); - } - - @SuppressWarnings("null") // not real code - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - new String("flag me"); - - // Forbidden factory methods: - Bitmap.createBitmap(100, 100, null); - android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false); - BitmapFactory.decodeFile(null); - Canvas canvas = null; - canvas.getClipBounds(); // allocates on your behalf - canvas.getClipBounds(null); // NOT an error - - final int layoutWidth = getWidth(); - final int layoutHeight = getHeight(); - if (mAllowCrop && (mOverlay == null || mOverlay.getWidth() != layoutWidth || - mOverlay.getHeight() != layoutHeight)) { - mOverlay = Bitmap.createBitmap(layoutWidth, layoutHeight, Bitmap.Config.ARGB_8888); - mOverlayCanvas = new Canvas(mOverlay); - } - - if (widthMeasureSpec == 42) { - throw new IllegalStateException("Test"); // NOT an allocation - } - - // More lazy init tests - boolean initialized = false; - if (!initialized) { - new String("foo"); - initialized = true; - } - - // NOT lazy initialization - if (!initialized || mOverlay == null) { - new String("foo"); - } - } - - void factories() { - Integer i1 = new Integer(42); - Long l1 = new Long(42L); - Boolean b1 = new Boolean(true); - Character c1 = new Character('c'); - Float f1 = new Float(1.0f); - Double d1 = new Double(1.0); - - // The following should not generate errors: - Object i2 = new foo.bar.Integer(42); - Integer i3 = Integer.valueOf(42); - } - - private boolean mAllowCrop; - private Canvas mOverlayCanvas; - private Bitmap mOverlay; -private abstract class JavaPerformanceTest1 extends JavaPerformanceTest { - @Override - public void layout(int l, int t, int r, int b) { - // Using "this." to reference fields - if (this.shader == null) - this.shader = new LinearGradient(0, 0, getWidth(), 0, GRADIENT_COLORS, null, - TileMode.REPEAT); - } -} private abstract class JavaPerformanceTest2 extends JavaPerformanceTest { - @Override - public void layout(int l, int t, int r, int b) { - int width = getWidth(); - int height = getHeight(); - - if ((shader == null) || (lastWidth != width) || (lastHeight != height)) - { - lastWidth = width; - lastHeight = height; - - shader = new LinearGradient(0, 0, width, 0, GRADIENT_COLORS, null, TileMode.REPEAT); - } - } -} private abstract class JavaPerformanceTest3 extends JavaPerformanceTest { - @Override - public void layout(int l, int t, int r, int b) { - if ((shader == null) || (lastWidth != getWidth()) || (lastHeight != getHeight())) { - } - } -} - public void inefficientSparseArray() { - new SparseArray(); // Use SparseIntArray instead - new SparseArray(); // Use SparseLongArray instead - new SparseArray(); // Use SparseBooleanArray instead - new SparseArray(); // OK - } - - public void longSparseArray() { // but only minSdkVersion >= 17 or if has v4 support lib - Map myStringMap = new HashMap(); - } - - public void byteSparseArray() { // bytes easily apply to ints - Map myByteMap = new HashMap(); - } - - protected LinearGradient shader; - protected int lastWidth; - protected int lastHeight; - protected int[] GRADIENT_COLORS; - - private static class foo { - private static class bar { - private static class Integer { - public Integer(int val) { - } - } - } - } - public JavaPerformanceTest() { - super(null); - } + private Bitmap bitmap; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -339,11 +82,6 @@ [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/JavaPerformanceDetectorTest.java) 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, `JavaPerformanceDetector.test`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/DuplicateActivity.md.html b/docs/checks/DuplicateActivity.md.html index 0285a6a..51c73f1 100644 --- a/docs/checks/DuplicateActivity.md.html +++ b/docs/checks/DuplicateActivity.md.html @@ -42,12 +42,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:15:Error: Duplicate registration for activity com.example.helloworld.HelloWorld [DuplicateActivity] - <activity android:name="com.example.helloworld.HelloWorld" ------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -74,6 +73,40 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DuplicateDefinition.md.html b/docs/checks/DuplicateDefinition.md.html index e2c34ef..cc0e31c 100644 --- a/docs/checks/DuplicateDefinition.md.html +++ b/docs/checks/DuplicateDefinition.md.html @@ -41,12 +41,46 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/strings2.xml:19:Error: wallpaper_instructions has already been defined in this folder [DuplicateDefinition] - <string name="wallpaper_instructions">Tap image to set landscape wallpaper</string> ----------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values/strings2.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -73,6 +107,41 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-cs/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Domů"</string> + <string name="show_all_apps">"Vše"</string> + <string name="menu_wallpaper">"Tapeta"</string> + <string name="menu_search">"Hledat"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Klepnutím na obrázek nastavíte tapetu portrétu"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/customattr.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <declare-styleable name="ContentFrame"> + <attr name="content" format="reference" /> + <attr name="contentId" format="reference" /> + </declare-styleable> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/customattr2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <declare-styleable name="ContentFrame"> + <attr name="content" format="reference" /> + <attr name="contentId" format="reference" /> + </declare-styleable> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/DuplicateResourceDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DuplicateDivider.md.html b/docs/checks/DuplicateDivider.md.html index ed681b4..a978945 100644 --- a/docs/checks/DuplicateDivider.md.html +++ b/docs/checks/DuplicateDivider.md.html @@ -44,7 +44,6 @@ src/com/example/android/supportv7/widget/decorator/DividerItemDecoration.java:11:Warning: Replace with android.support.v7.widget.DividerItemDecoration? [DuplicateDivider] - public abstract class DividerItemDecoration extends RecyclerView.ItemDecoration { --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DuplicateIds.md.html b/docs/checks/DuplicateIds.md.html index a79803f..28f4b3a 100644 --- a/docs/checks/DuplicateIds.md.html +++ b/docs/checks/DuplicateIds.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/duplicate.xml:5:Error: Duplicate id @+id/android_logo, already defined earlier in this layout [DuplicateIds] - <ImageButton android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DuplicateIncludedIds.md.html b/docs/checks/DuplicateIncludedIds.md.html index 4a70db4..a3ea45d 100644 --- a/docs/checks/DuplicateIncludedIds.md.html +++ b/docs/checks/DuplicateIncludedIds.md.html @@ -42,12 +42,11 @@ included multiple times in layout/layout1.xml: [layout/layout1.xml defines @+id/button2, layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button2] [DuplicateIncludedIds] - <include ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/layout1.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -76,6 +75,77 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/layout2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="RadioButton" /> + + <include + android:layout_width="wrap_content" + android:layout_height="wrap_content" + layout="@layout/layout3" /> + + <include + android:layout_width="wrap_content" + android:layout_height="wrap_content" + layout="@layout/layout4" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/layout3.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="CheckBox" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/layout4.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/DuplicateIdDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/DuplicatePlatformClasses.md.html b/docs/checks/DuplicatePlatformClasses.md.html index c648002..8931987 100644 --- a/docs/checks/DuplicatePlatformClasses.md.html +++ b/docs/checks/DuplicatePlatformClasses.md.html @@ -45,6 +45,92 @@ !!! Tip This lint check has an associated quickfix available in the IDE. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +build.gradle:3:Error: xpp3 defines classes that conflict with classes +now provided by Android. Solutions include finding newer versions or +alternative libraries that don't have the same problem (for example, for +httpclient use HttpUrlConnection or okhttp instead), or repackaging the +library using something like jarjar. [DuplicatePlatformClasses] + implementation 'xpp3:xpp3:1.1.4c' + --------------------------------- +build.gradle:4:Error: commons-logging defines classes that conflict with +classes now provided by Android. Solutions include finding newer +versions or alternative libraries that don't have the same problem (for +example, for httpclient use HttpUrlConnection or okhttp instead), or +repackaging the library using something like jarjar. +[DuplicatePlatformClasses] + implementation 'commons-logging:commons-logging:1.2' + ---------------------------------------------------- +build.gradle:5:Error: xmlParserAPIs defines classes that conflict with +classes now provided by Android. Solutions include finding newer +versions or alternative libraries that don't have the same problem (for +example, for httpclient use HttpUrlConnection or okhttp instead), or +repackaging the library using something like jarjar. +[DuplicatePlatformClasses] + implementation 'xerces:xmlParserAPIs:2.6.2' + ------------------------------------------- +build.gradle:6:Error: json defines classes that conflict with classes +now provided by Android. Solutions include finding newer versions or +alternative libraries that don't have the same problem (for example, for +httpclient use HttpUrlConnection or okhttp instead), or repackaging the +library using something like jarjar. [DuplicatePlatformClasses] + implementation 'org.json:json:20170516' + --------------------------------------- +build.gradle:7:Error: opengl-api defines classes that conflict with +classes now provided by Android. Solutions include finding newer +versions or alternative libraries that don't have the same problem (for +example, for httpclient use HttpUrlConnection or okhttp instead), or +repackaging the library using something like jarjar. +[DuplicatePlatformClasses] + implementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1' + ------------------------------------------------------------ +build.gradle:8:Error: android defines classes that conflict with classes +now provided by Android. Solutions include finding newer versions or +alternative libraries that don't have the same problem (for example, for +httpclient use HttpUrlConnection or okhttp instead), or repackaging the +library using something like jarjar. [DuplicatePlatformClasses] + implementation 'com.google.android:android:4.1.1.4' + --------------------------------------------------- +build.gradle:9:Error: httpclient defines classes that conflict with +classes now provided by Android. Solutions include finding newer +versions or alternative libraries that don't have the same problem (for +example, for httpclient use HttpUrlConnection or okhttp instead), or +repackaging the library using something like jarjar. +[DuplicatePlatformClasses] + compile group: 'org.apache.httpcomponents', + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +dependencies { + implementation 'my.indirect.dependency:myname:1.2.3' + implementation 'xpp3:xpp3:1.1.4c' + implementation 'commons-logging:commons-logging:1.2' + implementation 'xerces:xmlParserAPIs:2.6.2' + implementation 'org.json:json:20170516' + implementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1' + implementation 'com.google.android:android:4.1.1.4' + compile group: 'org.apache.httpcomponents', + name: 'httpclient', + version: '4.5.3' +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/GradleDetectorTest.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, `GradleDetector.testDuplicateWarnings`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=192708. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/DuplicateStrings.md.html b/docs/checks/DuplicateStrings.md.html index 327bbc8..f5c6b2d 100644 --- a/docs/checks/DuplicateStrings.md.html +++ b/docs/checks/DuplicateStrings.md.html @@ -47,16 +47,12 @@ HELLO, used in hello_caps and hello. Use android:inputType or android:capitalize to treat these as the same and avoid string duplication. [DuplicateStrings] - <string name="hello">hello</string> ----------------------------------- - - res/values/duplicate_strings.xml:5:Warning: Duplicate string value Hello World, used in hello_world and title_casing_hello_world. Use android:inputType or android:capitalize to treat these as the same and avoid string duplication. [DuplicateStrings] - <string name="hello_world">hello world</string> ----------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/DuplicateUsesFeature.md.html b/docs/checks/DuplicateUsesFeature.md.html index 3d3d64c..d2c2a8d 100644 --- a/docs/checks/DuplicateUsesFeature.md.html +++ b/docs/checks/DuplicateUsesFeature.md.html @@ -37,12 +37,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:9:Warning: Duplicate declaration of uses-feature android.hardware.camera [DuplicateUsesFeature] - <uses-feature android:name="android.hardware.camera"/> -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -64,6 +63,40 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/EasterEgg.md.html b/docs/checks/EasterEgg.md.html index 1855389..2e54c03 100644 --- a/docs/checks/EasterEgg.md.html +++ b/docs/checks/EasterEgg.md.html @@ -42,15 +42,11 @@ src/test/pkg/Hidden.java:5:Warning: Code might be hidden here; found unicode escape sequence which is interpreted as comment end, compiled code follows [EasterEgg] - /* \u002a\u002f static { System.out.println("I'm executed on class load"); } \u002f\u002a */ ------------ - - src/test/pkg/Hidden.java:6:Warning: Code might be hidden here; found unicode escape sequence which is interpreted as comment end, compiled code follows [EasterEgg] - /* \u002A\U002F static { System.out.println("I'm executed on class load"); } \u002f\u002a */ ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/EllipsizeMaxLines.md.html b/docs/checks/EllipsizeMaxLines.md.html index b93ec78..19c45e5 100644 --- a/docs/checks/EllipsizeMaxLines.md.html +++ b/docs/checks/EllipsizeMaxLines.md.html @@ -45,14 +45,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/sample.xml:9:Error: Combining ellipsize=start and lines=1 can lead to crashes. Use singleLine=true instead. [EllipsizeMaxLines] - android:lines="1" ----------------- - - res/layout/sample.xml:16:Error: Combining ellipsize=start and maxLines=1 can lead to crashes. Use singleLine=true instead. [EllipsizeMaxLines] - android:maxLines="1" -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/EmptyNavDeepLink-2.md.html b/docs/checks/EmptyNavDeepLink-2.md.html index a6f9132..0a26bd6 100644 --- a/docs/checks/EmptyNavDeepLink-2.md.html +++ b/docs/checks/EmptyNavDeepLink-2.md.html @@ -1,13 +1,13 @@ -(#) NavDeepLink must define an uri, action, and/or mimetype to be valid. +(#) NavDeepLink must define an uri, action, and/or mimetype to be valid -!!! ERROR: NavDeepLink must define an uri, action, and/or mimetype to be valid. +!!! ERROR: NavDeepLink must define an uri, action, and/or mimetype to be valid This is an error. Id : `EmptyNavDeepLink` Summary -: NavDeepLink must define an uri, action, and/or mimetype to be valid. +: NavDeepLink must define an uri, action, and/or mimetype to be valid Severity : Error Category @@ -48,12 +48,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/com/example/test.kt:6:Error: Creation of empty NavDeepLink [EmptyNavDeepLink] - navDeepLink { } ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/com/example/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -66,6 +65,13 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/androidx/navigation/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package androidx.navigation + +public fun navDeepLink(deepLinkBuilder: NavDeepLinkDslBuilder.() -> Unit): NavDeepLink {} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-common-lint/src/test/java/androidx/navigation/common/lint/EmptyNavDeepLinkDetectorTest.kt) for the unit tests for this check to see additional scenarios. @@ -80,9 +86,9 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* EmptyNavDeepLink: NavDeepLink must define an uri, action, and/or mimetype to be valid. (this issue) -* [EmptyNavDeepLink from androidx.navigation:navigation-compose:2.8.0-beta04](EmptyNavDeepLink.md.html) -* [EmptyNavDeepLink from androidx.navigation:navigation-common:2.8.0-beta04](EmptyNavDeepLink-2.md.html) +* EmptyNavDeepLink: NavDeepLink must define an uri, action, and/or mimetype to be valid (this issue) +* [EmptyNavDeepLink from androidx.navigation:navigation-compose:2.8.0-beta05](EmptyNavDeepLink.md.html) +* [EmptyNavDeepLink from androidx.navigation:navigation-common:2.8.0-beta05](EmptyNavDeepLink-2.md.html) (##) Including @@ -93,17 +99,17 @@ ``` // build.gradle.kts -implementation("androidx.navigation:navigation-common:2.8.0-beta04") +implementation("androidx.navigation:navigation-common:2.8.0-beta05") // build.gradle -implementation 'androidx.navigation:navigation-common:2.8.0-beta04' +implementation 'androidx.navigation:navigation-common:2.8.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.navigation-common) # libs.versions.toml [versions] -navigation-common = "2.8.0-beta04" +navigation-common = "2.8.0-beta05" [libraries] navigation-common = { module = "androidx.navigation:navigation-common", @@ -111,7 +117,7 @@ } ``` -2.8.0-beta04 is the version this documentation was generated from; +2.8.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.navigation:navigation-common](androidx_navigation_navigation-common.md.html). diff --git a/docs/checks/EmptyNavDeepLink.md.html b/docs/checks/EmptyNavDeepLink.md.html index 0d454a7..e70ebd3 100644 --- a/docs/checks/EmptyNavDeepLink.md.html +++ b/docs/checks/EmptyNavDeepLink.md.html @@ -1,13 +1,13 @@ -(#) NavDeepLink must define an uri, action, and/or mimetype to be valid. +(#) NavDeepLink must define an uri, action, and/or mimetype to be valid -!!! ERROR: NavDeepLink must define an uri, action, and/or mimetype to be valid. +!!! ERROR: NavDeepLink must define an uri, action, and/or mimetype to be valid This is an error. Id : `EmptyNavDeepLink` Summary -: NavDeepLink must define an uri, action, and/or mimetype to be valid. +: NavDeepLink must define an uri, action, and/or mimetype to be valid Severity : Error Category @@ -48,12 +48,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/com/example/test.kt:6:Error: Creation of empty NavDeepLink [EmptyNavDeepLink] - navDeepLink { } ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/com/example/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -66,6 +65,13 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/androidx/navigation/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package androidx.navigation + +public fun navDeepLink(deepLinkBuilder: NavDeepLinkDslBuilder.() -> Unit): NavDeepLink {} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/navigation/navigation-common-lint/src/test/java/androidx/navigation/common/lint/EmptyNavDeepLinkDetectorTest.kt) for the unit tests for this check to see additional scenarios. @@ -80,9 +86,9 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* EmptyNavDeepLink: NavDeepLink must define an uri, action, and/or mimetype to be valid. (this issue) -* [EmptyNavDeepLink from androidx.navigation:navigation-compose:2.8.0-beta04](EmptyNavDeepLink.md.html) -* [EmptyNavDeepLink from androidx.navigation:navigation-common:2.8.0-beta04](EmptyNavDeepLink-2.md.html) +* EmptyNavDeepLink: NavDeepLink must define an uri, action, and/or mimetype to be valid (this issue) +* [EmptyNavDeepLink from androidx.navigation:navigation-compose:2.8.0-beta05](EmptyNavDeepLink.md.html) +* [EmptyNavDeepLink from androidx.navigation:navigation-common:2.8.0-beta05](EmptyNavDeepLink-2.md.html) (##) Including @@ -93,17 +99,17 @@ ``` // build.gradle.kts -implementation("androidx.navigation:navigation-compose:2.8.0-beta04") +implementation("androidx.navigation:navigation-compose:2.8.0-beta05") // build.gradle -implementation 'androidx.navigation:navigation-compose:2.8.0-beta04' +implementation 'androidx.navigation:navigation-compose:2.8.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.navigation-compose) # libs.versions.toml [versions] -navigation-compose = "2.8.0-beta04" +navigation-compose = "2.8.0-beta05" [libraries] navigation-compose = { module = "androidx.navigation:navigation-compose", @@ -111,7 +117,7 @@ } ``` -2.8.0-beta04 is the version this documentation was generated from; +2.8.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.navigation:navigation-compose](androidx_navigation_navigation-compose.md.html). diff --git a/docs/checks/EmptySuperCall.md.html b/docs/checks/EmptySuperCall.md.html index 49d2a02..d1811f5 100644 --- a/docs/checks/EmptySuperCall.md.html +++ b/docs/checks/EmptySuperCall.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/ParentClass.kt:22:Warning: No need to call super.someOtherMethod; the super method is defined to be empty [EmptySuperCall] - super.someOtherMethod(arg) // ERROR --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/EnforceUTF8.md.html b/docs/checks/EnforceUTF8.md.html index 28a14a3..70544f5 100644 --- a/docs/checks/EnforceUTF8.md.html +++ b/docs/checks/EnforceUTF8.md.html @@ -49,7 +49,6 @@ res/layout/encoding.xml:1:Error: iso-latin-1: Not using UTF-8 as the file encoding. This can lead to subtle bugs with non-ascii characters [EnforceUTF8] - <?xml version="1.0" encoding="iso-latin-1"?> ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/EnqueueWork.md.html b/docs/checks/EnqueueWork.md.html index 54b0bd5..93a619a 100644 --- a/docs/checks/EnqueueWork.md.html +++ b/docs/checks/EnqueueWork.md.html @@ -39,35 +39,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/WorkManagerTest.java:15:Warning: WorkContinuation cont not enqueued: did you forget to call enqueue()? [EnqueueWork] - WorkContinuation cont = workManager.beginWith(workRequest1, workRequest2); // ERROR ------------------------------------------------- - - src/test/pkg/WorkManagerTest.java:22:Warning: WorkContinuation not enqueued: did you forget to call enqueue()? [EnqueueWork] - workManager.beginWith(workRequest1, workRequest2); // ERROR ------------------------------------------------- - - src/test/pkg/WorkManagerTest.java:46:Warning: WorkContinuation cont2 not enqueued: did you forget to call enqueue()? [EnqueueWork] - WorkContinuation cont2 = cont1.then(workRequest3).then(workRequest4); // ERROR ------------------------------------------- - - src/test/pkg/WorkManagerTest.java:47:Warning: WorkContinuation cont3 not enqueued: did you forget to call enqueue()? [EnqueueWork] - WorkContinuation cont3 = cont1.then(workRequest5); // ERROR ------------------------ - - src/test/pkg/WorkManagerTest.java:59:Warning: WorkContinuation cont4 not enqueued: did you forget to call enqueue()? [EnqueueWork] - WorkContinuation cont4 = WorkContinuation.combine(workRequest6, cont2, cont3); // ERROR ---------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/EnsureInitializerMetadata.md.html b/docs/checks/EnsureInitializerMetadata.md.html index 32a44fb..4f279a1 100644 --- a/docs/checks/EnsureInitializerMetadata.md.html +++ b/docs/checks/EnsureInitializerMetadata.md.html @@ -1,7 +1,7 @@ -(#) Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml file. +(#) Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml file -!!! ERROR: Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml file. +!!! ERROR: Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml file This is an error, and is also enforced at build time when supported by the build system. For Android this means it will run during release builds. @@ -9,7 +9,7 @@ Id : `EnsureInitializerMetadata` Summary -: Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml file. +: Every Initializer needs to be accompanied by a corresponding entry in the AndroidManifest.xml file Severity : Fatal Category @@ -33,8 +33,12 @@ : Kotlin and Java files and manifest files Editing : This check can *not* run live in the IDE editor +Implementation +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/startup/startup-runtime-lint/src/main/java/androidx/startup/lint/EnsureInitializerMetadataDetector.kt) Tests : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/startup/startup-runtime-lint/src/test/java/androidx/startup/lint/EnsureInitializerMetadataTest.kt) +Copyright Year +: 2020 When a library defines a Initializer, it needs to be accompanied by a corresponding entry in the AndroidManifest.xml file. diff --git a/docs/checks/EnsureInitializerNoArgConstr.md.html b/docs/checks/EnsureInitializerNoArgConstr.md.html index 36b429c..a382b1d 100644 --- a/docs/checks/EnsureInitializerNoArgConstr.md.html +++ b/docs/checks/EnsureInitializerNoArgConstr.md.html @@ -42,6 +42,38 @@ Every `Initializer` must have a no argument constructor. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/TestInitializer.kt:5:Error: Missing Initializer no-arg +constructor [EnsureInitializerNoArgConstr] +class TestInitializer(val int: Int): Initializer<Unit> { +^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`com/example/TestInitializer.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import androidx.startup.Initializer + +class TestInitializer(val int: Int): Initializer { + +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/startup/startup-runtime-lint/src/test/java/androidx/startup/lint/InitializerConstructorTest.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, `InitializerConstructorDetector.testFailureWhenZeroNoArgumentConstructorsArePresent`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=823348. + (##) Including !!! diff --git a/docs/checks/ErroneousLayoutAttribute.md.html b/docs/checks/ErroneousLayoutAttribute.md.html index 7c7e16e..4daa83b 100644 --- a/docs/checks/ErroneousLayoutAttribute.md.html +++ b/docs/checks/ErroneousLayoutAttribute.md.html @@ -1,13 +1,13 @@ -(#) Layout attribute that's not applicable to a particular view. +(#) Layout attribute that's not applicable to a particular view -!!! WARNING: Layout attribute that's not applicable to a particular view. +!!! WARNING: Layout attribute that's not applicable to a particular view This is a warning. Id : `ErroneousLayoutAttribute` Summary -: Layout attribute that's not applicable to a particular view. +: Layout attribute that's not applicable to a particular view Severity : Warning Category @@ -29,9 +29,47 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/ErroneousLayoutAttributeDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ErroneousLayoutAttributeDetectorTest.kt) Flags if a layout attribute is not applicable to a particular view. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:5:Warning: Attribute is erroneous on FrameLayout +[ErroneousLayoutAttribute] + android:orientation="horizontal" + -------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ErroneousLayoutAttributeDetectorTest.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, `ErroneousLayoutAttributeDetector.erroneousFrameLayoutOrientation`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/ErrorProneDoNotMockUsage.md.html b/docs/checks/ErrorProneDoNotMockUsage.md.html index 1f43137..856bf42 100644 --- a/docs/checks/ErrorProneDoNotMockUsage.md.html +++ b/docs/checks/ErrorProneDoNotMockUsage.md.html @@ -1,13 +1,13 @@ -(#) Use Slack's internal `@DoNotMock` annotation. +(#) Use Slack's internal `@DoNotMock` annotation -!!! ERROR: Use Slack's internal `@DoNotMock` annotation. +!!! ERROR: Use Slack's internal `@DoNotMock` annotation This is an error. Id : `ErrorProneDoNotMockUsage` Summary -: Use Slack's internal `@DoNotMock` annotation. +: Use Slack's internal `@DoNotMock` annotation Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/mocking/ErrorProneDoNotMockDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/mocking/ErrorProneDoNotMockDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/mocking/DoNotMockUsageDetectorTest.kt) Copyright Year @@ -53,14 +53,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/test/TestClass.kt:10:Error: Use Slack's internal @DoNotMock annotation. [ErrorProneDoNotMockUsage] - @com.google.errorprone.annotations.DoNotMock("Use fake()") ---------------------------------------------------------- - - src/slack/test/TestClass.kt:20:Error: Use Slack's internal @DoNotMock annotation. [ErrorProneDoNotMockUsage] - @DoNotMock ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExactAlarm.md.html b/docs/checks/ExactAlarm.md.html index 73d0997..bc9e3f8 100644 --- a/docs/checks/ExactAlarm.md.html +++ b/docs/checks/ExactAlarm.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:2:Error: USE_EXACT_ALARM can only be used when targeting API level 33 or higher [ExactAlarm] - <uses-permission android:name="android.permission.USE_EXACT_ALARM" /> ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExceptionMessage.md.html b/docs/checks/ExceptionMessage.md.html index 0405712..480195c 100644 --- a/docs/checks/ExceptionMessage.md.html +++ b/docs/checks/ExceptionMessage.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/ExceptionMessageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/ExceptionMessageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/ExceptionMessageDetectorTest.kt) Copyright Year @@ -56,7 +56,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:5:Error: Please specify a lazyMessage param for check [ExceptionMessage] - check(true) ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExifInterface.md.html b/docs/checks/ExifInterface.md.html index 657dfe4..e5e9945 100644 --- a/docs/checks/ExifInterface.md.html +++ b/docs/checks/ExifInterface.md.html @@ -40,23 +40,16 @@ src/test/pkg/ExifUsage.java:3:Warning: Avoid using android.media.ExifInterface; use androidx.exifinterface.media.ExifInterface instead [ExifInterface] - import android.media.ExifInterface; --------------------------- - - src/test/pkg/ExifUsage.java:13:Warning: Avoid using android.media.ExifInterface; use androidx.exifinterface.media.ExifInterface instead [ExifInterface] - android.media.ExifInterface exif2 = --------------------------- - - src/test/pkg/ExifUsage.java:14:Warning: Avoid using android.media.ExifInterface; use androidx.exifinterface.media.ExifInterface instead [ExifInterface] - new android.media.ExifInterface(path); --------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExpensiveAssertion.md.html b/docs/checks/ExpensiveAssertion.md.html index aed6d66..b2ad61f 100644 --- a/docs/checks/ExpensiveAssertion.md.html +++ b/docs/checks/ExpensiveAssertion.md.html @@ -80,12 +80,11 @@ always evaluated, even when assertions are off. Consider surrounding assertion with if (javaClass.desiredAssertionStatus()) { assert(...) } [ExpensiveAssertion] - assert(expensive()) // WARN ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/AssertTest.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -130,6 +129,42 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +fun testExpensive() { + assert(expensive()) // no suggestion to surround with javaClass from toplevel + assert(cheap()) + assert(cheap2(0)) + assert(cheap3()) +} +private fun expensive(): Boolean { + Thread.sleep(500) + return true +} + +const val DEBUGGING = false +private fun cheap(): Boolean { + return DEBUGGING +} +private fun cheap2(x: Int): Boolean = x < 10 +private fun cheap3() = test.pkg.Utils.isDiagnosing() + +fun castOkay(foo: Any) { + assert(foo is String) // OK +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/Utils.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; +public class Utils { + public static final boolean DIAGNOSE = false; + public static boolean isDiagnosing() { + return DIAGNOSE; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/AssertDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ExpiredTargetSdkVersion.md.html b/docs/checks/ExpiredTargetSdkVersion.md.html index 7c354ec..00674bc 100644 --- a/docs/checks/ExpiredTargetSdkVersion.md.html +++ b/docs/checks/ExpiredTargetSdkVersion.md.html @@ -53,14 +53,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:5:Error: Google Play requires that apps target API level 31 or higher. [ExpiredTargetSdkVersion] - targetSdkVersion 17 ------------------- - - build.gradle:6:Error: Google Play requires that apps target API level 31 or higher. [ExpiredTargetSdkVersion] - targetSdk 17 ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExpiringTargetSdkVersion.md.html b/docs/checks/ExpiringTargetSdkVersion.md.html index dea3238..6c0c80a 100644 --- a/docs/checks/ExpiringTargetSdkVersion.md.html +++ b/docs/checks/ExpiringTargetSdkVersion.md.html @@ -52,7 +52,6 @@ build.gradle:6:Warning: Google Play will soon require that apps target API level 33 or higher. This will be required for new apps and updates starting on August 31, 2023. [ExpiringTargetSdkVersion] - targetSdkVersion 31 ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExportedContentProvider.md.html b/docs/checks/ExportedContentProvider.md.html index e2f5bd2..a9802d9 100644 --- a/docs/checks/ExportedContentProvider.md.html +++ b/docs/checks/ExportedContentProvider.md.html @@ -46,19 +46,15 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:14:Warning: Exported content providers can provide access to potentially sensitive data [ExportedContentProvider] - <provider -------- - - AndroidManifest.xml:20:Warning: Exported content providers can provide access to potentially sensitive data [ExportedContentProvider] - <provider -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -97,6 +93,41 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/SecurityDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ExportedPreferenceActivity.md.html b/docs/checks/ExportedPreferenceActivity.md.html index 88e86d8..51d4225 100644 --- a/docs/checks/ExportedPreferenceActivity.md.html +++ b/docs/checks/ExportedPreferenceActivity.md.html @@ -43,7 +43,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:28:Warning: PreferenceActivity should not be exported [ExportedPreferenceActivity] - <activity ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExportedReceiver.md.html b/docs/checks/ExportedReceiver.md.html index 96f4afd..7cc3ad2 100644 --- a/docs/checks/ExportedReceiver.md.html +++ b/docs/checks/ExportedReceiver.md.html @@ -46,12 +46,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:12:Warning: Exported receiver does not require permission [ExportedReceiver] - <receiver -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -80,6 +79,41 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/SecurityDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ExportedService.md.html b/docs/checks/ExportedService.md.html index 025550e..6c7a6c5 100644 --- a/docs/checks/ExportedService.md.html +++ b/docs/checks/ExportedService.md.html @@ -45,12 +45,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:12:Warning: Exported service does not require permission [ExportedService] - <service ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -81,6 +80,41 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/SecurityDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ExposedRootPath.md.html b/docs/checks/ExposedRootPath.md.html new file mode 100644 index 0000000..b84e381 --- /dev/null +++ b/docs/checks/ExposedRootPath.md.html @@ -0,0 +1,136 @@ + +(#) Application specifies the device root directory + +!!! WARNING: Application specifies the device root directory + This is a warning. + +Id +: `ExposedRootPath` +Summary +: Application specifies the device root directory +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Resource files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/ExposedRootPath +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/MisconfiguredFileProviderDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MisconfiguredFileProviderDetectorTest.kt) +Copyright Year +: 2023 + +Allowing the device root directory in the `FileProvider` configuration +provides arbitrary access to files and folders for attackers, thereby +increasing the attack surface. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/xml/file_paths.xml:5:Warning: Do not use as it provides +arbitrary access to device files and folders [ExposedRootPath] + <root-path name="root" path="/"/> + --------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/xml/file_paths.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> + <paths xmlns:android="http://schemas.android.com/apk/res/android"> + <files-path name="my_images" path="images/"/> + <files-path name="my_docs" path="docs/"/> + <root-path name="root" path="/"/> + </paths> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MisconfiguredFileProviderDetectorTest.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, `MisconfiguredFileProviderDetector.testWhenRootPathUsedInConfig_showsWarningAndQuickFix`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute `tools:ignore="ExposedRootPath"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <lint> + <issue id="ExposedRootPath" 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 'ExposedRootPath' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore ExposedRootPath ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/ExtraText.md.html b/docs/checks/ExtraText.md.html index 6371609..d56c83c 100644 --- a/docs/checks/ExtraText.md.html +++ b/docs/checks/ExtraText.md.html @@ -41,14 +41,10 @@ AndroidManifest.xml:7:Error: Unexpected text found in manifest file: "android:label="Android AdServices" android:forceQueryable="true" android:directBootAware="true">" [ExtraText] - android:label="Android AdServices" ^ - - res/drawable/icon.xml:1:Warning: Unexpected text found in drawable file: ">" [ExtraText] - <shape>> - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ExtraTranslation.md.html b/docs/checks/ExtraTranslation.md.html index ff035a8..22cdb2b 100644 --- a/docs/checks/ExtraTranslation.md.html +++ b/docs/checks/ExtraTranslation.md.html @@ -50,12 +50,61 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values-de-rDE/strings.xml:11:Error: "continue_skip_label" is translated here but not found in default locale [ExtraTranslation] - <string name="continue_skip_label">"Weiter"</string> -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-cs/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Domů"</string> + <string name="show_all_apps">"Vše"</string> + <string name="menu_wallpaper">"Tapeta"</string> + <string name="menu_search">"Hledat"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Klepnutím na obrázek nastavíte tapetu portrétu"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values-de-rDE/strings.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -73,6 +122,115 @@ </resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-es/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Casa"</string> + <string name="show_all_apps">"Todo"</string> + <string name="menu_wallpaper">"Papel tapiz"</string> + <string name="menu_search">"Búsqueda"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string> + + <string-array name="security_questions"> + <item>"Comida favorita"</item> + <item>"Ciudad de nacimiento"</item> + <item>"Nombre de tu mejor amigo/a de la infancia"</item> + <item>"Nombre de tu colegio"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-es-rUS/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="menu_search">"Búsqueda"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-land/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap image to set landscape wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-cs/arrays.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string-array name="security_questions"> + <item>"Oblíbené jídlo?"</item> + <item>"Město narození."</item> + <item>"Jméno nejlepšího kamaráda z dětství?"</item> + <item>"Název střední školy"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-es/donottranslate.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="full_wday_month_day_no_year">EEEE, d MMMM</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-nl-rNL/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Start"</string> + <!-- Commented out in the unit test to generate extra warnings: + <string name="show_all_apps">"Alles"</string> + <string name="menu_wallpaper">"Achtergrond"</string> + --> + <string name="menu_search">"Zoeken"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Tik op afbeelding om portretachtergrond in te stellen"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/public.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources><public /></resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/foo.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout-ja/foo.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/TranslationDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/FieldSiteTargetOnQualifierAnnotation.md.html b/docs/checks/FieldSiteTargetOnQualifierAnnotation.md.html index 8006add..8743099 100644 --- a/docs/checks/FieldSiteTargetOnQualifierAnnotation.md.html +++ b/docs/checks/FieldSiteTargetOnQualifierAnnotation.md.html @@ -1,13 +1,13 @@ -(#) Redundant 'field:' used for Dagger qualifier annotation. +(#) Redundant 'field:' used for Dagger qualifier annotation -!!! WARNING: Redundant 'field:' used for Dagger qualifier annotation. +!!! WARNING: Redundant 'field:' used for Dagger qualifier annotation This is a warning. Id : `FieldSiteTargetOnQualifierAnnotation` Summary -: Redundant 'field:' used for Dagger qualifier annotation. +: Redundant 'field:' used for Dagger qualifier annotation Severity : Warning Category @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:14:Warning: Redundant 'field:' used for Dagger qualifier annotation. [FieldSiteTargetOnQualifierAnnotation] - @field:MyQualifier ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FileEndsWithExt.md.html b/docs/checks/FileEndsWithExt.md.html index f249547..104da70 100644 --- a/docs/checks/FileEndsWithExt.md.html +++ b/docs/checks/FileEndsWithExt.md.html @@ -41,21 +41,14 @@ src/test.kt:4:Warning: File.endsWith compares whole filenames, not just file extensions; did you mean file.path.endsWith(".xml") ? [FileEndsWithExt] - fun File.isXml() = endsWith(".xml") ---------------- - - src/test.kt:7:Warning: File.extension does not include the leading dot; did you mean "json" ? [FileEndsWithExt] - fun File.isJson() = extension == ".json" ------- - - src/test.kt:8:Warning: File.extension does not include the leading dot; did you mean "webp" ? [FileEndsWithExt] - fun isWebp(path: File) = path.extension.startsWith(".webp") ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FindViewByIdCast.md.html b/docs/checks/FindViewByIdCast.md.html index efbb154..1bcd695 100644 --- a/docs/checks/FindViewByIdCast.md.html +++ b/docs/checks/FindViewByIdCast.md.html @@ -49,12 +49,11 @@ src/main/java/test/pkg/ImplicitCastTest2.java:9:Warning: Add explicit cast here; won't compile with Java language level 1.8 without it [FindViewByIdCast] - checkNotNull1(findViewById(R.id.textView)).setAlpha(0.5f); // WARN --------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/main/java/test/pkg/ImplicitCastTest2.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -107,6 +106,16 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ViewTypeDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/FlowOperatorInvokedInComposition.md.html b/docs/checks/FlowOperatorInvokedInComposition.md.html index 1c341d3..3c4ae4e 100644 --- a/docs/checks/FlowOperatorInvokedInComposition.md.html +++ b/docs/checks/FlowOperatorInvokedInComposition.md.html @@ -51,159 +51,101 @@ src/androidx/compose/runtime/foo/test.kt:15:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:16:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- - - src/androidx/compose/runtime/foo/test.kt:21:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .map { true } --- - - src/androidx/compose/runtime/foo/test.kt:22:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:23:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- - - src/androidx/compose/runtime/foo/test.kt:28:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .map { true } --- - - src/androidx/compose/runtime/foo/test.kt:29:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:30:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- - - src/androidx/compose/runtime/foo/test.kt:40:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .map { true } --- - - src/androidx/compose/runtime/foo/test.kt:41:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:42:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- - - src/androidx/compose/runtime/foo/test.kt:46:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .map { true } --- - - src/androidx/compose/runtime/foo/test.kt:47:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:48:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- - - src/androidx/compose/runtime/foo/test.kt:55:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .map { true } --- - - src/androidx/compose/runtime/foo/test.kt:56:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:57:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- - - src/androidx/compose/runtime/foo/test.kt:62:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .map { true } --- - - src/androidx/compose/runtime/foo/test.kt:63:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .customOperator(true) -------------- - - src/androidx/compose/runtime/foo/test.kt:64:Error: Flow operator functions should not be invoked within composition [FlowOperatorInvokedInComposition] - .drop(0) ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -296,17 +238,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -314,7 +256,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/FontValidation.md.html b/docs/checks/FontValidation.md.html index 72ac549..8c2b3e9 100644 --- a/docs/checks/FontValidation.md.html +++ b/docs/checks/FontValidation.md.html @@ -46,7 +46,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/font/font1.xml:4:Error: A downloadable font cannot have a sub tag [FontValidation] - <font ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ForegroundServicePermission.md.html b/docs/checks/ForegroundServicePermission.md.html index 67abee9..22954b6 100644 --- a/docs/checks/ForegroundServicePermission.md.html +++ b/docs/checks/ForegroundServicePermission.md.html @@ -43,7 +43,6 @@ permission:[android.permission.FOREGROUND_SERVICE_CAMERA] AND any permission in list:[android.permission.CAMERA, android.permission.SYSTEM_CAMERA] [ForegroundServicePermission] - <service ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ForegroundServiceType.md.html b/docs/checks/ForegroundServiceType.md.html index 90a0fef..ff02791 100644 --- a/docs/checks/ForegroundServiceType.md.html +++ b/docs/checks/ForegroundServiceType.md.html @@ -40,7 +40,6 @@ src/test/pkg/MyService.java:8:Error: To call Service.startForeground(), the element of manifest file must have the foregroundServiceType attribute specified [ForegroundServiceType] - startForeground(1, null); --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FormalGerman.md.html b/docs/checks/FormalGerman.md.html index cd971bb..a5eb627 100644 --- a/docs/checks/FormalGerman.md.html +++ b/docs/checks/FormalGerman.md.html @@ -1,13 +1,13 @@ -(#) Marks strings which contain formal German words. +(#) Marks strings which contain formal German words -!!! WARNING: Marks strings which contain formal German words. +!!! WARNING: Marks strings which contain formal German words This is a warning. Id : `FormalGerman` Summary -: Marks strings which contain formal German words. +: Marks strings which contain formal German words Severity : Warning Category @@ -29,9 +29,61 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/FormalGermanDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/FormalGermanDetectorTest.kt) Informal language should be used at all times. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/values/config.xml:2:Warning: Formal language "Ihr" detected +[FormalGerman] + <string name="my_string_1">Wie lautet Ihr Name?</string> + ^ +res/values/config.xml:3:Warning: Formal language "Sie?" detected +[FormalGerman] + <string name="my_string_2">Wie heissen Sie?</string> + ^ +res/values/config.xml:4:Warning: Formal language "Ihrem" detected +[FormalGerman] + <string name="my_string_3">Frag nach Ihrem Namen.</string> + ^ +res/values/config.xml:5:Warning: Formal language "Sie" detected +[FormalGerman] + <string name="my_string_4">Wie Sie möchten</string> + ^ +res/values/config.xml:6:Warning: Formal language "Ihre" detected +[FormalGerman] + <string name="my_string_5">Ihre Historie</string> + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/values/config.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="my_string_1">Wie lautet Ihr Name?</string> + <string name="my_string_2">Wie heissen Sie?</string> + <string name="my_string_3">Frag nach Ihrem Namen.</string> + <string name="my_string_4">Wie Sie möchten</string> + <string name="my_string_5">Ihre Historie</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/FormalGermanDetectorTest.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, `FormalGermanDetector.formal`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/FragmentAddMenuProvider.md.html b/docs/checks/FragmentAddMenuProvider.md.html index 7496104..1c6a107 100644 --- a/docs/checks/FragmentAddMenuProvider.md.html +++ b/docs/checks/FragmentAddMenuProvider.md.html @@ -1,13 +1,13 @@ -(#) Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance. +(#) Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance -!!! ERROR: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance. +!!! ERROR: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance This is an error. Id : `FragmentAddMenuProvider` Summary -: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance. +: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance Severity : Error Category diff --git a/docs/checks/FragmentBackPressedCallback.md.html b/docs/checks/FragmentBackPressedCallback.md.html index c6ebafc..2eab73c 100644 --- a/docs/checks/FragmentBackPressedCallback.md.html +++ b/docs/checks/FragmentBackPressedCallback.md.html @@ -1,13 +1,13 @@ -(#) Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance. +(#) Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance -!!! ERROR: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance. +!!! ERROR: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance This is an error. Id : `FragmentBackPressedCallback` Summary -: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance. +: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance Severity : Error Category diff --git a/docs/checks/FragmentConstructorInjection.md.html b/docs/checks/FragmentConstructorInjection.md.html index 71446d9..616bbb9 100644 --- a/docs/checks/FragmentConstructorInjection.md.html +++ b/docs/checks/FragmentConstructorInjection.md.html @@ -1,13 +1,13 @@ -(#) Fragment dependencies should be injected using constructor injections only. +(#) Fragment dependencies should be injected using constructor injections only -!!! ERROR: Fragment dependencies should be injected using constructor injections only. +!!! ERROR: Fragment dependencies should be injected using constructor injections only This is an error. Id : `FragmentConstructorInjection` Summary -: Fragment dependencies should be injected using constructor injections only. +: Fragment dependencies should be injected using constructor injections only Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/FragmentDaggerFieldInjectionDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/FragmentDaggerFieldInjectionDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/FragmentDaggerFieldInjectionDetectorTest.kt) Copyright Year @@ -50,28 +50,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyFragment.kt:14:Error: Fragment dependencies should be injected using constructor injections only. [FragmentConstructorInjection] - @Inject ^ - - src/foo/MyFragment.kt:16:Error: Fragment dependencies should be injected using constructor injections only. [FragmentConstructorInjection] - @Inject ^ - - src/foo/MyFragment.kt:31:Error: Fragment dependencies should be injected using constructor injections only. [FragmentConstructorInjection] - @Inject ^ - - src/foo/MyFragment.kt:33:Error: Fragment dependencies should be injected using constructor injections only. [FragmentConstructorInjection] - @Inject ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FragmentFieldInjection.md.html b/docs/checks/FragmentFieldInjection.md.html index df51c1d..8daaaca 100644 --- a/docs/checks/FragmentFieldInjection.md.html +++ b/docs/checks/FragmentFieldInjection.md.html @@ -1,13 +1,13 @@ -(#) Fragment dependencies should be injected using the Fragment's constructor. +(#) Fragment dependencies should be injected using the Fragment's constructor -!!! ERROR: Fragment dependencies should be injected using the Fragment's constructor. +!!! ERROR: Fragment dependencies should be injected using the Fragment's constructor This is an error. Id : `FragmentFieldInjection` Summary -: Fragment dependencies should be injected using the Fragment's constructor. +: Fragment dependencies should be injected using the Fragment's constructor Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/FragmentDaggerFieldInjectionDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/FragmentDaggerFieldInjectionDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/FragmentDaggerFieldInjectionDetectorTest.kt) Copyright Year @@ -55,14 +55,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyFragment.kt:11:Error: Fragment dependencies should be injected using the Fragment's constructor. [FragmentFieldInjection] - @Inject ^ - - src/foo/MyFragment.kt:13:Error: Fragment dependencies should be injected using the Fragment's constructor. [FragmentFieldInjection] - @Inject ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FragmentGradleConfiguration-2.md.html b/docs/checks/FragmentGradleConfiguration-2.md.html index e81669f..9e72b4d 100644 --- a/docs/checks/FragmentGradleConfiguration-2.md.html +++ b/docs/checks/FragmentGradleConfiguration-2.md.html @@ -1,13 +1,13 @@ -(#) Include the fragment-testing-manifest library using the debugImplementation configuration. +(#) Include the fragment-testing-manifest library using the debugImplementation configuration -!!! ERROR: Include the fragment-testing-manifest library using the debugImplementation configuration. +!!! ERROR: Include the fragment-testing-manifest library using the debugImplementation configuration This is an error. Id : `FragmentGradleConfiguration` Summary -: Include the fragment-testing-manifest library using the debugImplementation configuration. +: Include the fragment-testing-manifest library using the debugImplementation configuration Severity : Error Category @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:2:Error: Replace with debugImplementation. [FragmentGradleConfiguration] - androidTestImplementation("androidx.fragment:fragment-testing-manifest:1.2.0-beta02") ------------------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FragmentGradleConfiguration.md.html b/docs/checks/FragmentGradleConfiguration.md.html index e2c28a9..4fb3a65 100644 --- a/docs/checks/FragmentGradleConfiguration.md.html +++ b/docs/checks/FragmentGradleConfiguration.md.html @@ -1,13 +1,13 @@ -(#) Include the fragment-testing library using the debugImplementation configuration. +(#) Include the fragment-testing library using the debugImplementation configuration -!!! ERROR: Include the fragment-testing library using the debugImplementation configuration. +!!! ERROR: Include the fragment-testing library using the debugImplementation configuration This is an error. Id : `FragmentGradleConfiguration` Summary -: Include the fragment-testing library using the debugImplementation configuration. +: Include the fragment-testing library using the debugImplementation configuration Severity : Error Category @@ -52,7 +52,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:2:Error: Replace with debugImplementation. [FragmentGradleConfiguration] - androidTestImplementation("androidx.fragment:fragment-testing-manifest:1.2.0-beta02") ------------------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FragmentLiveDataObserve.md.html b/docs/checks/FragmentLiveDataObserve.md.html index 0a9f5f6..23c779b 100644 --- a/docs/checks/FragmentLiveDataObserve.md.html +++ b/docs/checks/FragmentLiveDataObserve.md.html @@ -1,13 +1,13 @@ -(#) Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance when observing a LiveData object. +(#) Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance when observing a LiveData object -!!! ERROR: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance when observing a LiveData object. +!!! ERROR: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance when observing a LiveData object This is an error. Id : `FragmentLiveDataObserve` Summary -: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance when observing a LiveData object. +: Use getViewLifecycleOwner() as the LifecycleOwner instead of a Fragment instance when observing a LiveData object Severity : Error Category diff --git a/docs/checks/FragmentTagUsage.md.html b/docs/checks/FragmentTagUsage.md.html index fa3a88a..174d587 100644 --- a/docs/checks/FragmentTagUsage.md.html +++ b/docs/checks/FragmentTagUsage.md.html @@ -54,7 +54,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/layout.xml:5:Warning: Replace the tag with FragmentContainerView. [FragmentTagUsage] - <fragment android:name="androidx.fragment.app.Test'$'InflatedFragment" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FrequentlyChangedStateReadInComposition.md.html b/docs/checks/FrequentlyChangedStateReadInComposition.md.html index fa37bdb..b6d9367 100644 --- a/docs/checks/FrequentlyChangedStateReadInComposition.md.html +++ b/docs/checks/FrequentlyChangedStateReadInComposition.md.html @@ -55,47 +55,31 @@ src/androidx/compose/foundation/foo/test.kt:10:Warning: Frequently changing state should not be directly read in composable function [FrequentlyChangedStateReadInComposition] - val index = state.firstVisibleItemIndex --------------------------- - - src/androidx/compose/foundation/foo/test.kt:11:Warning: Frequently changing state should not be directly read in composable function [FrequentlyChangedStateReadInComposition] - val offset = state.firstVisibleItemScrollOffset ---------------------------------- - - src/androidx/compose/foundation/foo/test.kt:12:Warning: Frequently changing state should not be directly read in composable function [FrequentlyChangedStateReadInComposition] - val layoutInfo = state.layoutInfo ---------------- - - src/androidx/compose/foundation/foo/test.kt:17:Warning: Frequently changing state should not be directly read in composable function [FrequentlyChangedStateReadInComposition] - val index = state.firstVisibleItemIndex --------------------------- - - src/androidx/compose/foundation/foo/test.kt:18:Warning: Frequently changing state should not be directly read in composable function [FrequentlyChangedStateReadInComposition] - val offset = state.firstVisibleItemScrollOffset ---------------------------------- - - src/androidx/compose/foundation/foo/test.kt:19:Warning: Frequently changing state should not be directly read in composable function [FrequentlyChangedStateReadInComposition] - val layoutInfo = state.layoutInfo ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -142,17 +126,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.foundation:foundation-android:1.7.0-beta04") +implementation("androidx.compose.foundation:foundation-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.foundation:foundation-android:1.7.0-beta04' +implementation 'androidx.compose.foundation:foundation-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.foundation-android) # libs.versions.toml [versions] -foundation-android = "1.7.0-beta04" +foundation-android = "1.7.0-beta05" [libraries] foundation-android = { module = "androidx.compose.foundation:foundation-android", @@ -160,7 +144,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.foundation:foundation-android](androidx_compose_foundation_foundation-android.md.html). diff --git a/docs/checks/FullBackupContent.md.html b/docs/checks/FullBackupContent.md.html index 3af55f1..d2b84b0 100644 --- a/docs/checks/FullBackupContent.md.html +++ b/docs/checks/FullBackupContent.md.html @@ -42,14 +42,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/data_extraction_rules.xml:6:Error: foo.xml is not in an included path [FullBackupContent] - <exclude domain="sharedpref" path="foo.xml"/> ------- - - res/xml/full_backup_content.xml:5:Error: foo.xml is not in an included path [FullBackupContent] - <exclude domain="sharedpref" path="foo.xml"/> ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/FullyQualifiedResource.md.html b/docs/checks/FullyQualifiedResource.md.html index 2bbbfbe..3911c04 100644 --- a/docs/checks/FullyQualifiedResource.md.html +++ b/docs/checks/FullyQualifiedResource.md.html @@ -1,13 +1,13 @@ -(#) Resources should use an import alias instead of being fully qualified. +(#) Resources should use an import alias instead of being fully qualified -!!! ERROR: Resources should use an import alias instead of being fully qualified. +!!! ERROR: Resources should use an import alias instead of being fully qualified This is an error. Id : `FullyQualifiedResource` Summary -: Resources should use an import alias instead of being fully qualified. +: Resources should use an import alias instead of being fully qualified Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/resources/FullyQualifiedResourceDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/resources/FullyQualifiedResourceDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/resources/FullyQualifiedResourceDetectorTest.kt) Copyright Year @@ -75,7 +75,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/pkg/subpackage/MyClass.kt:6:Error: Use L10nR as an import alias instead [FullyQualifiedResource] - val appName = getString(slack.l10n.R.string.app_name) ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GestureBackNavigation.md.html b/docs/checks/GestureBackNavigation.md.html index 29ebc5c..c662b04 100644 --- a/docs/checks/GestureBackNavigation.md.html +++ b/docs/checks/GestureBackNavigation.md.html @@ -47,7 +47,6 @@ callbacks on the window level; Please see https://developer.android.com/about/versions/13/features/predictive-back-gesture [GestureBackNavigation] - if (KeyEvent.KEYCODE_BACK == keyCode) { --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GetContentDescriptionOverride.md.html b/docs/checks/GetContentDescriptionOverride.md.html index 89dc213..2b0d196 100644 --- a/docs/checks/GetContentDescriptionOverride.md.html +++ b/docs/checks/GetContentDescriptionOverride.md.html @@ -24,6 +24,8 @@ : This check runs on the fly in the IDE editor 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/GetContentDescriptionOverrideDetector.java) +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/GetContentDescriptionOverrideDetectorTest.kt) Copyright Year : 2016 @@ -32,6 +34,42 @@ call `setContentDescription()` when the content description needs to be changed. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/test/pkg/MyView.java:13:Error: Overriding getContentDescription() on +a View is not recommended [GetContentDescriptionOverride] + public CharSequence getContentDescription() { + --------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/test/pkg/MyView.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.content.Context; +import android.view.View; + +public class MyView extends View { + + public MyView(Context context) { + super(context); + } + + @Override + public CharSequence getContentDescription() { + return ""; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/GetContentDescriptionOverrideDetectorTest.kt) +for the unit tests for this check to see additional scenarios. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/GetInstance.md.html b/docs/checks/GetInstance.md.html index 675cb27..d996254 100644 --- a/docs/checks/GetInstance.md.html +++ b/docs/checks/GetInstance.md.html @@ -42,7 +42,6 @@ src/test/pkg/CipherGetInstanceAES.java:8:Warning: Cipher.getInstance should not be called without setting the encryption mode and padding [GetInstance] - Cipher.getInstance("AES"); ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GetLocales.md.html b/docs/checks/GetLocales.md.html index 4dface1..215ace9 100644 --- a/docs/checks/GetLocales.md.html +++ b/docs/checks/GetLocales.md.html @@ -42,12 +42,11 @@ AssetManager#getLocales is called and it contains one or more v21-style (3-letter or BCP47 locale) folders: values-b+kok+IN, values-fil [GetLocales] - String[] locales = assets.getLocales(); ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/myapplication/MyLibrary.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -64,6 +63,24 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-no/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-fil/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-b+kok+IN/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LocaleFolderDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/GradleCompatible.md.html b/docs/checks/GradleCompatible.md.html index 7059fdb..327e461 100644 --- a/docs/checks/GradleCompatible.md.html +++ b/docs/checks/GradleCompatible.md.html @@ -47,7 +47,6 @@ build.gradle:5:Error: Version 5.2.08 should not be used; the app can not be published with this version. Use version 11.1.71 instead. [GradleCompatible] - compile 'com.google.android.gms:play-services:5.2.08' --------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradleDependency.md.html b/docs/checks/GradleDependency.md.html index 2e03158..3b3be78 100644 --- a/docs/checks/GradleDependency.md.html +++ b/docs/checks/GradleDependency.md.html @@ -44,38 +44,25 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:24:Warning: A newer version of com.google.guava:guava than 11.0.2 is available: 21.0 [GradleDependency] - freeCompile 'com.google.guava:guava:11.0.2' ------------------------------- - - build.gradle:25:Warning: A newer version of com.android.support:appcompat-v7 than 13.0.0 is available: 25.3.1 [GradleDependency] - compile 'com.android.support:appcompat-v7:13.0.0' ----------------------------------------- - - build.gradle:26:Warning: A newer version of com.google.android.support:wearable than 1.2.0 is available: 1.3.0 [GradleDependency] - compile 'com.google.android.support:wearable:1.2.0' ------------------------------------------- - - build.gradle:27:Warning: A newer version of com.android.support:multidex than 1.0.0 is available: 1.0.1 [GradleDependency] - compile 'com.android.support:multidex:1.0.0' ------------------------------------ - - build.gradle:29:Warning: A newer version of com.android.support.test:runner than 0.3 is available: 0.5 [GradleDependency] - androidTestCompile 'com.android.support.test:runner:0.3' ------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradleDeprecated.md.html b/docs/checks/GradleDeprecated.md.html index 3dcd678..f36e8da 100644 --- a/docs/checks/GradleDeprecated.md.html +++ b/docs/checks/GradleDeprecated.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:1:Warning: 'android' is deprecated; use 'com.android.application' instead [GradleDeprecated] - apply plugin: 'android' ----------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradleDeprecatedConfiguration.md.html b/docs/checks/GradleDeprecatedConfiguration.md.html index f282739..1f78983 100644 --- a/docs/checks/GradleDeprecatedConfiguration.md.html +++ b/docs/checks/GradleDeprecatedConfiguration.md.html @@ -46,16 +46,12 @@ to maintain current behavior, or implementation to improve build performance by not sharing this dependency transitively. [GradleDeprecatedConfiguration] - compile 'androidx.appcompat:appcompat:1.0.0' ------- - - build.gradle:10:Warning: debugCompile is deprecated; replace with either debugApi to maintain current behavior, or debugImplementation to improve build performance by not sharing this dependency transitively. [GradleDeprecatedConfiguration] - debugCompile 'androidx.appcompat:appcompat:1.0.0' ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradleDynamicVersion.md.html b/docs/checks/GradleDynamicVersion.md.html index 045c1f4..574ddaa 100644 --- a/docs/checks/GradleDynamicVersion.md.html +++ b/docs/checks/GradleDynamicVersion.md.html @@ -46,7 +46,6 @@ build.gradle:23:Warning: Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds (com.android.support:appcompat-v7:+) [GradleDynamicVersion] - compile 'com.android.support:appcompat-v7:+' ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradleGetter.md.html b/docs/checks/GradleGetter.md.html index 463796c..8ca842b 100644 --- a/docs/checks/GradleGetter.md.html +++ b/docs/checks/GradleGetter.md.html @@ -50,16 +50,12 @@ does not conflict with the implicit getters for the defaultConfig properties. For example, try using the prefix compute- instead of get-. [GradleGetter] - versionCode getVersionCode -------------------------- - - build.gradle:19:Error: Bad method name: pick a unique method name which does not conflict with the implicit getters for the defaultConfig properties. For example, try using the prefix compute- instead of get-. [GradleGetter] - versionName getVersionName -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradleOverrides.md.html b/docs/checks/GradleOverrides.md.html index c79df6c..3cc2406 100644 --- a/docs/checks/GradleOverrides.md.html +++ b/docs/checks/GradleOverrides.md.html @@ -41,12 +41,11 @@ src/main/AndroidManifest.xml:2:Warning: Cannot use placeholder for the package in the manifest; set applicationId in build.gradle instead [GradleOverrides] - package="${packageName}" > ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/main/AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -60,6 +59,12 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +android { +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/GradlePath.md.html b/docs/checks/GradlePath.md.html index d7a888d..2d402d9 100644 --- a/docs/checks/GradlePath.md.html +++ b/docs/checks/GradlePath.md.html @@ -45,14 +45,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:4:Warning: Do not use Windows file separators in .gradle files; use / instead [GradlePath] - compile files('my\\libs\\http.jar') --------------------------- - - build.gradle:5:Warning: Avoid using absolute paths in .gradle files [GradlePath] - compile files('/libs/android-support-v4.jar') ------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GradlePluginVersion.md.html b/docs/checks/GradlePluginVersion.md.html index 92606d0..de0dca3 100644 --- a/docs/checks/GradlePluginVersion.md.html +++ b/docs/checks/GradlePluginVersion.md.html @@ -41,7 +41,6 @@ build.gradle:6:Error: You must use a newer version of the Android Gradle plugin. The minimum supported version is 3.2.0 and the recommended version is 7.0.3 [GradlePluginVersion] - classpath 'com.android.tools.build:gradle:0.1.0' ------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GrantAllUris.md.html b/docs/checks/GrantAllUris.md.html index 8363451..7b232b3 100644 --- a/docs/checks/GrantAllUris.md.html +++ b/docs/checks/GrantAllUris.md.html @@ -41,19 +41,15 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:25:Warning: Content provider shares everything; this is potentially dangerous [GrantAllUris] - <grant-uri-permission android:path="/"/> ---------------- - - AndroidManifest.xml:26:Warning: Content provider shares everything; this is potentially dangerous [GrantAllUris] - <grant-uri-permission android:pathPrefix="/"/> ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -89,6 +85,41 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/SecurityDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/GridLayout.md.html b/docs/checks/GridLayout.md.html index 2c54c6a..903fedf 100644 --- a/docs/checks/GridLayout.md.html +++ b/docs/checks/GridLayout.md.html @@ -44,7 +44,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/gridlayout.xml:36:Error: Column attribute (3) exceeds declared grid column count (2) [GridLayout] - android:layout_column="3" ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GuavaChecksUsed.md.html b/docs/checks/GuavaChecksUsed.md.html index 0b8441a..44e2279 100644 --- a/docs/checks/GuavaChecksUsed.md.html +++ b/docs/checks/GuavaChecksUsed.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/GuavaPreconditionsDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/GuavaPreconditionsDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/GuavaPreconditionsDetectorTest.kt) Copyright Year @@ -49,35 +49,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/Foo.java:7:Error: Use Slack's JavaPreconditions instead of Guava's Preconditions checks [GuavaChecksUsed] - boolean isTrue = Preconditions.checkState(1 == 1); ---------- - - src/foo/Foo.java:10:Error: Use Slack's JavaPreconditions instead of Guava's Preconditions checks [GuavaChecksUsed] - Preconditions.checkState(1 == 1); ---------- - - src/foo/Foo.java:11:Error: Use Slack's JavaPreconditions instead of Guava's Preconditions checks [GuavaChecksUsed] - Preconditions.checkArgument(1 == 1); ------------- - - src/foo/Foo.java:12:Error: Use Slack's JavaPreconditions instead of Guava's Preconditions checks [GuavaChecksUsed] - Preconditions.checkNotNull("Hello"); ------------ - - src/foo/Foo.java:13:Error: Use Slack's JavaPreconditions instead of Guava's Preconditions checks [GuavaChecksUsed] - Preconditions.checkElementIndex(0, 1); ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/GuavaPreconditionsUsedInKotlin.md.html b/docs/checks/GuavaPreconditionsUsedInKotlin.md.html index 5d451d0..5808ba7 100644 --- a/docs/checks/GuavaPreconditionsUsedInKotlin.md.html +++ b/docs/checks/GuavaPreconditionsUsedInKotlin.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/GuavaPreconditionsDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/GuavaPreconditionsDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/GuavaPreconditionsDetectorTest.kt) Copyright Year @@ -50,35 +50,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/Foo.kt:7:Error: Kotlin precondition checks should use the Kotlin standard library checks [GuavaPreconditionsUsedInKotlin] - val isTrue = Preconditions.checkState(false) ---------- - - src/foo/Foo.kt:10:Error: Kotlin precondition checks should use the Kotlin standard library checks [GuavaPreconditionsUsedInKotlin] - Preconditions.checkState(true) ---------- - - src/foo/Foo.kt:11:Error: Kotlin precondition checks should use the Kotlin standard library checks [GuavaPreconditionsUsedInKotlin] - Preconditions.checkArgument(false) ------------- - - src/foo/Foo.kt:12:Error: Kotlin precondition checks should use the Kotlin standard library checks [GuavaPreconditionsUsedInKotlin] - Preconditions.checkNotNull("Hello") ------------ - - src/foo/Foo.kt:13:Error: Kotlin precondition checks should use the Kotlin standard library checks [GuavaPreconditionsUsedInKotlin] - Preconditions.checkElementIndex(0, 1) ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HalfFloat.md.html b/docs/checks/HalfFloat.md.html index caa6497..a353789 100644 --- a/docs/checks/HalfFloat.md.html +++ b/docs/checks/HalfFloat.md.html @@ -39,49 +39,30 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/HalfFloatTest.java:23:Error: Expected a half float here, not a resource id [HalfFloat] - method1(getDimension1()); // ERROR --------------- - - src/test/pkg/HalfFloatTest.java:24:Error: Expected a half float here, not a dimension [HalfFloat] - method1(getDimension2()); // ERROR --------------- - - src/test/pkg/HalfFloatTest.java:25:Error: Expected a half float here, not a color [HalfFloat] - method1(getActualColor()); // ERROR ---------------- - - src/test/pkg/HalfFloatTest.java:26:Error: Expected a half float here, not a resource id [HalfFloat] - method1(getTextId()); // ERROR ----------- - - src/test/pkg/HalfFloatTest.java:43:Error: Half-float type in expression widened to int [HalfFloat] - int result3 = float1 + 1; // error: widening ------ - - src/test/pkg/HalfFloatTest.java:44:Error: Half-float type in expression widened to int [HalfFloat] - boolean result4 = float1 + 1 > 5; // error: widening ------ - - src/test/pkg/HalfFloatTest.java:50:Error: Half-float type in expression widened to int [HalfFloat] - Math.round(float1); // Error: should use Half.round ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HandlerLeak.md.html b/docs/checks/HandlerLeak.md.html index 5cd765c..1e65393 100644 --- a/docs/checks/HandlerLeak.md.html +++ b/docs/checks/HandlerLeak.md.html @@ -46,15 +46,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/HandlerTest.java:12:Warning: This Handler class should be static or leaks might occur (test.pkg.HandlerTest.Inner) [HandlerLeak] - public class Inner extends Handler { // ERROR ----- - - src/test/pkg/HandlerTest.java:18:Warning: This Handler class should be static or leaks might occur (anonymous android.os.Handler) [HandlerLeak] - Handler anonymous = new Handler() { // ERROR ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HardcodedDebugMode.md.html b/docs/checks/HardcodedDebugMode.md.html index 217008e..77b15d7 100644 --- a/docs/checks/HardcodedDebugMode.md.html +++ b/docs/checks/HardcodedDebugMode.md.html @@ -50,7 +50,6 @@ AndroidManifest.xml:10:Error: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode] - android:debuggable="true" ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HardcodedText.md.html b/docs/checks/HardcodedText.md.html index 455c3b8..658f1fb 100644 --- a/docs/checks/HardcodedText.md.html +++ b/docs/checks/HardcodedText.md.html @@ -48,14 +48,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/accessibility.xml:2:Warning: Hardcoded string "Button", should use @string resource [HardcodedText] - <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> --------------------- - - res/layout/accessibility.xml:5:Warning: Hardcoded string "Button", should use @string resource [HardcodedText] - <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HardwareIds.md.html b/docs/checks/HardwareIds.md.html index da49bdb..b5b66cc 100644 --- a/docs/checks/HardwareIds.md.html +++ b/docs/checks/HardwareIds.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/AppUtils.java:8:Warning: Using getAddress to get device identifiers is not recommended [HardwareIds] - return adapter.getAddress(); -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HighAppVersionCode.md.html b/docs/checks/HighAppVersionCode.md.html index 42038b1..0f9aafc 100644 --- a/docs/checks/HighAppVersionCode.md.html +++ b/docs/checks/HighAppVersionCode.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:5:Error: The 'versionCode' is very high and close to the max allowed value [HighAppVersionCode] - versionCode 2146435071 ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/HighSamplingRate.md.html b/docs/checks/HighSamplingRate.md.html index a7aed21..91679b8 100644 --- a/docs/checks/HighSamplingRate.md.html +++ b/docs/checks/HighSamplingRate.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:4:Warning: Most apps don't need access to high sensor sampling rate. [HighSamplingRate] - <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/> --------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/IconDensities.md.html b/docs/checks/IconDensities.md.html index 7f5e4e3..cf85366 100644 --- a/docs/checks/IconDensities.md.html +++ b/docs/checks/IconDensities.md.html @@ -41,30 +41,6 @@ `ANDROID_LINT_INCLUDE_LDPI=true`. For more information on current density usage, see https://developer.android.com/about/dashboards. -(##) Example - -Here is an example of lint warnings produced by this check: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -res/drawable-hdpi/.svn:Warning: Missing the following drawables in -drawable-hdpi: sample_icon.gif (found in drawable-mdpi) [IconDensities] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here is the source file referenced above: - -`res/drawable-hdpi/.svn`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -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/IconDetectorTest.java) -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, `IconDetector.test`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/IconDipSize.md.html b/docs/checks/IconDipSize.md.html index e1e670e..3cc6394 100644 --- a/docs/checks/IconDipSize.md.html +++ b/docs/checks/IconDipSize.md.html @@ -34,34 +34,6 @@ catches errors where images are either placed in the wrong folder, or icons are changed to new sizes but some folders are forgotten. -(##) Example - -Here is an example of lint warnings produced by this check: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -res/drawable-mdpi/my_lossy_72dp.webp:Warning: Suspicious file name -my_lossy_72dp.webp: The implied 72 dp size does not match the actual dp -size (pixel size 58×56 in a drawable-mdpi folder computes to 58×56 dp) -[IconDipSize] - -0 errors, 3 warnings -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here is the source file referenced above: - -`res/drawable-mdpi/my_lossy_72dp.webp`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers -H4sIAAAAAAAAAAvydHPzYGBgCHd1CggLsFCwAbIvMDPMZdSyYrBgsJvoscBHdYmykhIHwwYhzkyGMgYGhbxlC7g+chcxMPw7vf3/Wx8ht6D//wV23zjUANTKAADVeQHzUAAAAA== -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -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/IconDetectorTest.java) -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, `IconDetector.testClaimedSizeWebp`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/IconExtension.md.html b/docs/checks/IconExtension.md.html index 80b5f00..5a5d4fd 100644 --- a/docs/checks/IconExtension.md.html +++ b/docs/checks/IconExtension.md.html @@ -33,32 +33,6 @@ is really in the PNG format and not for example a GIF file named `.png`). -(##) Example - -Here is an example of lint warnings produced by this check: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -res/drawable-mdpi/foo.png:Warning: Misleading file extension; named .png -but the file format is webp [IconExtension] - -0 errors, 1 warnings -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here is the source file referenced above: - -`res/drawable-mdpi/foo.png`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers -H4sIAAAAAAAAAAvydHNTYWBgCHd1CggLsPARB7L1LQ/wMrBf2O/3ddt/RgXFP/XrXb/Yf2VkAABv2HPZLAAAAA== -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -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/IconDetectorTest.java) -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, `IconDetector.testMisleadingWebpFileName`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/IconMissingDensityFolder.md.html b/docs/checks/IconMissingDensityFolder.md.html index db622c7..11e4573 100644 --- a/docs/checks/IconMissingDensityFolder.md.html +++ b/docs/checks/IconMissingDensityFolder.md.html @@ -45,17 +45,23 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -res/drawable-hdpi/.svn:Warning: Missing density variation folders in -res: drawable-xhdpi, drawable-xxhdpi [IconMissingDensityFolder] - -0 errors, 5 warnings +res/drawable-nodpi/frame.xml:Warning: Missing density variation folders +in res: drawable-hdpi, drawable-xhdpi, drawable-xxhdpi +[IconMissingDensityFolder] +0 errors, 3 warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`res/drawable-hdpi/.svn`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers - +`res/drawable-nodpi/frame.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:color="#ff000000"/> <!-- WRONG, SHOULD BE LAST --> + <item android:state_pressed="true" + android:color="#ffff0000"/> <!-- pressed --> + <item android:state_focused="true" + android:color="#ff0000ff"/> <!-- focused --> +</selector> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the @@ -63,7 +69,7 @@ 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, `IconDetector.test`. +found for this lint check, `IconDetector.testNoDpiMix`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. diff --git a/docs/checks/IconXmlAndPng.md.html b/docs/checks/IconXmlAndPng.md.html index cc80c7b..99da3b3 100644 --- a/docs/checks/IconXmlAndPng.md.html +++ b/docs/checks/IconXmlAndPng.md.html @@ -42,7 +42,6 @@ density independent .xml files and as bitmap files: res/drawable-mdpi/background.png, res/drawable/background.xml [IconXmlAndPng] - res/drawable-mdpi/background.png: <No location-specific message> 0 errors, 1 warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/IdleBatteryChargingConstraints.md.html b/docs/checks/IdleBatteryChargingConstraints.md.html index 19ac30e..21e4c27 100644 --- a/docs/checks/IdleBatteryChargingConstraints.md.html +++ b/docs/checks/IdleBatteryChargingConstraints.md.html @@ -41,6 +41,42 @@ Some devices are never considered charging and idle at the same time. Consider removing one of these constraints. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/App.kt:8:Warning: Constraints may not be met for some +devices [IdleBatteryChargingConstraints] + builder.setRequiresDeviceIdle(true) + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`com/example/App.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import androidx.work.Constraints + +class App { + fun onCreate() { + val builder = Constraints.Builder() + builder.setRequiresDeviceIdle(true) + .setRequiresCharging(true) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/work-lint/src/test/java/androidx/work/lint/IdleBatteryChargingConstraintsDetectorTest.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, `IdleBatteryChargingConstraintsDetector.testWarnWithIdleCharging`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=409906. + (##) Including !!! diff --git a/docs/checks/IgnoreWithoutReason.md.html b/docs/checks/IgnoreWithoutReason.md.html index b84b6d9..64e4e96 100644 --- a/docs/checks/IgnoreWithoutReason.md.html +++ b/docs/checks/IgnoreWithoutReason.md.html @@ -63,7 +63,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyTest.java:7:Warning: Test is ignored without giving any explanation [IgnoreWithoutReason] - @Ignore class MyTest { ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/IllegalResourceRef.md.html b/docs/checks/IllegalResourceRef.md.html index 5c8ea97..fd6376a 100644 --- a/docs/checks/IllegalResourceRef.md.html +++ b/docs/checks/IllegalResourceRef.md.html @@ -40,15 +40,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:3:Warning: The android:versionCode cannot be a resource url, it must be a literal integer [IllegalResourceRef] - android:versionCode="@dimen/versionCode" ---------------------------------------- - - AndroidManifest.xml:6:Warning: The android:targetSdkVersion cannot be a resource url, it must be a literal integer (or string if a preview codename) [IllegalResourceRef] - <uses-sdk android:minSdkVersion="@dimen/minSdkVersion" android:targetSdkVersion="@dimen/targetSdkVersion" /> -------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ImplicitSamInstance.md.html b/docs/checks/ImplicitSamInstance.md.html index a9a8628..158a711 100644 --- a/docs/checks/ImplicitSamInstance.md.html +++ b/docs/checks/ImplicitSamInstance.md.html @@ -47,44 +47,31 @@ src/test/pkg/test.kt:17:Warning: Implicit new MyInterface instance being passed to method which ends up checking instance equality; this can lead to subtle bugs [ImplicitSamInstance] - handler.stash(lambda, list) // WARN ------ - - src/test/pkg/test.kt:18:Warning: Implicit new MyInterface instance being passed to method which ends up checking instance equality; this can lead to subtle bugs [ImplicitSamInstance] - handler.store(lambda) // WARN ------ - - src/test/pkg/test.kt:19:Warning: Implicit new MyInterface instance being passed to method which ends up checking instance equality; this can lead to subtle bugs [ImplicitSamInstance] - handler.compareIdentity1(lambda) // WARN ------ - - src/test/pkg/test.kt:20:Warning: Implicit new MyInterface instance being passed to method which ends up checking instance equality; this can lead to subtle bugs [ImplicitSamInstance] - handler.compareIdentity2(lambda) // WARN ------ - - src/test/pkg/test.kt:27:Warning: Implicit new MyInterface instance being passed to method which ends up checking instance equality; this can lead to subtle bugs [ImplicitSamInstance] - handler.stash(lambda2, list) // WARN ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -127,6 +114,90 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/JavaTest.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import java.util.List; + +public class JavaTest { + public void test(MyHandler handler, List list) { + handler.handle(() -> System.out.println("hello")); // OK + handler.stash(() -> System.out.println("hello"), list); // OK + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyInterface.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +public interface MyInterface { + void act(); +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyHandler.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import java.util.List; + +public class MyHandler { + public void handle(MyInterface actor) { + actor.act(); + System.out.println(actor); + MyInterface copy = actor; + System.out.println(copy); + } + + public void stash(MyInterface actor, List actors) { + actors.add(actor); + } + + public void store(MyInterface actor) { + last = actor; + } + + private MyInterface last; + + public void compareIdentity1(MyInterface actor) { + if (actor == last) { + System.out.println("last"); + } + } + + public void compareIdentity2(MyInterface actor) { + if (actor != last) { + System.out.println("not last"); + } + } + + public void compareEquals1(MyInterface actor) { + if (actor.equals(last)) { + System.out.println("last"); + } + } + + public void compareEquals2(MyInterface actor) { + if (last.equals(actor)) { + System.out.println("last"); + } + } + + public void act(MyInterface actor) { + if (actor != null) { + actor.act(); + } + //noinspection StatementWithEmptyBody + if (actor == null) { + } else { + actor.act(); + } + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/SamDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ImplicitStringPlaceholder.md.html b/docs/checks/ImplicitStringPlaceholder.md.html index 9ee977c..b082917 100644 --- a/docs/checks/ImplicitStringPlaceholder.md.html +++ b/docs/checks/ImplicitStringPlaceholder.md.html @@ -1,13 +1,13 @@ -(#) Marks implicit placeholders in strings without an index. +(#) Marks implicit placeholders in strings without an index -!!! WARNING: Marks implicit placeholders in strings without an index. +!!! WARNING: Marks implicit placeholders in strings without an index This is a warning. Id : `ImplicitStringPlaceholder` Summary -: Marks implicit placeholders in strings without an index. +: Marks implicit placeholders in strings without an index Severity : Warning Category @@ -29,9 +29,44 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/ImplicitStringPlaceholderDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ImplicitStringPlaceholderDetectorTest.kt) It's better and more explicit to use numbered placeholders. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/values/strings.xml:2:Warning: Implicit placeholder +[ImplicitStringPlaceholder] + <string name="my_string">Hello %s</string> + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="my_string">Hello %s</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ImplicitStringPlaceholderDetectorTest.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, `ImplicitStringPlaceholderDetector.invalid`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/ImpliedQuantity.md.html b/docs/checks/ImpliedQuantity.md.html index 02194c4..edc7c0a 100644 --- a/docs/checks/ImpliedQuantity.md.html +++ b/docs/checks/ImpliedQuantity.md.html @@ -51,12 +51,46 @@ 701, 1001, …), but the message did not include a formatting argument (such as %d). This is usually an internationalization error. See full issue explanation for more. [ImpliedQuantity] - <item quantity="one">Znaleziono jedną piosenkę.</item> ------------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/plurals.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <plurals name="my_plural"> + <item quantity="one">@string/hello</item> + <item quantity="few">@string/hello</item> + <item quantity="other">@string/hello</item> + </plurals> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/plurals2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <plurals name="numberOfSongsAvailable"> + <item quantity="one">One song found.</item> + <item quantity="other">%d songs found.</item> + </plurals> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-pl/plurals2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <plurals name="numberOfSongsAvailable"> + <item quantity="one">Znaleziono jedną piosenkę.</item> + <item quantity="few">Znaleziono %d piosenki.</item> + <item quantity="other">Znaleziono %d piosenek.</item> + </plurals> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values-sl/plurals2.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers diff --git a/docs/checks/ImpliedTouchscreenHardware.md.html b/docs/checks/ImpliedTouchscreenHardware.md.html index fc8525b..b02a226 100644 --- a/docs/checks/ImpliedTouchscreenHardware.md.html +++ b/docs/checks/ImpliedTouchscreenHardware.md.html @@ -42,9 +42,8 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:2:Error: Hardware feature -android.hardware.touchscreen not explicitly marked as optional +android.hardware.touchscreen not explicitly marked as optional [ImpliedTouchscreenHardware] - <manifest xmlns:android="http://schemas.android.com/apk/res/android" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InOrMmUsage.md.html b/docs/checks/InOrMmUsage.md.html index 93578b2..dee1b42 100644 --- a/docs/checks/InOrMmUsage.md.html +++ b/docs/checks/InOrMmUsage.md.html @@ -44,15 +44,11 @@ res/layout/now_playing_after.xml:49:Warning: Avoid using "mm" as units (it does not work accurately on all devices); use "dp" instead [InOrMmUsage] - android:layout_width="100mm" ---------------------------- - - res/layout/now_playing_after.xml:50:Warning: Avoid using "in" as units (it does not work accurately on all devices); use "dp" instead [InOrMmUsage] - android:layout_height="120in" ----------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/IncludeLayoutParam.md.html b/docs/checks/IncludeLayoutParam.md.html index 73d01fc..713f4bc 100644 --- a/docs/checks/IncludeLayoutParam.md.html +++ b/docs/checks/IncludeLayoutParam.md.html @@ -45,47 +45,31 @@ res/layout/include_params.xml:43:Error: Layout parameter layout_margin ignored unless both layout_width and layout_height are also specified on tag [IncludeLayoutParam] - android:layout_margin="20dp" ---------------------------- - - res/layout/include_params.xml:44:Error: Layout parameter layout_weight ignored unless both layout_width and layout_height are also specified on tag [IncludeLayoutParam] - android:layout_weight="1.5" --------------------------- - - res/layout/include_params.xml:51:Error: Layout parameter layout_weight ignored unless layout_width is also specified on tag [IncludeLayoutParam] - android:layout_weight="1.5" --------------------------- - - res/layout/include_params.xml:58:Error: Layout parameter layout_weight ignored unless layout_height is also specified on tag [IncludeLayoutParam] - android:layout_weight="1.5" --------------------------- - - res/layout/include_params.xml:65:Error: Layout parameter layout_width ignored unless layout_height is also specified on tag [IncludeLayoutParam] - android:layout_width="fill_parent" ---------------------------------- - - res/layout/include_params.xml:72:Error: Layout parameter layout_height ignored unless layout_width is also specified on tag [IncludeLayoutParam] - android:layout_height="fill_parent" ----------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InclusiveNaming.md.html b/docs/checks/InclusiveNaming.md.html index be4e71f..8ed088f 100644 --- a/docs/checks/InclusiveNaming.md.html +++ b/docs/checks/InclusiveNaming.md.html @@ -1,13 +1,13 @@ -(#) Use inclusive naming. +(#) Use inclusive naming -!!! ERROR: Use inclusive naming. +!!! ERROR: Use inclusive naming This is an error. Id : `InclusiveNaming` Summary -: Use inclusive naming. +: Use inclusive naming Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/inclusive/InclusiveNamingResourceScanner.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/inclusive/InclusiveNamingResourceScanner.kt) Copyright Year : 2021 @@ -67,7 +67,7 @@ This issue id has also been used by other, unrelated lint checks. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* InclusiveNaming: Use inclusive naming. (this issue) +* InclusiveNaming: Use inclusive naming (this issue) * [InclusiveNaming from com.slack.lint:slack-lint-checks:0.7.4](InclusiveNaming.md.html) * [InclusiveNaming from com.slack.lint:slack-lint-checks:0.7.4](InclusiveNaming.md.html) diff --git a/docs/checks/IncompatibleMediaBrowserServiceCompatVersion.md.html b/docs/checks/IncompatibleMediaBrowserServiceCompatVersion.md.html index 1903861..11c39ad 100644 --- a/docs/checks/IncompatibleMediaBrowserServiceCompatVersion.md.html +++ b/docs/checks/IncompatibleMediaBrowserServiceCompatVersion.md.html @@ -40,12 +40,35 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:4:Warning: Using a version of the class that is not forward compatible [IncompatibleMediaBrowserServiceCompatVersion] - - compile 'com.android.support:support-v4:23.4.0' + compile 'com.android.support:support-v4:23.4.0' ------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/MyBrowserService.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.os.Bundle; +import android.support.v4.media.MediaBrowserCompat; +import android.support.v4.media.MediaBrowserServiceCompat; + +import java.util.List; + +public class MyBrowserService extends MediaBrowserServiceCompat { + + @Override + public BrowserRoot onGetRoot(String clientPackageName, int clientUid, Bundle rootHints) { + return null; + } + + @Override + public void onLoadChildren(String parentId, Result> result) { + + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `build.gradle`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers @@ -69,13 +92,6 @@ You can suppress false positives using one of the following mechanisms: -* Using a suppression comment like this on the line above: - - ```kt - //noinspection IncompatibleMediaBrowserServiceCompatVersion - problematicStatement() - ``` - * Using a suppression annotation like this on the enclosing element: @@ -97,6 +113,13 @@ } ``` +* Using a suppression comment like this on the line above: + + ```kt + //noinspection IncompatibleMediaBrowserServiceCompatVersion + problematicStatement() + ``` + * 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: diff --git a/docs/checks/InconsistentArrays.md.html b/docs/checks/InconsistentArrays.md.html index 7ae0207..bd39006 100644 --- a/docs/checks/InconsistentArrays.md.html +++ b/docs/checks/InconsistentArrays.md.html @@ -50,20 +50,16 @@ res/values/arrays.xml:3:Warning: Array security_questions has an inconsistent number of items (3 in values-nl-rNL/arrays.xml, 4 in values-cs/arrays.xml) [InconsistentArrays] - <string-array name="security_questions"> ^ - - res/values/arrays.xml:10:Warning: Array signal_strength has an inconsistent number of items (5 in values/arrays.xml, 6 in values-land/arrays.xml) [InconsistentArrays] - <array name="signal_strength"> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/values/arrays.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -87,6 +83,68 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-cs/arrays.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string-array name="security_questions"> + <item>"Oblíbené jídlo?"</item> + <item>"Město narození."</item> + <item>"Jméno nejlepšího kamaráda z dětství?"</item> + <item>"Název střední školy"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-land/arrays.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <array name="signal_strength"> + <item>@drawable/ic_setups_signal_0</item> + <item>@drawable/ic_setups_signal_1</item> + <item>@drawable/ic_setups_signal_2</item> + <item>@drawable/ic_setups_signal_3</item> + <item>@drawable/ic_setups_signal_4</item> + <item>@drawable/extra</item> + </array> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-nl-rNL/arrays.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string-array name="security_questions"> + <item>"Favoriete eten?"</item> + <item>"Geboorteplaats?"</item> + <item>"Naam van middelbare school?"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-es/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers + +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Casa"</string> + <string name="show_all_apps">"Todo"</string> + <string name="menu_wallpaper">"Papel tapiz"</string> + <string name="menu_search">"Búsqueda"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string> + + <string-array name="security_questions"> + <item>"Comida favorita"</item> + <item>"Ciudad de nacimiento"</item> + <item>"Nombre de tu mejor amigo/a de la infancia"</item> + <item>"Nombre de tu colegio"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ArraySizeDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/InconsistentLayout.md.html b/docs/checks/InconsistentLayout.md.html index 9d73836..3e1aa8b 100644 --- a/docs/checks/InconsistentLayout.md.html +++ b/docs/checks/InconsistentLayout.md.html @@ -50,20 +50,27 @@ res/layout/layout1.xml:11:Warning: The id "button1" in layout "layout1" is missing from the following layout configurations: layout-xlarge (present in layout) [InconsistentLayout] - android:id="@+id/button1" ------------------------- - - res/layout/layout1.xml:38:Warning: The id "button4" in layout "layout1" is missing from the following layout configurations: layout-xlarge (present in layout) [InconsistentLayout] - android:id="@+id/button4" ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/X.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; +public class X { + public void X(Y parent) { + parent.foo(R.id.button1); + parent.foo(R.id.button4); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/layout/layout1.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -114,6 +121,23 @@ </RelativeLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout-xlarge/layout1.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/my_id2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LayoutConsistencyDetectorTest.java) for the unit tests for this check to see additional scenarios. @@ -127,12 +151,6 @@ You can suppress false positives using one of the following mechanisms: -* Adding the suppression attribute `tools:ignore="InconsistentLayout"` - 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 suppression annotation like this on the enclosing element: @@ -161,6 +179,12 @@ problematicStatement() ``` +* Adding the suppression attribute `tools:ignore="InconsistentLayout"` + 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: diff --git a/docs/checks/IncorrectChainMarginsUsage.md.html b/docs/checks/IncorrectChainMarginsUsage.md.html index 3db4b87..cbecbce 100644 --- a/docs/checks/IncorrectChainMarginsUsage.md.html +++ b/docs/checks/IncorrectChainMarginsUsage.md.html @@ -1,13 +1,13 @@ -(#) Use `LayoutReference.withChainParams()` to define margins for elements in a Chain. +(#) Use `LayoutReference.withChainParams()` to define margins for elements in a Chain -!!! WARNING: Use `LayoutReference.withChainParams()` to define margins for elements in a Chain. +!!! WARNING: Use `LayoutReference.withChainParams()` to define margins for elements in a Chain This is a warning. Id : `IncorrectChainMarginsUsage` Summary -: Use `LayoutReference.withChainParams()` to define margins for elements in a Chain. +: Use `LayoutReference.withChainParams()` to define margins for elements in a Chain Severity : Warning Category diff --git a/docs/checks/IncorrectMatchParentUsage.md.html b/docs/checks/IncorrectMatchParentUsage.md.html index 6828f72..d771979 100644 --- a/docs/checks/IncorrectMatchParentUsage.md.html +++ b/docs/checks/IncorrectMatchParentUsage.md.html @@ -1,13 +1,13 @@ -(#) Prefer using `Dimension.percent(1f)` when defining custom constraints. +(#) Prefer using `Dimension.percent(1f)` when defining custom constraints -!!! WARNING: Prefer using `Dimension.percent(1f)` when defining custom constraints. +!!! WARNING: Prefer using `Dimension.percent(1f)` when defining custom constraints This is a warning. Id : `IncorrectMatchParentUsage` Summary -: Prefer using `Dimension.percent(1f)` when defining custom constraints. +: Prefer using `Dimension.percent(1f)` when defining custom constraints Severity : Warning Category diff --git a/docs/checks/IncorrectReferencesDeclaration.md.html b/docs/checks/IncorrectReferencesDeclaration.md.html index 8bd9f82..102071a 100644 --- a/docs/checks/IncorrectReferencesDeclaration.md.html +++ b/docs/checks/IncorrectReferencesDeclaration.md.html @@ -50,28 +50,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/example/test.kt:8:Error: Arguments of createRefsFor (2) do not match assigned variables (3) [IncorrectReferencesDeclaration] - val (box1, text1, image1) = createRefsFor("box", "text") ------------- - - src/example/test.kt:9:Error: Arguments of createRefsFor (3) do not match assigned variables (2) [IncorrectReferencesDeclaration] - val (box2, text2) = createRefsFor("box", "text", "image") ------------- - - src/example/test.kt:19:Error: Arguments of createRefsFor (2) do not match assigned variables (3) [IncorrectReferencesDeclaration] - val (box1, text1, image1) = createRefsFor("box", "text") ------------- - - src/example/test.kt:20:Error: Arguments of createRefsFor (3) do not match assigned variables (2) [IncorrectReferencesDeclaration] - val (box2, text2) = createRefsFor("box", "text", "image") ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InefficientWeight.md.html b/docs/checks/InefficientWeight.md.html index ac68e9b..9810bbf 100644 --- a/docs/checks/InefficientWeight.md.html +++ b/docs/checks/InefficientWeight.md.html @@ -43,14 +43,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/inefficient_weight.xml:10:Warning: Use a layout_width of 0dp instead of match_parent for better performance [InefficientWeight] - android:layout_width="match_parent" ----------------------------------- - - res/layout/inefficient_weight.xml:24:Warning: Use a layout_height of 0dp instead of wrap_content for better performance [InefficientWeight] - android:layout_height="wrap_content" ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InflateParams.md.html b/docs/checks/InflateParams.md.html index 96a43cf..ad9a514 100644 --- a/docs/checks/InflateParams.md.html +++ b/docs/checks/InflateParams.md.html @@ -42,20 +42,16 @@ src/test/pkg/LayoutInflationTest.java:13:Warning: Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element) [InflateParams] - convertView = mInflater.inflate(R.layout.your_layout, null); ---- - - src/test/pkg/LayoutInflationTest.java:14:Warning: Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element) [InflateParams] - convertView = mInflater.inflate(R.layout.your_layout, null, true); ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/LayoutInflationTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -101,6 +97,23 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/your_layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/LinearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout-port/your_layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@id/text1" + style="?android:attr/listSeparatorTextViewStyle" /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LayoutInflationDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/InjectInJava.md.html b/docs/checks/InjectInJava.md.html index 8aa89df..5687fc5 100644 --- a/docs/checks/InjectInJava.md.html +++ b/docs/checks/InjectInJava.md.html @@ -1,13 +1,13 @@ -(#) Only Kotlin classes should be injected in order for Anvil to work. +(#) Only Kotlin classes should be injected in order for Anvil to work -!!! ERROR: Only Kotlin classes should be injected in order for Anvil to work. +!!! ERROR: Only Kotlin classes should be injected in order for Anvil to work This is an error. Id : `InjectInJava` Summary -: Only Kotlin classes should be injected in order for Anvil to work. +: Only Kotlin classes should be injected in order for Anvil to work Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/InjectInJavaDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/InjectInJavaDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/InjectInJavaDetectorTest.kt) Copyright Year @@ -50,42 +50,26 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/JavaClass.java:9:Error: Only Kotlin classes should be injected in order for Anvil to work. [InjectInJava] - @Inject String memberInjected; ------- - - src/test/pkg/JavaClass.java:11:Error: Only Kotlin classes should be injected in order for Anvil to work. [InjectInJava] - @Inject JavaClass(String constructorInjected) { ------- - - src/test/pkg/JavaClass.java:15:Error: Only Kotlin classes should be injected in order for Anvil to work. [InjectInJava] - @Inject void methodInject(String value) { ------- - - src/test/pkg/JavaClass.java:21:Error: Only Kotlin classes should be injected in order for Anvil to work. [InjectInJava] - @AssistedInject JavaAssistedClass(@Assisted String assistedParam) { --------------- - - src/test/pkg/JavaClass.java:25:Error: Only Kotlin classes should be injected in order for Anvil to work. [InjectInJava] - @AssistedFactory ---------------- - - src/test/pkg/JavaClass.java:31:Error: Only Kotlin classes should be injected in order for Anvil to work. [InjectInJava] - @Module static abstract class ExampleModule { ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InlinedApi.md.html b/docs/checks/InlinedApi.md.html index d68b3ed..dd3dfd7 100644 --- a/docs/checks/InlinedApi.md.html +++ b/docs/checks/InlinedApi.md.html @@ -59,7 +59,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test.kt:8:Warning: Field requires API level 29 (current min is 21): android.media.MediaFormat#MIMETYPE_AUDIO_AC4 [InlinedApi] - val format: String = MediaFormat.MIMETYPE_AUDIO_AC4 ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InnerclassSeparator.md.html b/docs/checks/InnerclassSeparator.md.html index f8fab89..6fe4a40 100644 --- a/docs/checks/InnerclassSeparator.md.html +++ b/docs/checks/InnerclassSeparator.md.html @@ -46,12 +46,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:5:Warning: Use '$' instead of '.' for inner classes; replace ".Foo.Bar" with ".Foo$Bar" [InnerclassSeparator] - android:name=".Foo.Bar" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -66,6 +65,18 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/Foo.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; + +public class Foo { + public static class Bar extends Activity { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/MissingClassDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/InsecureBaseConfiguration.md.html b/docs/checks/InsecureBaseConfiguration.md.html index bc4a3b8..df29b97 100644 --- a/docs/checks/InsecureBaseConfiguration.md.html +++ b/docs/checks/InsecureBaseConfiguration.md.html @@ -36,7 +36,7 @@ Permitting cleartext traffic could allow eavesdroppers to intercept data sent by your app, which impacts the privacy of your users. Consider only allowing encrypted traffic by setting the `cleartextTrafficPermitted` -tag to `"false"`. +tag to `false`. !!! Tip This lint check has an associated quickfix available in the IDE. @@ -47,7 +47,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/network_config.xml:3:Warning: Insecure Base Configuration [InsecureBaseConfiguration] - <base-config cleartextTrafficPermitted="true"> ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InsecureDnsSdkLevel.md.html b/docs/checks/InsecureDnsSdkLevel.md.html new file mode 100644 index 0000000..5e03046 --- /dev/null +++ b/docs/checks/InsecureDnsSdkLevel.md.html @@ -0,0 +1,146 @@ + +(#) Application vulnerable to DNS spoofing attacks + +!!! WARNING: Application vulnerable to DNS spoofing attacks + This is a warning. + +Id +: `InsecureDnsSdkLevel` +Summary +: Application vulnerable to DNS spoofing attacks +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/InsecureDnsSdkLevel +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/DnsConfigDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/DnsConfigDetectorTest.kt) +Copyright Year +: 2024 + +Apps targeting SDK versions earlier than 28 are susceptible to DNS +attacks like DNS spoofing or cache poisoning. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:2:Warning: Update your application's target SDK +version to 28 and above to make use of the Android OS's built-in +transport security features [InsecureDnsSdkLevel] +<uses-sdk android:targetSdkVersion='27'/> + -- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<uses-sdk android:targetSdkVersion='27'/> +<application android:debuggable='false'> + <activity android:name='com.example.MainActivity'></activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/DnsConfigDetectorTest.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, `DnsConfigDetector.testWhenTargetSdkBelowSecureDnsTransportPatch_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="InsecureDnsSdkLevel"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <uses-sdk tools:ignore="InsecureDnsSdkLevel" .../> + ... + </manifest> + ``` + +* 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="InsecureDnsSdkLevel" 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 'InsecureDnsSdkLevel' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore InsecureDnsSdkLevel ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/InsecurePermissionProtectionLevel.md.html b/docs/checks/InsecurePermissionProtectionLevel.md.html new file mode 100644 index 0000000..9a01745 --- /dev/null +++ b/docs/checks/InsecurePermissionProtectionLevel.md.html @@ -0,0 +1,149 @@ + +(#) Custom permission created with a normal `protectionLevel` + +!!! WARNING: Custom permission created with a normal `protectionLevel` + This is a warning. + +Id +: `InsecurePermissionProtectionLevel` +Summary +: Custom permission created with a normal `protectionLevel` +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/InsecurePermissionProtectionLevel +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/PermissionDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/PermissionDetectorTest.kt) +Copyright Year +: 2024 + +Custom permissions are designed for sharing resources and capabilities +with other apps. However, typos and insufficient protection levels can +negate the usage of these custom permissions altogether. In general, use +`signature` or higher protection levels whenever possible, as this +ensures only other apps signed with the same certificate can access +these protected features. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:2:Warning: Custom permissions should have signature +`protectionLevel`s or higher [InsecurePermissionProtectionLevel] +<permission android:name="com.android.example.permission.CUSTOM_PERMISSION" /> +------------------------------------------------------------------------------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<permission android:name="com.android.example.permission.CUSTOM_PERMISSION" /> +<application android:debuggable='false'> + <activity android:name='com.example.MainActivity'></activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/PermissionDetectorTest.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, `PermissionDetector.testWhenCustomPermissionNoSpecifiedProtectionLevel_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="InsecurePermissionProtectionLevel"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <permission tools:ignore="InsecurePermissionProtectionLevel" .../> + ... + </manifest> + ``` + +* 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="InsecurePermissionProtectionLevel" 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 'InsecurePermissionProtectionLevel' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore InsecurePermissionProtectionLevel ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/InstantApps.md.html b/docs/checks/InstantApps.md.html index 451e625..2782a86 100644 --- a/docs/checks/InstantApps.md.html +++ b/docs/checks/InstantApps.md.html @@ -37,21 +37,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/main/AndroidManifest.xml:10:Warning: Instant Apps are not allowed to export services, receivers, and providers [InstantApps] - <service android:name=".WearMessageListenerService"> ^ - - src/main/AndroidManifest.xml:15:Warning: Instant Apps are not allowed to export services, receivers, and providers [InstantApps] - <provider android:name=".TestService" /> ---------------------------------------- - - src/main/AndroidManifest.xml:16:Warning: Instant Apps are not allowed to export services, receivers, and providers [InstantApps] - <receiver android:name=".DeviceAdminTestReceiver" ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Instantiatable.md.html b/docs/checks/Instantiatable.md.html index 8346d27..496f840 100644 --- a/docs/checks/Instantiatable.md.html +++ b/docs/checks/Instantiatable.md.html @@ -47,12 +47,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/menu/my_menu.xml:13:Error: NotView must extend android.view.View [Instantiatable] - android:actionViewClass="test.pkg.NotView" /> ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/menu/my_menu.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -72,6 +71,19 @@ </menu> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/SearchView.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import android.widget.TextView +abstract class SearchView : TextView(null) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/NotView.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +abstract class NotView : android.app.Fragment() +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/MissingClassDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/IntentFilterExportedReceiver.md.html b/docs/checks/IntentFilterExportedReceiver.md.html index 7633231..0058cfd 100644 --- a/docs/checks/IntentFilterExportedReceiver.md.html +++ b/docs/checks/IntentFilterExportedReceiver.md.html @@ -65,7 +65,6 @@ AndroidManifest.xml:7:Warning: As of Android 12, android:exported must be set; use true to make the activity available to other apps, and false otherwise. [IntentFilterExportedReceiver] - <receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver"> -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/IntentFilterUniqueDataAttributes.md.html b/docs/checks/IntentFilterUniqueDataAttributes.md.html index aa3b088..72718c4 100644 --- a/docs/checks/IntentFilterUniqueDataAttributes.md.html +++ b/docs/checks/IntentFilterUniqueDataAttributes.md.html @@ -80,40 +80,12 @@ AndroidManifest.xml:5:Warning: Consider splitting data tag into multiple tags with individual attributes to avoid confusion [IntentFilterUniqueDataAttributes] - - <data android:scheme="https" android:host="example.com"/> - --------------------------------------------------------- - - + <data alt-android:scheme="https" alt-android:host="example.com"/> + ----------------------------------------------------------------- AndroidManifest.xml:6:Warning: Consider splitting data tag into multiple tags with individual attributes to avoid confusion [IntentFilterUniqueDataAttributes] - - <data android:scheme="http" android:host="example.org"/> - -------------------------------------------------------- - - -AndroidManifest.xml:12:Warning: Consider splitting data tag into -multiple tags with individual attributes to avoid confusion -[IntentFilterUniqueDataAttributes] - - <data - ^ - - -AndroidManifest.xml:24:Warning: Consider splitting data tag into -multiple tags with individual attributes to avoid confusion -[IntentFilterUniqueDataAttributes] - - <data android:host="example.com" android:port="41" android:path="/sub"/> - ------------------------------------------------------------------------ - - -AndroidManifest.xml:30:Warning: Consider splitting data tag into -multiple tags with individual attributes to avoid confusion -[IntentFilterUniqueDataAttributes] - - <data android:host="example.com" android:mimeType="image/jpeg"/> + <data alt-android:scheme="http" alt-android:host="example.org"/> ---------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -121,53 +93,12 @@ `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers -<manifest xmlns:android="http://schemas.android.com/apk/res/android" +<manifest xmlns:alt-android="http://schemas.android.com/apk/res/android" package="com.example.helloworld" > - <activity android:name="com.example.Activity"> - <intent-filter> - <data android:scheme="https" android:host="example.com"/> - <data android:scheme="http" android:host="example.org"/> - </intent-filter> - </activity> - <receiver android:name="com.example.Receiver"> - <intent-filter> - <data android:scheme="https"/> - <data - android:host="example.com" - android:path="/path" - android:scheme="https" - /> - </intent-filter> - </receiver> - <service android:name="com.example.Service"> - <intent-filter> - <data android:scheme="https"/> - <!-- Don't warn on only host and port --> - <data android:host="example.com" android:port="40"/> - <data android:host="example.com" android:port="41" android:path="/sub"/> - </intent-filter> - </service> - <provider android:name="com.example.Provider"> - <intent-filter> - <data android:scheme="https"/> - <data android:host="example.com" android:mimeType="image/jpeg"/> - </intent-filter> - </provider> - <activity android:name="com.example.Activity2"> + <activity alt-android:name="com.example.Activity"> <intent-filter> - <data android:scheme="https" android:host="example.com"/> - <!-- Don't warn on multiple attributes of only path variants--> - <data - android:pathPrefix="/prefix" - android:path="/path" - android:pathPattern="/pattern/*" - /> - </intent-filter> - </activity> - <activity android:name="com.example.Activity3"> - <intent-filter> - <!-- Don't warn on only 1 data tag --> - <data android:scheme="https" android:host="example.com"/> + <data alt-android:scheme="https" alt-android:host="example.com"/> + <data alt-android:scheme="http" alt-android:host="example.org"/> </intent-filter> </activity> </manifest> @@ -177,11 +108,6 @@ [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/AppLinksValidDetectorTest.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, `AppLinksValidDetector.testIntentFilterDataDeclaration`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/IntentReset.md.html b/docs/checks/IntentReset.md.html index aa65eee..f3eba37 100644 --- a/docs/checks/IntentReset.md.html +++ b/docs/checks/IntentReset.md.html @@ -40,14 +40,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/IntentTest.java:19:Warning: Calling setType after calling setData will clear the data: Call setDataAndType instead? [IntentReset] - intent.setType(type); // ERROR 1.1 ------------- - - src/test/pkg/IntentTest.java:26:Warning: Calling setData after calling setType will clear the type: Call setDataAndType instead? [IntentReset] - intent.setData(uri); // ERROR 2.1 ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/IntentWithNullActionLaunch.md.html b/docs/checks/IntentWithNullActionLaunch.md.html index bab6c80..9ac3fa9 100644 --- a/docs/checks/IntentWithNullActionLaunch.md.html +++ b/docs/checks/IntentWithNullActionLaunch.md.html @@ -49,7 +49,6 @@ and is not explicit by component. You should either make this intent explicit by component or set an action matching the targeted intent filter. [IntentWithNullActionLaunch] - Intent intent = new Intent(); ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InternalInsetResource.md.html b/docs/checks/InternalInsetResource.md.html index 3296b55..c6a4b0a 100644 --- a/docs/checks/InternalInsetResource.md.html +++ b/docs/checks/InternalInsetResource.md.html @@ -24,6 +24,8 @@ : This check runs on the fly in the IDE editor 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/InternalInsetResourceDetector.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/InternalInsetResourceDetectorTest.kt) Copyright Year : 2022 @@ -34,6 +36,32 @@ for your app and listen to updates, use `androidx.core.view.WindowInsetsCompat` and related APIs. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/test/pkg/test.kt:6:Warning: Using internal inset dimension resource +status_bar_height is not supported [InternalInsetResource] + getIdentifier("status_bar_height", "dimen", "android") + ------------------------------------------------------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/test/pkg/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.content.res.Resources + +fun Resources.getStatusBarHeightIdentifier(): Int = + getIdentifier("status_bar_height", "dimen", "android") +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/InternalInsetResourceDetectorTest.kt) +for the unit tests for this check to see additional scenarios. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/InvalidAccessibility.md.html b/docs/checks/InvalidAccessibility.md.html index 75f718f..0b72c1a 100644 --- a/docs/checks/InvalidAccessibility.md.html +++ b/docs/checks/InvalidAccessibility.md.html @@ -1,13 +1,13 @@ -(#) Marks invalid accessibility usages. +(#) Marks invalid accessibility usages -!!! WARNING: Marks invalid accessibility usages. +!!! WARNING: Marks invalid accessibility usages This is a warning. Id : `InvalidAccessibility` Summary -: Marks invalid accessibility usages. +: Marks invalid accessibility usages Severity : Warning Category @@ -29,9 +29,46 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/InvalidAccessibilityDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidAccessibilityDetectorTest.kt) Marks usages of invalid accessibility and suggests corrections. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:5:Warning: Either set a proper accessibility text or +use importantForAccessibility [InvalidAccessibility] + android:contentDescription="@null"/> + ----- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<ImageView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:contentDescription="@null"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidAccessibilityDetectorTest.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, `InvalidAccessibilityDetector.contentDescriptionNull`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/InvalidAnalyticsName.md.html b/docs/checks/InvalidAnalyticsName.md.html index 6bf75de..2908b62 100644 --- a/docs/checks/InvalidAnalyticsName.md.html +++ b/docs/checks/InvalidAnalyticsName.md.html @@ -41,7 +41,6 @@ src/test/pkg/MainActivity.java:6:Error: Analytics event name must only consist of letters, numbers and underscores (found a;) [InvalidAnalyticsName] - FirebaseAnalytics.getInstance(this).logEvent("a;", new Bundle()); ---------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidColorHexValue.md.html b/docs/checks/InvalidColorHexValue.md.html index 300ed10..d4489dd 100644 --- a/docs/checks/InvalidColorHexValue.md.html +++ b/docs/checks/InvalidColorHexValue.md.html @@ -48,21 +48,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:6:Warning: Invalid Color hex value [InvalidColorHexValue] - val color = Color(0x00000) ------- - - src/test/test.kt:7:Warning: Invalid Color hex value [InvalidColorHexValue] - val color2 = Color(0xEEEEE) ------- - - src/test/test.kt:8:Warning: Invalid Color hex value [InvalidColorHexValue] - val color3 = Color(0x00_0_0_0L) ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -97,17 +90,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-graphics-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-graphics-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-graphics-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-graphics-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-graphics-android) # libs.versions.toml [versions] -ui-graphics-android = "1.7.0-beta04" +ui-graphics-android = "1.7.0-beta05" [libraries] ui-graphics-android = { module = "androidx.compose.ui:ui-graphics-android", @@ -115,7 +108,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-graphics-android](androidx_compose_ui_ui-graphics-android.md.html). diff --git a/docs/checks/InvalidFragmentVersionForActivityResult.md.html b/docs/checks/InvalidFragmentVersionForActivityResult.md.html index 8a0a386..9151471 100644 --- a/docs/checks/InvalidFragmentVersionForActivityResult.md.html +++ b/docs/checks/InvalidFragmentVersionForActivityResult.md.html @@ -53,12 +53,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/main/kotlin/com/example/test.kt:6:Error: Upgrade Fragment version to at least . [InvalidFragmentVersionForActivityResult] - val launcher = ActivityResultCaller().registerForActivityResult(ActivityResultContract()) -------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +dependencies { + api("androidx.fragment:fragment:1.2.4") +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/main/kotlin/com/example/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -113,6 +119,13 @@ You can suppress false positives using one of the following mechanisms: +* Using a suppression comment like this on the line above: + + ```kt + //noinspection InvalidFragmentVersionForActivityResult + problematicStatement() + ``` + * Using a suppression annotation like this on the enclosing element: @@ -134,13 +147,6 @@ } ``` -* Using a suppression comment like this on the line above: - - ```kt - //noinspection InvalidFragmentVersionForActivityResult - problematicStatement() - ``` - * 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: diff --git a/docs/checks/InvalidId.md.html b/docs/checks/InvalidId.md.html index 51d3201..230fb56 100644 --- a/docs/checks/InvalidId.md.html +++ b/docs/checks/InvalidId.md.html @@ -45,28 +45,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/invalid_ids.xml:23:Error: ID definitions must be of the form @+id/name; try using @+id/menu_Reload [InvalidId] - android:id="@+menu/Reload" -------------------------- - - res/layout/invalid_ids.xml:31:Error: ID definitions must be of the form @+id/name; try using @+id/_id_foo [InvalidId] - android:id="@+/id_foo" ---------------------- - - res/layout/invalid_ids.xml:37:Error: ID definitions must be of the form @+id/name; try using @+id/myid_button5 [InvalidId] - android:id="@+myid/button5" --------------------------- - - res/layout/invalid_ids.xml:43:Error: ID definitions must be of the form @+id/name; try using @+id/string_whatevs [InvalidId] - android:id="@+string/whatevs" ----------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidImeActionId.md.html b/docs/checks/InvalidImeActionId.md.html index 2550fba..46adfa7 100644 --- a/docs/checks/InvalidImeActionId.md.html +++ b/docs/checks/InvalidImeActionId.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/namespace.xml:2:Error: Invalid resource type, expected integer value [InvalidImeActionId] - <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:imeActionId="@+id/login"/> -------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidImport.md.html b/docs/checks/InvalidImport.md.html index 1ddc720..944239b 100644 --- a/docs/checks/InvalidImport.md.html +++ b/docs/checks/InvalidImport.md.html @@ -1,13 +1,13 @@ -(#) Flags invalid imports. +(#) Flags invalid imports -!!! WARNING: Flags invalid imports. +!!! WARNING: Flags invalid imports This is a warning. Id : `InvalidImport` Summary -: Flags invalid imports. +: Flags invalid imports Severity : Warning Category @@ -29,11 +29,45 @@ : 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/kotlin/com/vanniktech/lintrules/android/InvalidImportDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidImportDetectorTest.kt) Flags invalid imports. One example is com.foo.bar.R.drawable. Instead just the generated class R should be imported and not R.drawable. Also you should never import anything that's in an internal package. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:3:Warning: Forbidden import [InvalidImport] +import foo.R.drawable; + -------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import foo.R.drawable; + +class Example { +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidImportDetectorTest.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, `InvalidImportDetector.rDrawableImport`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/InvalidLanguageTagDelimiter.md.html b/docs/checks/InvalidLanguageTagDelimiter.md.html index b342f9a..08f6339 100644 --- a/docs/checks/InvalidLanguageTagDelimiter.md.html +++ b/docs/checks/InvalidLanguageTagDelimiter.md.html @@ -1,13 +1,13 @@ -(#) Undercore (_) is an unsupported delimiter for subtags +(#) Underscore (`_`) is an unsupported delimiter for subtags -!!! ERROR: Undercore (_) is an unsupported delimiter for subtags +!!! ERROR: Underscore (`_`) is an unsupported delimiter for subtags This is an error. Id : `InvalidLanguageTagDelimiter` Summary -: Undercore (_) is an unsupported delimiter for subtags +: Underscore (`_`) is an unsupported delimiter for subtags Severity : Error Category @@ -48,9 +48,8 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:8:Error: A hyphen (-), not an underscore (_) delimiter should be used in a language tag [InvalidLanguageTagDelimiter] - bar(Locale("en_UK")) - ----- + ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: @@ -84,17 +83,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-text-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-text-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-text-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-text-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-text-android) # libs.versions.toml [versions] -ui-text-android = "1.7.0-beta04" +ui-text-android = "1.7.0-beta05" [libraries] ui-text-android = { module = "androidx.compose.ui:ui-text-android", @@ -102,7 +101,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-text-android](androidx_compose_ui_ui-text-android.md.html). diff --git a/docs/checks/InvalidNavigation.md.html b/docs/checks/InvalidNavigation.md.html index 0945c90..e0b4c6a 100644 --- a/docs/checks/InvalidNavigation.md.html +++ b/docs/checks/InvalidNavigation.md.html @@ -38,12 +38,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/navigation/navigation.xml:5:Warning: Invalid start destination @id/includedId [InvalidNavigation] - app:startDestination="@id/includedId"> -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/navigation/navigation.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -56,6 +55,18 @@ </navigation> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/navigation/foo.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> + <navigation + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:android="http://schemas.android.com/apk/res/android" + android:id='@+id/includedId2' + app:startDestination="@id/foo2"> + <fragment android:id="@+id/foo2"/> + </navigation> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/StartDestinationDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/InvalidPackage.md.html b/docs/checks/InvalidPackage.md.html index 250d3d9..410fb78 100644 --- a/docs/checks/InvalidPackage.md.html +++ b/docs/checks/InvalidPackage.md.html @@ -53,14 +53,89 @@ libs/unsupported.jar:Error: Invalid package reference in library; not included in Android: javax.swing. Referenced from test.pkg.LibraryClass. [InvalidPackage] - 2 errors, 0 warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/layout/layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <!-- Requires API 5 --> + + <QuickContactBadge + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <!-- Requires API 11 --> + + <CalendarView + android:layout_width="fill_parent" + android:layout_height="fill_parent" /> + + <!-- Requires API 14 --> + + <GridLayout + foo="@android:attr/actionBarSplitStyle" + bar="@android:color/holo_red_light" + android:layout_width="fill_parent" + android:layout_height="fill_parent" > + + <Button + android:layout_width="fill_parent" + android:layout_height="fill_parent" /> + </GridLayout> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/themes.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="Theme" parent="android:Theme"/> + + <style name="Theme.Test" parent="android:style/Theme.Light"> + <item name="android:windowNoTitle">true</item> + <item name="android:windowContentOverlay">@null</item> + <!-- Requires API 14 --> + <item name="android:windowBackground"> @android:color/holo_red_light </item> + </style> + + <style name="Theme.Test.Transparent"> + <item name="android:windowBackground">@android:color/transparent</item> + </style> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/color/colors.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="Theme" parent="android:Theme"/> + + <style name="Theme.Test" parent="android:style/Theme.Light"> + <item name="android:windowNoTitle">true</item> + <item name="android:windowContentOverlay">@null</item> + <!-- Requires API 14 --> + <item name="android:windowBackground"> @android:color/holo_red_light </item> + </style> + + <style name="Theme.Test.Transparent"> + <item name="android:windowBackground">@android:color/transparent</item> + </style> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `libs/unsupported.jar`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers H4sIAAAAAAAAAAvwZmYRYeAAwmMzkxwZkAAnAwuDr2uIo66nn5v+v1MMDMwMAd7sHCApJqiSAJyaRYAYrtnX0c/TzTU4RM/X7bPvmdM+3rp6F3m9dbXOnTm/OcjgivGDp0V6Xr46nr4XS1excM54KXlEerZ2hoWYyJMlWhXPVF9nfir6WMQItt1tYdofG6DZNlDbucC27UWznRWIS1KLS/RxK+GEKSnITtdH+GM6mjJpZGU+mUlFiUWVzjmJxcV6ySAyNyjaX9hR5N+y7bnXs/QDHC5yPVq69ITD0exefpMZGWEmKzOfFG67O+Xg3chNc7n+Kv/jr93Q6fuH8Z/G45u5jpk32i2Nn8/5qZf+7fv8+fsZrgSaCyRrZC5f//Pjc7ntS2Q7Em6UuO7PVzg4wV4onqW89dXH798mXr7Is3J6kOffLsW4ldskhXz3v57RoTzZVUizbY7q1M32H3LUf2jkXE/UiKpz35EreOKDja/al4VvjHWipk8ylzC6d2FuCs8TyWdOqsv31Ct5nr59t/HaPqOJzmrNllN4zsQL3Jb6tvVx6sYGV6FX/B7lJ7tOXXouz7SyxJu974OU2rrkmwd6NQ/6WHbP3nE0QaZdM1zQ4+isuR6Lb5kV/H6zz+LiHs2mdaptR7IW9fQ0WvN8Drwq/GvC+1P3pJfOnSe8pHD6wTvr7G9V/nnycvPzaLWwQnuZx82SakHO26Qf7gkuS/l75vwZl4y8Yyufv1vZeHyD2dsFLNuXvipaOGV967R9j+ar+V6ZX6S88jnzrhcNUo+2vTHUiZhuuWDTzU/sjscrdQ+H6/753zH7Ie8mFwGO/RJvX4gvvLpAePkJDbXr7h713afU1q7UmHlMNGrzZLaucE2jGOv9f6YqTBYxP3ZCtqfjm3XXVvmIpPcZmx1nG56aEn9TPvnrgh1mh/aKd9bLPOU43BNR1BKn8EfVKX5hMO/Pjur0Jvuny6Y7sYYm6SdIvr4iuvidzlX5SZOknpqfDGh6FHZk019xUFL9+WuOhgQwpyQzg5IqI5MIA2pWYYKnRBYGVICS69C1IucAERRttjjyHMgELgbcOQUBdiPyDW4tnCha7qHmI4RbQTkJOQikUbSxMuLNVwHerGwQ57EyGACVpjGDeADV4J9drAQAAA== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidPeriodicWorkRequestInterval.md.html b/docs/checks/InvalidPeriodicWorkRequestInterval.md.html index 175e203..fbe39f3 100644 --- a/docs/checks/InvalidPeriodicWorkRequestInterval.md.html +++ b/docs/checks/InvalidPeriodicWorkRequestInterval.md.html @@ -43,6 +43,52 @@ The interval duration for a `PeriodicWorkRequest` must be at least 15 minutes. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/Test.kt:9:Error: Interval duration for +`PeriodicWorkRequest`s must be at least 15 minutes. +[InvalidPeriodicWorkRequestInterval] + val builder = PeriodicWorkRequest.Builder(TestWorker::class.java, 15L, TimeUnit.MILLISECONDS) + ------------------------------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`com/example/TestWorker.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import androidx.work.ListenableWorker + +class TestWorker: ListenableWorker() +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`com/example/Test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import androidx.work.PeriodicWorkRequest +import com.example.TestWorker +import java.util.concurrent.TimeUnit + +class Test { + fun enqueue() { + val builder = PeriodicWorkRequest.Builder(TestWorker::class.java, 15L, TimeUnit.MILLISECONDS) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/work-lint/src/test/java/androidx/work/lint/InvalidPeriodicWorkRequestIntervalDetectorTest.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, `InvalidPeriodicWorkRequestIntervalDetector.testWithInvalidDurationTimeUnits`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=409906. + (##) Including !!! diff --git a/docs/checks/InvalidPermission.md.html b/docs/checks/InvalidPermission.md.html index b4f031e..3a4c51e 100644 --- a/docs/checks/InvalidPermission.md.html +++ b/docs/checks/InvalidPermission.md.html @@ -40,14 +40,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:19:Error: Protecting an unsupported element with a permission is a no-op and potentially dangerous [InvalidPermission] - android:permission="android.permission.READ_CONTACTS"/> ----------------------------------------------------- - - AndroidManifest.xml:22:Error: Protecting an unsupported element with a permission is a no-op and potentially dangerous [InvalidPermission] - android:permission="android.permission.SET_WALLPAPER"/> ----------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidResourceFolder.md.html b/docs/checks/InvalidResourceFolder.md.html index 5743e79..5078266 100644 --- a/docs/checks/InvalidResourceFolder.md.html +++ b/docs/checks/InvalidResourceFolder.md.html @@ -54,11 +54,30 @@ [InvalidResourceFolder] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values-ldtrl-mnc123/strings.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers -<resources>null</resources> +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-kok-rIN/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-no-rNOR/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the diff --git a/docs/checks/InvalidSetHasFixedSize.md.html b/docs/checks/InvalidSetHasFixedSize.md.html index 665f246..6501465 100644 --- a/docs/checks/InvalidSetHasFixedSize.md.html +++ b/docs/checks/InvalidSetHasFixedSize.md.html @@ -1,18 +1,15 @@ -(#) When using `setHasFixedSize() in an `RecyclerView`, `wrap_content` cannot be used as \ -a value for `size` in the scrolling direction. +(#) When using `setHasFixedSize()` in an `RecyclerView`, `wrap_content` cannot be used as a value for `size` in the scrolling direction. - !!! ERROR: When using `setHasFixedSize() in an `RecyclerView`, `wrap_content` cannot be used as \ -a value for `size` in the scrolling direction. - This is an error, and is also enforced at build time when - supported by the build system. For Android this means it will - run during release builds. +!!! ERROR: When using `setHasFixedSize()` in an `RecyclerView`, `wrap_content` cannot be used as a value for `size` in the scrolling direction. + This is an error, and is also enforced at build time when + supported by the build system. For Android this means it will + run during release builds. Id : `InvalidSetHasFixedSize` Summary -: When using `setHasFixedSize() in an `RecyclerView`, `wrap_content` cannot be used as \ -a value for `size` in the scrolling direction. +: When using `setHasFixedSize()` in an `RecyclerView`, `wrap_content` cannot be used as a value for `size` in the scrolling direction. Severity : Fatal Category @@ -46,6 +43,65 @@ When a RecyclerView uses `setHasFixedSize(...)` you cannot use `wrap_content` for size in the scrolling direction. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/Example.kt:10:Error: When using `setHasFixedSize() in an +RecyclerView, wrap_content cannot be used as a value for size in the +scrolling direction. [InvalidSetHasFixedSize] + recyclerView?.setHasFixedSize(true) + ----------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`layout/recycler_view.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> + <androidx.recyclerview.widget.RecyclerView + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/my_recycler_view" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`com/example/R.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +object R { + object id { + const val my_recycler_view = 0 + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`com/example/Example.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import android.view.View +import androidx.recyclerview.widget.RecyclerView + +class Example { + fun main() { + val view: View = TODO() + val recyclerView = view.findViewById(R.id.my_recycler_view) + recyclerView?.setHasFixedSize(true) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/recyclerview/recyclerview-lint/src/test/java/androidx/recyclerview/lint/InvalidSetHasFixedSizeTest.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, `InvalidSetHasFixedSizeDetector.testInCorrectUsageOfFixedSize`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=460887. + (##) Including !!! diff --git a/docs/checks/InvalidSingleLineComment.md.html b/docs/checks/InvalidSingleLineComment.md.html index f7e04fd..ad4731e 100644 --- a/docs/checks/InvalidSingleLineComment.md.html +++ b/docs/checks/InvalidSingleLineComment.md.html @@ -1,13 +1,13 @@ -(#) Marks single line comments that are not sentences. +(#) Marks single line comments that are not sentences -!!! WARNING: Marks single line comments that are not sentences. +!!! WARNING: Marks single line comments that are not sentences This is a warning. Id : `InvalidSingleLineComment` Summary -: Marks single line comments that are not sentences. +: Marks single line comments that are not sentences Severity : Warning Category @@ -29,10 +29,49 @@ : Gradle build files and Kotlin and Java files Editing : This check can *not* run live in the IDE editor +Implementation +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/main/kotlin/com/vanniktech/lintrules/android/InvalidSingleLineCommentDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidSingleLineCommentDetectorTest.kt) Single line comments should always be sentences. They're part of the code and hence they deserve as much detail and respect as code. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:5:Warning: Comment does not contain a space at the +beginning [InvalidSingleLineComment] + //Something. + --- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +class Example { + public void foo() { + //Something. + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidSingleLineCommentDetectorTest.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, `InvalidSingleLineCommentDetector.invalidSingleLineCommentNoSpace`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/InvalidString.md.html b/docs/checks/InvalidString.md.html index 4727f64..3d0baa6 100644 --- a/docs/checks/InvalidString.md.html +++ b/docs/checks/InvalidString.md.html @@ -1,13 +1,13 @@ -(#) Marks invalid translation strings. +(#) Marks invalid translation strings -!!! WARNING: Marks invalid translation strings. +!!! WARNING: Marks invalid translation strings This is a warning. Id : `InvalidString` Summary -: Marks invalid translation strings. +: Marks invalid translation strings Severity : Warning Category @@ -29,10 +29,46 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/InvalidStringDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidStringDetectorTest.kt) A translation string is invalid if it contains new lines instead of the escaped \n or if it contains trailing whitespace. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/values/strings.xml:2:Warning: Text contains new line. +[InvalidString] + <string name="my_string">My string" + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="my_string">My string" +</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/InvalidStringDetectorTest.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, `InvalidStringDetector.stringContainingNewLine`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/InvalidUseOfOnBackPressed.md.html b/docs/checks/InvalidUseOfOnBackPressed.md.html index a729830..fe8ce34 100644 --- a/docs/checks/InvalidUseOfOnBackPressed.md.html +++ b/docs/checks/InvalidUseOfOnBackPressed.md.html @@ -35,6 +35,8 @@ : https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture#ui-logic Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/activity/activity-lint/src/main/java/androidx/activity/lint/OnBackPressedDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/activity/activity-lint/src/test/java/androidx/activity/lint/OnBackPressedDispatcherTest.kt) Copyright Year : 2024 @@ -42,6 +44,53 @@ |add a callback, you have to handle back completely in the callback. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/com/example/test.kt:12:Warning: Should not call onBackPressed inside +of OnBackPressedCallback.handledOnBackPressed +[InvalidUseOfOnBackPressed] + activity.onBackPressed() + ------------------------ +src/com/example/test.kt:14:Warning: Should not call onBackPressed inside +of OnBackPressedCallback.handledOnBackPressed +[InvalidUseOfOnBackPressed] + dispatcher.onBackPressed() + -------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/com/example/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import androidx.activity.ComponentActivity +import androidx.activity.OnBackPressedCallback +import androidx.activity.OnBackPressedDispatcher + +fun test() { + object: OnBackPressedCallback { + override fun handledOnBackPressed() { + val activity = ComponentActivity() + activity.onBackPressed() + val dispatcher = OnBackPressedDispatcher() + dispatcher.onBackPressed() + } + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/activity/activity-lint/src/test/java/androidx/activity/lint/OnBackPressedDispatcherTest.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, `OnBackPressedDetector.expectFailOnBackPressed`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=527362. + (##) Including !!! diff --git a/docs/checks/InvalidUsesTagAttribute.md.html b/docs/checks/InvalidUsesTagAttribute.md.html index fae0381..cd277ce 100644 --- a/docs/checks/InvalidUsesTagAttribute.md.html +++ b/docs/checks/InvalidUsesTagAttribute.md.html @@ -45,12 +45,45 @@ res/xml/automotive_app_desc.xml:3:Error: Expecting one of media, notification, sms, or template for the name attribute in uses tag [InvalidUsesTagAttribute] - <uses name="medias"/> ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.example.android.uamp"> + + <application + android:name=".UAMPApplication" + android:label="@string/app_name" + android:theme="@style/UAmpAppTheme"> + + <meta-data + android:name="com.google.android.gms.car.application" + android:resource="@xml/automotive_app_desc"/> + + <service + android:name=".MusicService" + android:exported="true" + tools:ignore="ExportedService"> + <intent-filter> + <action android:name="android.media.browse.MediaBrowserService"/> + </intent-filter> + <intent-filter> + <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH"/> + <category android:name="android.intent.category.DEFAULT"/> + </intent-filter> + </service> + + </application> + +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/xml/automotive_app_desc.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers diff --git a/docs/checks/InvalidVectorPath.md.html b/docs/checks/InvalidVectorPath.md.html index de08ed1..989d2bb 100644 --- a/docs/checks/InvalidVectorPath.md.html +++ b/docs/checks/InvalidVectorPath.md.html @@ -47,7 +47,6 @@ res/drawable/my_vector.xml:7:Error: Avoid scientific notation (1.05e-4) in vector paths because it can lead to crashes on some devices. Use 0.000105 instead. [InvalidVectorPath] - android:pathData="m 1.05e-4,2.75448" /> ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidWakeLockTag.md.html b/docs/checks/InvalidWakeLockTag.md.html index 8c414fe..d14f0bd 100644 --- a/docs/checks/InvalidWakeLockTag.md.html +++ b/docs/checks/InvalidWakeLockTag.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/WakelockActivity.java:12:Error: Tag name should not be empty to make wake lock problems easier to debug [InvalidWakeLockTag] - mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); ------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/InvalidWearFeatureAttribute.md.html b/docs/checks/InvalidWearFeatureAttribute.md.html index 43a1d70..59f1aaa 100644 --- a/docs/checks/InvalidWearFeatureAttribute.md.html +++ b/docs/checks/InvalidWearFeatureAttribute.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:4:Error: android:required="false" is not supported for this feature [InvalidWearFeatureAttribute] - <uses-feature android:name="android.hardware.type.watch" android:required="false"/> ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/JCenter.md.html b/docs/checks/JCenter.md.html index 80f86c7..bc99966 100644 --- a/docs/checks/JCenter.md.html +++ b/docs/checks/JCenter.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of the jcenter() repository. +(#) Marks usage of the jcenter() repository -!!! WARNING: Marks usage of the jcenter() repository. +!!! WARNING: Marks usage of the jcenter() repository This is a warning. Id : `JCenter` Summary -: Marks usage of the jcenter() repository. +: Marks usage of the jcenter() repository Severity : Warning Category @@ -29,11 +29,47 @@ : Gradle build 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/kotlin/com/vanniktech/lintrules/android/JcenterDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/JcenterDetectorTest.kt) JCenter has gotten less and less reliable and it's best to avoid if possible. This check will flag usages of jcenter() in your gradle files. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +build.gradle:3:Warning: Don't use jcenter() [JCenter] + jcenter() + --------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +buildscript { + repositories { + jcenter() + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/JcenterDetectorTest.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, `JcenterDetector.jcenter`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/JavaOnlyDetector.md.html b/docs/checks/JavaOnlyDetector.md.html index ec1b362..e0a85f3 100644 --- a/docs/checks/JavaOnlyDetector.md.html +++ b/docs/checks/JavaOnlyDetector.md.html @@ -1,13 +1,13 @@ -(#) Using @JavaOnly elements in Kotlin code. +(#) Using @JavaOnly elements in Kotlin code -!!! ERROR: Using @JavaOnly elements in Kotlin code. +!!! ERROR: Using @JavaOnly elements in Kotlin code This is an error. Id : `JavaOnlyDetector` Summary -: Using @JavaOnly elements in Kotlin code. +: Using @JavaOnly elements in Kotlin code Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/JavaOnlyDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/JavaOnlyDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/JavaOnlyDetectorTest.kt) Copyright Year @@ -48,21 +48,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text test/test/pkg/Test.kt:7:Error: This method should not be called from Kotlin, see its documentation for details. [JavaOnlyDetector] - g() --- - - test/test/pkg/Test.kt:8:Error: This method should not be called from Kotlin: satisfying explanation [JavaOnlyDetector] - f() --- - - test/test/pkg/Test.kt:9:Error: This method should not be called from Kotlin, see its documentation for details. [JavaOnlyDetector] - val r = this::g ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/JavaPluginLanguageLevel.md.html b/docs/checks/JavaPluginLanguageLevel.md.html index a096908..40b11da 100644 --- a/docs/checks/JavaPluginLanguageLevel.md.html +++ b/docs/checks/JavaPluginLanguageLevel.md.html @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:2:Warning: no Java sourceCompatibility directive [JavaPluginLanguageLevel] - id 'java' --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/JavascriptInterface.md.html b/docs/checks/JavascriptInterface.md.html index 331fd24..6579278 100644 --- a/docs/checks/JavascriptInterface.md.html +++ b/docs/checks/JavascriptInterface.md.html @@ -45,39 +45,83 @@ added interface (NonAnnotatedObject) have been annotated with @android.webkit.JavascriptInterface; they will not be visible in API 17 [JavascriptInterface] - webview.addJavascriptInterface(new NonAnnotatedObject(), "myobj"); ---------------------- - - src/test/pkg/JavaScriptTest.java:14:Error: None of the methods in the added interface (NonAnnotatedObject) have been annotated with @android.webkit.JavascriptInterface; they will not be visible in API 17 [JavascriptInterface] - webview.addJavascriptInterface(o, "myobj"); ---------------------- - - src/test/pkg/JavaScriptTest.java:21:Error: None of the methods in the added interface (NonAnnotatedObject) have been annotated with @android.webkit.JavascriptInterface; they will not be visible in API 17 [JavascriptInterface] - webview.addJavascriptInterface(object2, "myobj"); ---------------------- - - src/test/pkg/JavaScriptTest.java:32:Error: None of the methods in the added interface (NonAnnotatedObject) have been annotated with @android.webkit.JavascriptInterface; they will not be visible in API 17 [JavascriptInterface] - webview.addJavascriptInterface(t, "myobj"); ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/AnnotatedObject.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.webkit.JavascriptInterface; + +@SuppressWarnings("ClassNameDiffersFromFileName") +public class AnnotatedObject { + @JavascriptInterface + public void test1() { + } + + public void test2() { + } + + @JavascriptInterface + public void test3() { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritsFromAnnotated.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.webkit.JavascriptInterface; + +@SuppressWarnings("ClassNameDiffersFromFileName") +public class InheritsFromAnnotated extends AnnotatedObject { + + @Override + public void test1() { + } + + @Override + public void test2() { + } + +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/NonAnnotatedObject.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +@SuppressWarnings("ClassNameDiffersFromFileName") +public class NonAnnotatedObject { + public void test1() { + } + public void test2() { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/JavaScriptTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/JcenterRepositoryObsolete.md.html b/docs/checks/JcenterRepositoryObsolete.md.html index ec6475b..be9b297 100644 --- a/docs/checks/JcenterRepositoryObsolete.md.html +++ b/docs/checks/JcenterRepositoryObsolete.md.html @@ -45,15 +45,11 @@ build.gradle:7:Warning: JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere [JcenterRepositoryObsolete] - jcenter() --------- - - build.gradle:14:Warning: JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere [JcenterRepositoryObsolete] - jcenter() --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/JobSchedulerService.md.html b/docs/checks/JobSchedulerService.md.html index 8d9129f..5537afa 100644 --- a/docs/checks/JobSchedulerService.md.html +++ b/docs/checks/JobSchedulerService.md.html @@ -43,20 +43,16 @@ src/test/pkg/JobSchedulerTest.java:21:Warning: Scheduled job class NotAJobService must extend android.app.job.JobService [JobSchedulerService] - new ComponentName(this, NotAJobService.class)); --------------------------------------------- - - src/test/pkg/JobSchedulerTest.java:29:Warning: Scheduled job class NotAJobService must extend android.app.job.JobService [JobSchedulerService] - new ComponentName(this, NotAJobService.class)); --------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/JobSchedulerTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -96,6 +92,55 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyJobService.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.annotation.TargetApi; +import android.app.job.JobParameters; +import android.app.job.JobService; +import android.os.Build; + +@TargetApi(Build.VERSION_CODES.LOLLIPOP) +public class MyJobService extends JobService { + @Override + public boolean onStartJob(JobParameters jobParameters) { + return false; + } + + @Override + public boolean onStopJob(JobParameters jobParameters) { + return false; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/NotAJobService.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Service; + +public abstract class NotAJobService extends Service { +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="test.pkg"> + + <application> + <service android:name=".MyJobService" + android:permission="android.permission.BIND_JOB_SERVICE" + android:exported="true" /> + <service android:name=".NotAJobService" + android:exported="true" /> + </application> + +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/JobSchedulerDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/JvmStaticProvidesInObjectDetector.md.html b/docs/checks/JvmStaticProvidesInObjectDetector.md.html index af71fa6..c9e37b1 100644 --- a/docs/checks/JvmStaticProvidesInObjectDetector.md.html +++ b/docs/checks/JvmStaticProvidesInObjectDetector.md.html @@ -49,21 +49,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:26:Warning: @JvmStatic used for @Provides function in an object class [JvmStaticProvidesInObjectDetector] - @JvmStatic ---------- - - src/foo/MyQualifier.kt:43:Warning: @JvmStatic used for @Provides function in an object class [JvmStaticProvidesInObjectDetector] - @JvmStatic ---------- - - src/foo/MyQualifier.kt:56:Warning: @JvmStatic used for @Provides function in an object class [JvmStaticProvidesInObjectDetector] - @kotlin.jvm.JvmStatic --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KaptUsageInsteadOfKsp.md.html b/docs/checks/KaptUsageInsteadOfKsp.md.html index cff8de7..d379fea 100644 --- a/docs/checks/KaptUsageInsteadOfKsp.md.html +++ b/docs/checks/KaptUsageInsteadOfKsp.md.html @@ -42,34 +42,24 @@ which greatly improves performance. Learn more: https://developer.android.com/studio/build/migrate-to-ksp [KaptUsageInsteadOfKsp] - kapt 'androidx.room:room-compiler:2.5.0' ---------------------------------------- - - build.gradle:10:Warning: This library supports using KSP instead of kapt, which greatly improves performance. Learn more: https://developer.android.com/studio/build/migrate-to-ksp [KaptUsageInsteadOfKsp] - kapt "androidx.room:room-compiler:$room_version" ------------------------------------------------ - - build.gradle:13:Warning: This library supports using KSP instead of kapt, which greatly improves performance. Learn more: https://developer.android.com/studio/build/migrate-to-ksp [KaptUsageInsteadOfKsp] - kapt 'com.github.bumptech.glide:compiler:4.14.2' ------------------------------------------------ - - build.gradle:14:Warning: This library supports using KSP instead of kapt, which greatly improves performance. Learn more: https://developer.android.com/studio/build/migrate-to-ksp [KaptUsageInsteadOfKsp] - kapt("com.github.bumptech.glide:compiler:glide_version") -------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KeyboardInaccessibleWidget.md.html b/docs/checks/KeyboardInaccessibleWidget.md.html index 91b7c86..2ab8b04 100644 --- a/docs/checks/KeyboardInaccessibleWidget.md.html +++ b/docs/checks/KeyboardInaccessibleWidget.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/mywidget.xml:2:Warning: 'clickable' attribute found, please also add 'focusable' [KeyboardInaccessibleWidget] - android:clickable="true" /> ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KnownPermissionError.md.html b/docs/checks/KnownPermissionError.md.html index 734e3dc..c3f0d27 100644 --- a/docs/checks/KnownPermissionError.md.html +++ b/docs/checks/KnownPermissionError.md.html @@ -44,42 +44,26 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:4:Error: true is not a valid permission value [KnownPermissionError] - <application android:permission="true"> ---- - - AndroidManifest.xml:5:Error: TRUE is not a valid permission value [KnownPermissionError] - <activity android:permission="TRUE" /> ---- - - AndroidManifest.xml:6:Error: True is not a valid permission value [KnownPermissionError] - <activity-alias android:permission="True" /> ---- - - AndroidManifest.xml:7:Error: true is not a valid permission value [KnownPermissionError] - <receiver android:permission="true" /> ---- - - AndroidManifest.xml:8:Error: false is not a valid permission value [KnownPermissionError] - <service android:permission="false" /> ----- - - AndroidManifest.xml:9:Error: false is not a valid permission value [KnownPermissionError] - <provider android:permission="false" /> ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KotlinNullnessAnnotation.md.html b/docs/checks/KotlinNullnessAnnotation.md.html index 5b6fcf7..665950d 100644 --- a/docs/checks/KotlinNullnessAnnotation.md.html +++ b/docs/checks/KotlinNullnessAnnotation.md.html @@ -44,25 +44,18 @@ src/test/pkg/test.kt:7:Warning: Do not use @NonNull in Kotlin; the nullability is already implied by the Kotlin type String not ending with ? [KotlinNullnessAnnotation] - fun testWarning(@NonNull string: String) { } -------- - - src/test/pkg/test.kt:11:Error: Do not use @Nullable in Kotlin; the nullability is determined by the Kotlin type String not ending with ? which declares it not nullable, contradicting the annotation [KotlinNullnessAnnotation] - fun testError(@Nullable string: String) { } --------- - - src/test/pkg/test.kt:15:Error: Do not use @NonNull in Kotlin; the nullability is determined by the Kotlin type Number? ending with ? which declares it nullable, contradicting the annotation [KotlinNullnessAnnotation] - fun testError(@NonNull number: Number?) { } -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KotlinPairNotCreated.md.html b/docs/checks/KotlinPairNotCreated.md.html index fc2342a..a242a2a 100644 --- a/docs/checks/KotlinPairNotCreated.md.html +++ b/docs/checks/KotlinPairNotCreated.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/NonKotlinPairDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/NonKotlinPairDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/NonKotlinPairDetectorTest.kt) Copyright Year @@ -52,7 +52,6 @@ src/slack/test/TestClass.java:10:Warning: Use Kotlin's kotlin.Pair instead of other Pair types from other libraries like AndroidX and Slack commons [KotlinPairNotCreated] - Pair pair = Pair.create("first", "second"); ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KotlinPropertyAccess.md.html b/docs/checks/KotlinPropertyAccess.md.html index 0b84a4f..f3e7971 100644 --- a/docs/checks/KotlinPropertyAccess.md.html +++ b/docs/checks/KotlinPropertyAccess.md.html @@ -48,67 +48,48 @@ see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - public String hasError1() { return ""; } --------- - - src/test/pkg/GetterSetter.java:34:Warning: This method should be called getError2 such that error2 can be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - public String error2() { return ""; } ------ - - src/test/pkg/GetterSetter.java:38:Warning: This method should be called getError3 such that error3 can be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - public String hazzError3() { return ""; } ---------- - - src/test/pkg/GetterSetter.java:42:Warning: The getter return type (Integer) and setter parameter type (String) getter and setter methods for property error4 should have exactly the same type to allow be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - public Integer getError4() { return 0; } --------- - - src/test/pkg/GetterSetter.java:46:Warning: This getter should be public such that error5 can be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - protected String getError5() { return ""; } --------- - - src/test/pkg/GetterSetter.java:50:Warning: This getter should not be static such that error6 can be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - public static String getError6() { return ""; } ------ - - src/test/pkg/GetterSetter.java:70:Warning: The getter return type (Float) is not the same as the super return type (Number); they should have exactly the same type to allow number3 be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes [KotlinPropertyAccess] - @Override public Float getNumber3() { return 0.0f; } // ERROR (even though we have corresponding setter) ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KotlinRequireNotNullUseMessage.md.html b/docs/checks/KotlinRequireNotNullUseMessage.md.html index f8bc4b9..bcdaff9 100644 --- a/docs/checks/KotlinRequireNotNullUseMessage.md.html +++ b/docs/checks/KotlinRequireNotNullUseMessage.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of the requireNotNull method without lazy messages. +(#) Marks usage of the requireNotNull method without lazy messages -!!! WARNING: Marks usage of the requireNotNull method without lazy messages. +!!! WARNING: Marks usage of the requireNotNull method without lazy messages This is a warning. Id : `KotlinRequireNotNullUseMessage` Summary -: Marks usage of the requireNotNull method without lazy messages. +: Marks usage of the requireNotNull method without lazy messages Severity : Warning Category @@ -29,10 +29,42 @@ : 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-kotlin-lint/src/main/kotlin/com/vanniktech/lintrules/kotlin/KotlinRequireNotNullUseMessageDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-kotlin-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/KotlinRequireNotNullUseMessageDetectorTest.kt) The default generated message from requireNotNull often lacks context, hence it's best to provide a custom message. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/test.kt:2:Warning: Provide a message +[KotlinRequireNotNullUseMessage] + requireNotNull(value) + -------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +fun test(value: Int?) { + requireNotNull(value) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-kotlin-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/KotlinRequireNotNullUseMessageDetectorTest.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, `KotlinRequireNotNullUseMessageDetector.requireNotNull`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/KotlincFE10.md.html b/docs/checks/KotlincFE10.md.html index f9245bb..d21775f 100644 --- a/docs/checks/KotlincFE10.md.html +++ b/docs/checks/KotlincFE10.md.html @@ -43,61 +43,42 @@ org.jetbrains.kotlin.resolve.BindingContext appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - val bindingContext = service.getBindingContext(declaration) // ERROR -------------------------------------- - - src/test/pkg/TestVisitor.kt:29:Warning: org.jetbrains.kotlin.resolve.BindingContext appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - val type = bindingContext.getType(expression) ?: return // ERROR -------------- - - src/test/pkg/TestVisitor.kt:30:Warning: org.jetbrains.kotlin.types.KotlinType appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - if (type.isDynamic()) return // ERROR ---- - - src/test/pkg/TestVisitor.kt:37:Warning: org.jetbrains.kotlin.resolve.BindingContext appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - bindingContext: BindingContext, // ERROR -------------- - - src/test/pkg/TestVisitor.kt:41:Warning: org.jetbrains.kotlin.resolve.BindingContext appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, node.sourcePsi) // ERROR -------------- - - src/test/pkg/TestVisitor.kt:42:Warning: org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - if (descriptor is DeclarationDescriptorWithVisibility) { // ERROR ----------------------------------- - - src/test/pkg/TestVisitor.kt:43:Warning: org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility appears to be part of the old K1 Kotlin compiler. Avoid using it if possible; K1 will be going away soon. [KotlincFE10] - val effectiveVisibility = descriptor.visibility.effectiveVisibility(descriptor, false) // ERROR ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/KtxExtensionAvailable.md.html b/docs/checks/KtxExtensionAvailable.md.html index baa0d38..f83100e 100644 --- a/docs/checks/KtxExtensionAvailable.md.html +++ b/docs/checks/KtxExtensionAvailable.md.html @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:7:Information: Add suffix -ktx to enable the Kotlin extensions for this library [KtxExtensionAvailable] - implementation "androidx.core:core:1.2.0" -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LabelFor.md.html b/docs/checks/LabelFor.md.html index d2f3e3e..91f205b 100644 --- a/docs/checks/LabelFor.md.html +++ b/docs/checks/LabelFor.md.html @@ -48,21 +48,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/labelfororhint_empty_hint.xml:11:Warning: Empty android:hint attribute [LabelFor] - android:hint="" --------------- - - res/layout/labelfororhint_empty_hint.xml:21:Warning: Empty android:hint attribute [LabelFor] - android:hint="" --------------- - - res/layout/labelfororhint_empty_hint.xml:29:Warning: Empty android:hint attribute [LabelFor] - android:hint="" --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LambdaLast.md.html b/docs/checks/LambdaLast.md.html index 0908b14..8d90063 100644 --- a/docs/checks/LambdaLast.md.html +++ b/docs/checks/LambdaLast.md.html @@ -45,22 +45,18 @@ improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions [LambdaLast] - public void error1(Runnable run, int x) { } ----- - - src/test/pkg/Test.java:12:Warning: Functional interface parameters (such as parameter 1, "sam", in test.pkg.Test.error2) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions [LambdaLast] - public void error2(SamInterface sam, int x) { } ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/Test.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -85,6 +81,19 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +fun ok1(bar: (Int) -> Int) { } +fun ok2(foo: Int) { } +fun ok3(foo: Int, bar: (Int) -> Int) { } +fun ok4(foo: Int, bar: (Int) -> Int, baz: (Int) -> Int) { } +// Lamda not last, but we're not flagging issues in Kotlin files for the +// interoperability issue +fun error(bar: (Int) -> Int, foo: Int) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/InteroperabilityDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LaunchActivityFromNotification.md.html b/docs/checks/LaunchActivityFromNotification.md.html index e630a84..9e8dc1e 100644 --- a/docs/checks/LaunchActivityFromNotification.md.html +++ b/docs/checks/LaunchActivityFromNotification.md.html @@ -50,12 +50,31 @@ src/test/pkg/NotificationTest.java:22:Warning: Notifications should only launch a Service from notification actions (addAction) [LaunchActivityFromNotification] - .setContentIntent(serviceIntent) ------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/BroadcastTrampoline.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class BroadcastTrampoline extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + // The start below will be blocked + Intent i = new Intent(); + i.setClassName("test.pkg", "test.pkg.SecondActivity"); + i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(i); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/NotificationTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/LaunchDuringComposition.md.html b/docs/checks/LaunchDuringComposition.md.html index 21cdba9..07ffe49 100644 --- a/docs/checks/LaunchDuringComposition.md.html +++ b/docs/checks/LaunchDuringComposition.md.html @@ -49,49 +49,30 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/com/example/test.kt:10:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ - - src/com/example/test.kt:15:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ - - src/com/example/test.kt:20:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ - - src/com/example/test.kt:30:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ - - src/com/example/test.kt:34:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ - - src/com/example/test.kt:41:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ - - src/com/example/test.kt:46:Error: Calls to launch should happen inside of a SideEffect and not during composition [LaunchDuringComposition] - launcher.launch("test") ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LayoutFileNameMatchesClass.md.html b/docs/checks/LayoutFileNameMatchesClass.md.html index 4a4ea4e..cbf2ca5 100644 --- a/docs/checks/LayoutFileNameMatchesClass.md.html +++ b/docs/checks/LayoutFileNameMatchesClass.md.html @@ -1,13 +1,13 @@ -(#) Checks that the layout file matches the class name. +(#) Checks that the layout file matches the class name -!!! WARNING: Checks that the layout file matches the class name. +!!! WARNING: Checks that the layout file matches the class name This is a warning. Id : `LayoutFileNameMatchesClass` Summary -: Checks that the layout file matches the class name. +: Checks that the layout file matches the class name Severity : Warning Category @@ -29,10 +29,63 @@ : 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/kotlin/com/vanniktech/lintrules/android/LayoutFileNameMatchesClassDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/LayoutFileNameMatchesClassDetectorTest.kt) Layout file names should always match the name of the class. FooActivity should have a layout file named activity_foo hence. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/main/java/foo/FooActivity.java:5:Warning: Parameter should be named +R.layout.unit_test_activity_foo [LayoutFileNameMatchesClass] + setContentView(R.layout.activity_bar); + --------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`src/foo/Activity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +public abstract class Activity { + public void setContentView(int viewId) { } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/main/java/foo/FooActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +class FooActivity extends Activity { + void foo() { + setContentView(R.layout.activity_bar); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`null`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers +unit_test_ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/LayoutFileNameMatchesClassDetectorTest.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, `LayoutFileNameMatchesClassDetector.fooActivityUsesActivityBarWithResourcePrefix`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/LeanbackUsesWifi.md.html b/docs/checks/LeanbackUsesWifi.md.html index 177f396..a8d963e 100644 --- a/docs/checks/LeanbackUsesWifi.md.html +++ b/docs/checks/LeanbackUsesWifi.md.html @@ -47,7 +47,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:4:Warning: Requiring Wifi permissions limits app availability on TVs that support only Ethernet [LeanbackUsesWifi] - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> ---------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LibraryCustomView.md.html b/docs/checks/LibraryCustomView.md.html index 3f98d0a..63b3508 100644 --- a/docs/checks/LibraryCustomView.md.html +++ b/docs/checks/LibraryCustomView.md.html @@ -45,7 +45,6 @@ res/layout/customview.xml:5:Error: When using a custom namespace attribute in a library project, use the namespace "http://schemas.android.com/apk/res-auto" instead [LibraryCustomView] - xmlns:foo="http://schemas.android.com/apk/res/foo" -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LifecycleAnnotationProcessorWithJava8.md.html b/docs/checks/LifecycleAnnotationProcessorWithJava8.md.html index 7d14a70..ef3598e 100644 --- a/docs/checks/LifecycleAnnotationProcessorWithJava8.md.html +++ b/docs/checks/LifecycleAnnotationProcessorWithJava8.md.html @@ -53,7 +53,6 @@ build.gradle:3:Warning: Use the Lifecycle Java 8 API provided by the lifecycle-common library instead of Lifecycle annotations for faster incremental build. [LifecycleAnnotationProcessorWithJava8] - annotationProcessor "android.arch.lifecycle:compiler:1.1.1" --------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LintDocExample.md.html b/docs/checks/LintDocExample.md.html index fed848e..87eb83e 100644 --- a/docs/checks/LintDocExample.md.html +++ b/docs/checks/LintDocExample.md.html @@ -51,12 +51,236 @@ find a documentation example test (testDocumentationExample) which shows a simple, typical scenario which triggers the test, and which will be extracted into lint's per-issue documentation pages [LintDocExample] - fun testBasic() { ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/MyJavaLintDetector.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiCallExpression; +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.util.PsiTreeUtil; +import com.android.tools.lint.detector.api.Detector; +import org.jetbrains.uast.UFile; +import org.jetbrains.uast.UMethod; +import org.jetbrains.uast.UField; +import com.android.tools.lint.detector.api.Category; +import com.android.tools.lint.detector.api.Detector; +import com.android.tools.lint.detector.api.Implementation; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.JavaContext; +import com.android.tools.lint.detector.api.Scope; +import com.android.tools.lint.detector.api.Severity; +import org.jetbrains.uast.UCallExpression; +import java.util.EnumSet; + +@SuppressWarnings({"MethodMayBeStatic", "ClassNameDiffersFromFileName", "StatementWithEmptyBody", "deprecation"}) +public class MyJavaLintDetector extends Detector { + public static final Issue ISSUE = + Issue.create( + "com.android.namespaced.lint.check.FooDetector", + "Wrong use of ", + "As described in " + + "https://code.google.com/p/android/issues/detail?id=65351 blah blah blah.", + Category.A11Y, + 3, + Severity.WARNING, + new Implementation(MyJavaLintDetector.class, EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE))) + .addMoreInfo("file://explanation.doc") + .addMoreInfo("http://my.personal.blogger.com/aboutme.htm") + .addMoreInfo("mailto:lint@example.com"); + public void testGetBody(PsiMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetBody(UMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetContainingClass(UMethod method, UField field) { + method.getContainingClass(); // ERROR - must use UAST + field.getContainingClass(); // ERROR - must use UAST + } + public void testGetContainingClass(PsiMethod method, PsiField field) { + method.getContainingClass(); // OK - legitimate uses after resolve + field.getContainingClass(); // OK - legitimate uses after resolve + } + public void testEquals(PsiCallExpression element1, PsiExpression element2) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 != element2) { } + } + public void testGetInitializer(PsiField field) { + field.getInitializer(); // ERROR - must use UAST + } + public void testParents(PsiField field, UMethod method) { + PsiElement parent = field.getParent(); // OK + PsiElement parent = method.getParent(); // ERROR + PsiTreeUtil.getParentOfType(field, PsiClass.class); // OK + PsiTreeUtil.getParentOfType(method, PsiClass.class); // ERROR + } + + public void testReport(JavaContext context, UCallExpression node) { + context.report(ISSUE, node, context.getLocation(node), + "Wrong use of LinearLayout."); + context.report(ISSUE, node, context.getLocation(node), + "First problem. Second problem."); + context.report(ISSUE, node, context.getLocation(node), + "This is teh typo"); + String message = "Welcome to Andriod"; + context.report(ISSUE, node, context.getLocation(node), message); + context.report(ISSUE, node, context.getLocation(node), + "Should you use `x ?: y` instead of ```foo ? 1 : 0``` ?"); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/MyKotlinLintDetectorTest.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/LintImplBadUrl.md.html b/docs/checks/LintImplBadUrl.md.html index c430f58..5d0bcfd 100644 --- a/docs/checks/LintImplBadUrl.md.html +++ b/docs/checks/LintImplBadUrl.md.html @@ -43,19 +43,15 @@ src/test/pkg/MyJavaLintDetector.java:30:Error: Don't point to old http://b.android.com links; should be using https://issuetracker.google.com instead [LintImplBadUrl] - + "https://code.google.com/p/android/issues/detail?id=65351 blah blah blah.", -------------------------------------------------------- - - src/test/pkg/MyJavaLintDetector.java:35:Error: Unexpected protocol file in file://explanation.doc [LintImplBadUrl] - .addMoreInfo("file://explanation.doc") ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyJavaLintDetector.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -141,6 +137,201 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplDollarEscapes.md.html b/docs/checks/LintImplDollarEscapes.md.html index ff06674..1d7e31a 100644 --- a/docs/checks/LintImplDollarEscapes.md.html +++ b/docs/checks/LintImplDollarEscapes.md.html @@ -53,12 +53,236 @@ src/test/pkg/MyKotlinLintDetectorTest.kt:22:Error: In unit tests, use the fullwidth dollar sign, $, instead of $, to avoid having to use cumbersome escapes. Lint will treat a $ as a $. [LintImplDollarEscapes] - println("Value=${"$"}") ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/MyJavaLintDetector.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiCallExpression; +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.util.PsiTreeUtil; +import com.android.tools.lint.detector.api.Detector; +import org.jetbrains.uast.UFile; +import org.jetbrains.uast.UMethod; +import org.jetbrains.uast.UField; +import com.android.tools.lint.detector.api.Category; +import com.android.tools.lint.detector.api.Detector; +import com.android.tools.lint.detector.api.Implementation; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.JavaContext; +import com.android.tools.lint.detector.api.Scope; +import com.android.tools.lint.detector.api.Severity; +import org.jetbrains.uast.UCallExpression; +import java.util.EnumSet; + +@SuppressWarnings({"MethodMayBeStatic", "ClassNameDiffersFromFileName", "StatementWithEmptyBody", "deprecation"}) +public class MyJavaLintDetector extends Detector { + public static final Issue ISSUE = + Issue.create( + "com.android.namespaced.lint.check.FooDetector", + "Wrong use of ", + "As described in " + + "https://code.google.com/p/android/issues/detail?id=65351 blah blah blah.", + Category.A11Y, + 3, + Severity.WARNING, + new Implementation(MyJavaLintDetector.class, EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE))) + .addMoreInfo("file://explanation.doc") + .addMoreInfo("http://my.personal.blogger.com/aboutme.htm") + .addMoreInfo("mailto:lint@example.com"); + public void testGetBody(PsiMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetBody(UMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetContainingClass(UMethod method, UField field) { + method.getContainingClass(); // ERROR - must use UAST + field.getContainingClass(); // ERROR - must use UAST + } + public void testGetContainingClass(PsiMethod method, PsiField field) { + method.getContainingClass(); // OK - legitimate uses after resolve + field.getContainingClass(); // OK - legitimate uses after resolve + } + public void testEquals(PsiCallExpression element1, PsiExpression element2) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 != element2) { } + } + public void testGetInitializer(PsiField field) { + field.getInitializer(); // ERROR - must use UAST + } + public void testParents(PsiField field, UMethod method) { + PsiElement parent = field.getParent(); // OK + PsiElement parent = method.getParent(); // ERROR + PsiTreeUtil.getParentOfType(field, PsiClass.class); // OK + PsiTreeUtil.getParentOfType(method, PsiClass.class); // ERROR + } + + public void testReport(JavaContext context, UCallExpression node) { + context.report(ISSUE, node, context.getLocation(node), + "Wrong use of LinearLayout."); + context.report(ISSUE, node, context.getLocation(node), + "First problem. Second problem."); + context.report(ISSUE, node, context.getLocation(node), + "This is teh typo"); + String message = "Welcome to Andriod"; + context.report(ISSUE, node, context.getLocation(node), message); + context.report(ISSUE, node, context.getLocation(node), + "Should you use `x ?: y` instead of ```foo ? 1 : 0``` ?"); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/MyKotlinLintDetectorTest.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/LintImplIdFormat.md.html b/docs/checks/LintImplIdFormat.md.html index 9deaf91..857efff 100644 --- a/docs/checks/LintImplIdFormat.md.html +++ b/docs/checks/LintImplIdFormat.md.html @@ -55,12 +55,95 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/MyKotlinLintDetector.kt:60:Error: Lint issue IDs should use capitalized camel case, such as MyIssueId [LintImplIdFormat] - id = "badlyCapitalized id", --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/MyJavaLintDetector.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiCallExpression; +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.util.PsiTreeUtil; +import com.android.tools.lint.detector.api.Detector; +import org.jetbrains.uast.UFile; +import org.jetbrains.uast.UMethod; +import org.jetbrains.uast.UField; +import com.android.tools.lint.detector.api.Category; +import com.android.tools.lint.detector.api.Detector; +import com.android.tools.lint.detector.api.Implementation; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.JavaContext; +import com.android.tools.lint.detector.api.Scope; +import com.android.tools.lint.detector.api.Severity; +import org.jetbrains.uast.UCallExpression; +import java.util.EnumSet; + +@SuppressWarnings({"MethodMayBeStatic", "ClassNameDiffersFromFileName", "StatementWithEmptyBody", "deprecation"}) +public class MyJavaLintDetector extends Detector { + public static final Issue ISSUE = + Issue.create( + "com.android.namespaced.lint.check.FooDetector", + "Wrong use of ", + "As described in " + + "https://code.google.com/p/android/issues/detail?id=65351 blah blah blah.", + Category.A11Y, + 3, + Severity.WARNING, + new Implementation(MyJavaLintDetector.class, EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE))) + .addMoreInfo("file://explanation.doc") + .addMoreInfo("http://my.personal.blogger.com/aboutme.htm") + .addMoreInfo("mailto:lint@example.com"); + public void testGetBody(PsiMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetBody(UMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetContainingClass(UMethod method, UField field) { + method.getContainingClass(); // ERROR - must use UAST + field.getContainingClass(); // ERROR - must use UAST + } + public void testGetContainingClass(PsiMethod method, PsiField field) { + method.getContainingClass(); // OK - legitimate uses after resolve + field.getContainingClass(); // OK - legitimate uses after resolve + } + public void testEquals(PsiCallExpression element1, PsiExpression element2) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 != element2) { } + } + public void testGetInitializer(PsiField field) { + field.getInitializer(); // ERROR - must use UAST + } + public void testParents(PsiField field, UMethod method) { + PsiElement parent = field.getParent(); // OK + PsiElement parent = method.getParent(); // ERROR + PsiTreeUtil.getParentOfType(field, PsiClass.class); // OK + PsiTreeUtil.getParentOfType(method, PsiClass.class); // ERROR + } + + public void testReport(JavaContext context, UCallExpression node) { + context.report(ISSUE, node, context.getLocation(node), + "Wrong use of LinearLayout."); + context.report(ISSUE, node, context.getLocation(node), + "First problem. Second problem."); + context.report(ISSUE, node, context.getLocation(node), + "This is teh typo"); + String message = "Welcome to Andriod"; + context.report(ISSUE, node, context.getLocation(node), message); + context.report(ISSUE, node, context.getLocation(node), + "Should you use `x ?: y` instead of ```foo ? 1 : 0``` ?"); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/MyKotlinLintDetector.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -162,6 +245,101 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplPsiEquals.md.html b/docs/checks/LintImplPsiEquals.md.html index 131cc84..8030b0d 100644 --- a/docs/checks/LintImplPsiEquals.md.html +++ b/docs/checks/LintImplPsiEquals.md.html @@ -40,19 +40,15 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/MyJavaLintDetector.java:53:Error: Don't compare PsiElements with equals, use isEquivalentTo(PsiElement) instead [LintImplPsiEquals] - if (element1.equals(element2)) { } ------------------------- - - src/test/pkg/MyJavaLintDetector.java:54:Error: Don't compare PsiElements with equals, use isEquivalentTo(PsiElement) instead [LintImplPsiEquals] - if (element2.equals(element1)) { } ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyJavaLintDetector.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -138,6 +134,201 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplTextFormat.md.html b/docs/checks/LintImplTextFormat.md.html index a2b35cd..6a1f48d 100644 --- a/docs/checks/LintImplTextFormat.md.html +++ b/docs/checks/LintImplTextFormat.md.html @@ -52,33 +52,23 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/MyJavaLintDetector.java:70:Warning: Single sentence error messages should not end with a period [LintImplTextFormat] - "Wrong use of LinearLayout."); -------------------------- - - src/test/pkg/MyJavaLintDetector.java:74:Warning: "teh" is a common misspelling; did you mean "the"? [LintImplTextFormat] - "This is teh typo"); --- - - src/test/pkg/MyJavaLintDetector.java:76:Warning: "Andriod" is a common misspelling; did you mean "Android"? [LintImplTextFormat] - context.report(ISSUE, node, context.getLocation(node), message); ------- - - src/test/pkg/MyJavaLintDetector.java:78:Warning: Question marks should not be separated by a space [LintImplTextFormat] - "Should you use `x ?: y` instead of ```foo ? 1 : 0``` ?"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyJavaLintDetector.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -164,6 +154,201 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplTrimIndent.md.html b/docs/checks/LintImplTrimIndent.md.html index 4ac7bce..7cdbd75 100644 --- a/docs/checks/LintImplTrimIndent.md.html +++ b/docs/checks/LintImplTrimIndent.md.html @@ -56,12 +56,95 @@ src/test/pkg/MyKotlinLintDetector.kt:68:Error: No need to call .trimIndent() in issue registration strings; they are already trimmed by indent by lint when displaying to users [LintImplTrimIndent] - """.trimIndent(), ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/MyJavaLintDetector.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiCallExpression; +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.util.PsiTreeUtil; +import com.android.tools.lint.detector.api.Detector; +import org.jetbrains.uast.UFile; +import org.jetbrains.uast.UMethod; +import org.jetbrains.uast.UField; +import com.android.tools.lint.detector.api.Category; +import com.android.tools.lint.detector.api.Detector; +import com.android.tools.lint.detector.api.Implementation; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.JavaContext; +import com.android.tools.lint.detector.api.Scope; +import com.android.tools.lint.detector.api.Severity; +import org.jetbrains.uast.UCallExpression; +import java.util.EnumSet; + +@SuppressWarnings({"MethodMayBeStatic", "ClassNameDiffersFromFileName", "StatementWithEmptyBody", "deprecation"}) +public class MyJavaLintDetector extends Detector { + public static final Issue ISSUE = + Issue.create( + "com.android.namespaced.lint.check.FooDetector", + "Wrong use of ", + "As described in " + + "https://code.google.com/p/android/issues/detail?id=65351 blah blah blah.", + Category.A11Y, + 3, + Severity.WARNING, + new Implementation(MyJavaLintDetector.class, EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE))) + .addMoreInfo("file://explanation.doc") + .addMoreInfo("http://my.personal.blogger.com/aboutme.htm") + .addMoreInfo("mailto:lint@example.com"); + public void testGetBody(PsiMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetBody(UMethod method) { + method.getBody(); // ERROR - must use UAST + } + public void testGetContainingClass(UMethod method, UField field) { + method.getContainingClass(); // ERROR - must use UAST + field.getContainingClass(); // ERROR - must use UAST + } + public void testGetContainingClass(PsiMethod method, PsiField field) { + method.getContainingClass(); // OK - legitimate uses after resolve + field.getContainingClass(); // OK - legitimate uses after resolve + } + public void testEquals(PsiCallExpression element1, PsiExpression element2) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 != element2) { } + } + public void testGetInitializer(PsiField field) { + field.getInitializer(); // ERROR - must use UAST + } + public void testParents(PsiField field, UMethod method) { + PsiElement parent = field.getParent(); // OK + PsiElement parent = method.getParent(); // ERROR + PsiTreeUtil.getParentOfType(field, PsiClass.class); // OK + PsiTreeUtil.getParentOfType(method, PsiClass.class); // ERROR + } + + public void testReport(JavaContext context, UCallExpression node) { + context.report(ISSUE, node, context.getLocation(node), + "Wrong use of LinearLayout."); + context.report(ISSUE, node, context.getLocation(node), + "First problem. Second problem."); + context.report(ISSUE, node, context.getLocation(node), + "This is teh typo"); + String message = "Welcome to Andriod"; + context.report(ISSUE, node, context.getLocation(node), message); + context.report(ISSUE, node, context.getLocation(node), + "Should you use `x ?: y` instead of ```foo ? 1 : 0``` ?"); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/MyKotlinLintDetector.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -163,6 +246,101 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplUnexpectedDomain.md.html b/docs/checks/LintImplUnexpectedDomain.md.html index bda4d30..6192274 100644 --- a/docs/checks/LintImplUnexpectedDomain.md.html +++ b/docs/checks/LintImplUnexpectedDomain.md.html @@ -42,12 +42,11 @@ my.personal.blogger.com; for the builtin Android Lint checks make sure to use an authoritative link (http://my.personal.blogger.com/aboutme.htm) [LintImplUnexpectedDomain] - .addMoreInfo("http://my.personal.blogger.com/aboutme.htm") ------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyJavaLintDetector.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -133,6 +132,201 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplUseKotlin.md.html b/docs/checks/LintImplUseKotlin.md.html index 2815b61..781dcca 100644 --- a/docs/checks/LintImplUseKotlin.md.html +++ b/docs/checks/LintImplUseKotlin.md.html @@ -43,12 +43,11 @@ src/test/pkg/MyJavaLintDetector.java:24:Warning: New lint checks should be implemented in Kotlin to take advantage of a lot of Kotlin-specific mechanisms in the Lint API [LintImplUseKotlin] - public class MyJavaLintDetector extends Detector { ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyJavaLintDetector.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -134,6 +133,201 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LintImplUseUast.md.html b/docs/checks/LintImplUseUast.md.html index 33a7a35..5015db5 100644 --- a/docs/checks/LintImplUseUast.md.html +++ b/docs/checks/LintImplUseUast.md.html @@ -50,60 +50,41 @@ src/test/pkg/MyJavaLintDetector.java:39:Error: Don't call PsiMethod#getBody(); you must use UAST instead. If you don't have a UMethod call UastFacade.getMethodBody(method) [LintImplUseUast] - method.getBody(); // ERROR - must use UAST ---------------- - - src/test/pkg/MyJavaLintDetector.java:42:Error: Don't call PsiMethod#getBody(); you must use UAST instead. If you don't have a UMethod call UastFacade.getMethodBody(method) [LintImplUseUast] - method.getBody(); // ERROR - must use UAST ---------------- - - src/test/pkg/MyJavaLintDetector.java:45:Error: Don't call PsiMember#getContainingClass(); you should use UAST instead and call getContainingUClass() [LintImplUseUast] - method.getContainingClass(); // ERROR - must use UAST --------------------------- - - src/test/pkg/MyJavaLintDetector.java:46:Error: Don't call PsiMember#getContainingClass(); you should use UAST instead and call getContainingUClass() [LintImplUseUast] - field.getContainingClass(); // ERROR - must use UAST -------------------------- - - src/test/pkg/MyJavaLintDetector.java:59:Error: Don't call PsiField#getInitializer(); you must use UAST instead. If you don't have a UField call UastFacade.getInitializerBody(field) [LintImplUseUast] - field.getInitializer(); // ERROR - must use UAST ---------------------- - - src/test/pkg/MyJavaLintDetector.java:63:Error: Don't call PsiElement#getParent(); you should use UAST instead and call getUastParent() [LintImplUseUast] - PsiElement parent = method.getParent(); // ERROR ------------------ - - src/test/pkg/MyJavaLintDetector.java:65:Error: Don't call PsiTreeUtil#getParentOfType(); you should use UAST instead and call UElement.parentOfType [LintImplUseUast] - PsiTreeUtil.getParentOfType(method, PsiClass.class); // ERROR --------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/MyJavaLintDetector.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -189,6 +170,201 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyKotlinLintDetector.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +/* Copyright (C) 2020 The Android Open Source Project */ +package test.pkg +import com.intellij.psi.PsiCallExpression +import com.intellij.psi.PsiExpression +import com.intellij.psi.PsiField +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.android.tools.lint.detector.api.Category +import com.android.tools.lint.detector.api.Detector +import com.android.tools.lint.detector.api.Implementation +import com.android.tools.lint.detector.api.Issue +import com.android.tools.lint.detector.api.JavaContext +import com.android.tools.lint.detector.api.Scope +import com.android.tools.lint.detector.api.Severity +import org.jetbrains.uast.UCallExpression + +class MyKotlinLintDetector : Detector() { + fun testGetBody(method: PsiMethod) { + val body = method.body // ERROR - must use UAST + } + @Suppress("ReplaceCallWithBinaryOperator","ControlFlowWithEmptyBody") + fun testEquals(element1: PsiCallExpression, element2: PsiExpression) { + if (element1.equals(element2)) { } + if (element2.equals(element1)) { } + if (element1 == element2) { } + if (element1 === element2) { } + if (element1 != element2) { } + if (element1 !== element2) { } + if (element1 == null) { } // OK + if (element1 === null) { } // OK + if (element1 != null) { } // OK + if (element1 !== null) { } // OK + } + @Suppress("UsePropertyAccessSyntax") + fun testGetInitializer(field: PsiField) { + field.getInitializer() // ERROR - must use UAST + field.initializer // ERROR - must use UAST + } + fun testParents(field: PsiField) { + val parent = field.parent + val method = PsiTreeUtil.getParentOfType(field, PsiMethod::class.java) + } + + fun testReport(context: JavaContext, node: UCallExpression) { + context.report(ISSUE, node, context.getLocation(node), + """ + |Instead you should call foo().bar().baz() here. + |""".trimIndent()) + } + + companion object { + private val IMPLEMENTATION = + Implementation( + MyKotlinLintDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + + val ISSUE = + Issue.create( + id = "badlyCapitalized id", + briefDescription = "checks MyLintDetector.", + explanation = """ + Some description here. + Here's a call: foo.bar.baz(args). + This line continuation is okay. \ + But this one is missing a space.\ + Okay? + """.trimIndent(), + category = Category.INTEROPERABILITY_KOTLIN, + moreInfo = "https://code.google.com/p/android/issues/detail?id=65351", // OBSOLETE + priority = 4, + severity = Severity.WARNING, + implementation = IMPLEMENTATION + ) + .addMoreInfo("https://issuetracker.google.com/issues/3733548") // ERROR - missing digit + .addMoreInfo("https://issuetracker.google.com/issues/373354878") // OK - including digit + .addMoreInfo("http://issuetracker.google.com/issues/37335487") // ERROR - http instead of https + .addMoreInfo("https://b.corp.google.com/issues/139153781") // ERROR - don't point to buganizer with internal link + .addMoreInfo("https://goo.gle/policy-storage-help") // OK - regression test for goo.gle + } + + override fun visitAnnotationUsage( + context: JavaContext, + element: org.jetbrains.uast.UElement.UElement, + annotationInfo: com.android.tools.lint.detector.api.AnnotationInfo, + usageInfo: com.android.tools.lint.detector.api.AnnotationUsageInfo + ) { + // Invalid recursion! + super.visitAnnotationUsage(context, element, annotationInfo, usageInfo) + } + + fun misc() { + System.out.print("Debugging") + println("Debugging code") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +class MyIssueRegistry : IssueRegistry() { + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyVendorIssueRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class MyVendorIssueRegistry : IssueRegistry() { + // Supplies a vendor: no warning + override var vendor: Vendor? = Vendor("Unit test") + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/InheritingRegistry.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +import com.android.tools.lint.client.api.IssueRegistry +import com.android.tools.lint.client.api.Vendor +class InheritingRegistry : MyVendorIssueRegistry() { // NO WARNING + // This registry doesn't supply a vendor but inherits one; no warning + override val issues = listOf( + MyJavaLintDetector.ISSUE, + MyKotlinLintDetector.Companion.ISSUE + ) +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyKotlinLintDetectorTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +// Copyright (C) 2021 The Android Open Source Project +package test.pkg +import com.android.tools.lint.checks.infrastructure.LintDetectorTest +import com.android.tools.lint.detector.api.Detector +class MyKotlinLintDetectorTest : LintDetectorTest() { + override fun getDetector(): Detector { + return MyKotlinLintDetector() + } + + fun testBasic() { + val expected = """ + src/test/pkg/AlarmTest.java:9: Warning: Value will be forced up to 5000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + ~~ + 0 errors, 1 warnings + """ + + lint().files( + kotlin( + """ + fun test() { + println("Value=${"$"}") + } + """ + ), + java( + "src/test/pkg/AlarmTest.java", + """ + package test.pkg; + + import android.app.AlarmManager; + @SuppressWarnings("ClassNameDiffersFromFileName") + public class AlarmTest { + public void test(AlarmManager alarmManager) { + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR + alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR + OtherClass.MY_INTERVAL, null); // ERROR + } + + private static class OtherClass { + public static final long MY_INTERVAL = 1000L; + } + } + """.trimIndent() + ) + ).run().expect(expected) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/LintDetectorDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LocalSuppress.md.html b/docs/checks/LocalSuppress.md.html index 707d383..13929dc 100644 --- a/docs/checks/LocalSuppress.md.html +++ b/docs/checks/LocalSuppress.md.html @@ -45,47 +45,31 @@ src/test/pkg/WrongAnnotation.java:10:Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress] - public static void foobar(View view, @SuppressLint("NewApi") int foo) { // $ Invalid: class-file check ----------------------- - - src/test/pkg/WrongAnnotation.java:11:Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress] - @SuppressLint("NewApi") // Invalid ----------------------- - - src/test/pkg/WrongAnnotation.java:13:Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress] - @SuppressLint({"SdCardPath", "NewApi"}) // Invalid: class-file based check on local variable --------------------------------------- - - src/test/pkg/WrongAnnotation.java:15:Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress] - @android.annotation.SuppressLint({"SdCardPath", "NewApi"}) // Invalid (FQN) ---------------------------------------------------------- - - src/test/pkg/WrongAnnotation.java:29:Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress] - @SuppressLint("NewApi") ----------------------- - - src/test/pkg/WrongAnnotation.java:34:Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress] - @SuppressLint("NewApi") // Invalid ----------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LocaleFolder.md.html b/docs/checks/LocaleFolder.md.html index 84c686b..eb9bcfd 100644 --- a/docs/checks/LocaleFolder.md.html +++ b/docs/checks/LocaleFolder.md.html @@ -54,11 +54,36 @@ [LocaleFolder] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-no/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values-he/strings.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers -<resources>null</resources> +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-id/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-yi/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> +</resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the diff --git a/docs/checks/LockedOrientationActivity.md.html b/docs/checks/LockedOrientationActivity.md.html index 5294e25..1f31625 100644 --- a/docs/checks/LockedOrientationActivity.md.html +++ b/docs/checks/LockedOrientationActivity.md.html @@ -35,7 +35,7 @@ users can take advantage of the multi-window environments and larger screens available on Android. To fix the issue, consider declaring the corresponding activity element with `screenOrientation="unspecified"`or -`"fullSensor"` attribute. +`fullSensor` attribute. !!! Tip This lint check has an associated quickfix available in the IDE. @@ -49,7 +49,6 @@ activity so the user can use the application in any orientation and provide a great experience on Chrome OS devices [LockedOrientationActivity] - <activity android:name=".MainActivity" android:screenOrientation="portrait"/> ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LogConditional.md.html b/docs/checks/LogConditional.md.html index 8bcbb8a..c0c0ab3 100644 --- a/docs/checks/LogConditional.md.html +++ b/docs/checks/LogConditional.md.html @@ -49,7 +49,6 @@ src/LogExample.kt:7:Warning: The log call Log.i(...) should be conditional: surround with if (Log.isLoggable(...)) or if (BuildConfig.DEBUG) { ... } [LogConditional] - Log.i(TAG, "message" + m) // string is not constant; computed each time ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LogNotTimber.md.html b/docs/checks/LogNotTimber.md.html index edd4865..1c4b7ad 100644 --- a/docs/checks/LogNotTimber.md.html +++ b/docs/checks/LogNotTimber.md.html @@ -45,12 +45,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/Example.java:5:Warning: Using 'Log' instead of 'Timber' [LogNotTimber] - Log.d("TAG", "msg"); ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/foo/Example.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -63,6 +62,17 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/foo/Example.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import android.util.Log +class Example { + fun log() { + Log.d("TAG", "msg") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://github.com/JakeWharton/timber/tree/trunk/timber-lint/src/test/java/timber/lint/WrongTimberUsageDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/LogTagMismatch.md.html b/docs/checks/LogTagMismatch.md.html index 0a663a4..b3cc678 100644 --- a/docs/checks/LogTagMismatch.md.html +++ b/docs/checks/LogTagMismatch.md.html @@ -42,7 +42,6 @@ src/LogExample.kt:9:Error: Mismatched tags: the d() and isLoggable() calls typically should pass the same tag: TAG1 versus TAG2 [LogTagMismatch] - Log.d(TAG2, "message") // warn: mismatched tags - TAG1 and TAG2 ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/LongLogTag.md.html b/docs/checks/LongLogTag.md.html index 48c0fd7..8fc17d1 100644 --- a/docs/checks/LongLogTag.md.html +++ b/docs/checks/LongLogTag.md.html @@ -38,7 +38,6 @@ src/pkg1/pkg2/pkg3/pkg4/pkg5/LogExampleInLongClassName.kt:9:Error: The logging tag can be at most 23 characters, was 35 (SuperSuperLongLogTagWhichExceedsMax) [LongLogTag] - Log.d(TAG, "message") --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MainScopeUsage.md.html b/docs/checks/MainScopeUsage.md.html index 4c21e98..95cba58 100644 --- a/docs/checks/MainScopeUsage.md.html +++ b/docs/checks/MainScopeUsage.md.html @@ -1,13 +1,13 @@ -(#) Use slack.foundation.coroutines.android.MainScope. +(#) Use slack.foundation.coroutines.android.MainScope -!!! ERROR: Use slack.foundation.coroutines.android.MainScope. +!!! ERROR: Use slack.foundation.coroutines.android.MainScope This is an error. Id : `MainScopeUsage` Summary -: Use slack.foundation.coroutines.android.MainScope. +: Use slack.foundation.coroutines.android.MainScope Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MainScopeUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MainScopeUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MainScopeUsageDetectorTest.kt) Copyright Year @@ -52,7 +52,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/test.kt:6:Error: Use slack.foundation.coroutines.android.MainScope. [MainScopeUsage] - val scope = MainScope() ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MangledCRLF.md.html b/docs/checks/MangledCRLF.md.html index 6315dec..33c0dd7 100644 --- a/docs/checks/MangledCRLF.md.html +++ b/docs/checks/MangledCRLF.md.html @@ -47,7 +47,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/crcrlf.xml:4:Error: Incorrect line ending: found carriage return (\r) without corresponding newline (\n) [MangledCRLF] - android:layout_height="match_parent" > ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ManifestOrder.md.html b/docs/checks/ManifestOrder.md.html index ac09e67..e8fdd83 100644 --- a/docs/checks/ManifestOrder.md.html +++ b/docs/checks/ManifestOrder.md.html @@ -42,12 +42,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:15:Warning: tag appears after tag [ManifestOrder] - <uses-sdk android:minSdkVersion="Froyo" /> -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -70,6 +69,40 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ManifestResource.md.html b/docs/checks/ManifestResource.md.html index 2a7bc20..8dbc14a 100644 --- a/docs/checks/ManifestResource.md.html +++ b/docs/checks/ManifestResource.md.html @@ -43,28 +43,21 @@ AndroidManifest.xml:6:Error: Resources referenced from the manifest cannot vary by configuration (except for version qualifiers, e.g. -v21). Found variation in mcc [ManifestResource] - <application android:fullBackupContent="@xml/backup"> ----------- - - AndroidManifest.xml:8:Error: Resources referenced from the manifest cannot vary by configuration (except for version qualifiers, e.g. -v21). Found variation in en-rUS [ManifestResource] - android:process="@string/location_process" ------------------------ - - AndroidManifest.xml:9:Error: Resources referenced from the manifest cannot vary by configuration (except for version qualifiers, e.g. -v21). Found variation in watch-v20 [ManifestResource] - android:enabled="@bool/enable_wearable_location_service"> -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -82,6 +75,50 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/values.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="location_process">Location Process</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/bools.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <bool name="enable_wearable_location_service">true</bool> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-en-rUS/values.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="location_process">Location Process (English)</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-watch/bools.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <bool name="enable_wearable_location_service">false</bool> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/xml/backup.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<full-backup-content> + <include domain="file" path="dd"/> + <exclude domain="file" path="dd/fo3o.txt"/> + <exclude domain="file" path="dd/ss/foo.txt"/> +</full-backup-content> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/xml-mcc/backup.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<full-backup-content> + <include domain="file" path="mcc"/> +</full-backup-content> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestResourceDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ManifestTypo.md.html b/docs/checks/ManifestTypo.md.html index 22a02da..d981181 100644 --- a/docs/checks/ManifestTypo.md.html +++ b/docs/checks/ManifestTypo.md.html @@ -40,12 +40,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:7:Error: Misspelled tag : Did you mean ? [ManifestTypo] - <use-sdk android:minSdkVersion="14" /> -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -79,6 +78,41 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestTypoDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MatchingMenuId.md.html b/docs/checks/MatchingMenuId.md.html index 4c12d1c..bf70165 100644 --- a/docs/checks/MatchingMenuId.md.html +++ b/docs/checks/MatchingMenuId.md.html @@ -1,13 +1,13 @@ -(#) Flags menu ids that don't match with the file name. +(#) Flags menu ids that don't match with the file name -!!! WARNING: Flags menu ids that don't match with the file name. +!!! WARNING: Flags menu ids that don't match with the file name This is a warning. Id : `MatchingMenuId` Summary -: Flags menu ids that don't match with the file name. +: Flags menu ids that don't match with the file name Severity : Warning Category @@ -29,11 +29,46 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/MatchingMenuIdDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MatchingMenuIdDetectorTest.kt) When the layout file is named menu_home all of the containing ids should be prefixed with menuHome to avoid ambiguity between different menu files across different menu items. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/menu/menu_main.xml:2:Warning: Id should start with: menuMain +[MatchingMenuId] + <item android:id="@+id/something"/> + -------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/menu/menu_main.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/something"/> +</menu> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MatchingMenuIdDetectorTest.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, `MatchingMenuIdDetector.idWithoutPrefix`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/MatchingViewId.md.html b/docs/checks/MatchingViewId.md.html index a82ad18..3c7106b 100644 --- a/docs/checks/MatchingViewId.md.html +++ b/docs/checks/MatchingViewId.md.html @@ -1,13 +1,13 @@ -(#) Flags view ids that don't match with the file name. +(#) Flags view ids that don't match with the file name -!!! WARNING: Flags view ids that don't match with the file name. +!!! WARNING: Flags view ids that don't match with the file name This is a warning. Id : `MatchingViewId` Summary -: Flags view ids that don't match with the file name. +: Flags view ids that don't match with the file name Severity : Warning Category @@ -29,11 +29,44 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/MatchingViewIdDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MatchingViewIdDetectorTest.kt) When the layout file is named activity_home all of the containing ids should be prefixed with activityHome to avoid ambiguity between different layout files across different views. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/activity_main.xml:1:Warning: Id should start with: +activityMain [MatchingViewId] +<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"/> + --------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/activity_main.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MatchingViewIdDetectorTest.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, `MatchingViewIdDetector.idWithoutPrefix`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/MenuTitle.md.html b/docs/checks/MenuTitle.md.html index cf944b2..8fb2f65 100644 --- a/docs/checks/MenuTitle.md.html +++ b/docs/checks/MenuTitle.md.html @@ -54,14 +54,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/menu/titles.xml:3:Error: Menu items should specify a title [MenuTitle] - <item android:id="@+id/action_bar_progress_spinner" ---- - - res/menu/titles.xml:12:Error: Menu items should specify a title [MenuTitle] - <item android:id="@+id/menu_plus_one" ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MergeMarker.md.html b/docs/checks/MergeMarker.md.html index 8717aa3..7ff7b09 100644 --- a/docs/checks/MergeMarker.md.html +++ b/docs/checks/MergeMarker.md.html @@ -37,19 +37,12 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/strings.xml:5:Error: Missing merge marker? [MergeMarker] - <<<<<<< HEAD ------- - - res/values/strings.xml:7:Error: Missing merge marker? [MergeMarker] - ======= ------- - - res/values/strings.xml:9:Error: Missing merge marker? [MergeMarker] - >>>>>>> branch-a ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MergeRootFrame.md.html b/docs/checks/MergeRootFrame.md.html index 50904f3..9995afc 100644 --- a/docs/checks/MergeRootFrame.md.html +++ b/docs/checks/MergeRootFrame.md.html @@ -42,12 +42,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/simple.xml:1:Warning: This can be replaced with a tag [MergeRootFrame] - <FrameLayout ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/simple.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -57,6 +56,22 @@ android:layout_height="match_parent" /> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/ImportFrameActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; +import android.os.Bundle; + +public class ImportFrameActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.simple); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/MergeRootFrameLayoutDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MinSdkTooLow.md.html b/docs/checks/MinSdkTooLow.md.html index 69da5f5..e152597 100644 --- a/docs/checks/MinSdkTooLow.md.html +++ b/docs/checks/MinSdkTooLow.md.html @@ -45,15 +45,11 @@ build.gradle:8:Warning: The value of minSdkVersion is too low. It can be incremented without noticeably reducing the number of supported devices. [MinSdkTooLow] - minSdkVersion 7 --------------- - - build.gradle:9:Warning: The value of minSdkVersion is too low. It can be incremented without noticeably reducing the number of supported devices. [MinSdkTooLow] - minSdk 7 -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MipmapIcons.md.html b/docs/checks/MipmapIcons.md.html index c836b51..248092f 100644 --- a/docs/checks/MipmapIcons.md.html +++ b/docs/checks/MipmapIcons.md.html @@ -55,19 +55,15 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/main/AndroidManifest.xml:8:Warning: Should use @mipmap instead of @drawable for launcher icons [MipmapIcons] - android:icon="@drawable/ic_launcher" ------------------------------------ - - src/main/AndroidManifest.xml:13:Warning: Should use @mipmap instead of @drawable for launcher icons [MipmapIcons] - android:icon="@drawable/activity1" ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/main/AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -107,6 +103,26 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +android { + defaultConfig { + resConfigs "cs" + } + flavorDimensions "pricing", "releaseType" + productFlavors { + beta { + dimension "releaseType" + resConfig "en", "de" + resConfigs "nodpi", "hdpi" + } + normal { dimension "releaseType" } + free { dimension "pricing" } + paid { dimension "pricing" } + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingApplicationIcon.md.html b/docs/checks/MissingApplicationIcon.md.html index 4a57da5..aa303c8 100644 --- a/docs/checks/MissingApplicationIcon.md.html +++ b/docs/checks/MissingApplicationIcon.md.html @@ -44,12 +44,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:8:Warning: Should explicitly set android:icon, there is no default [MissingApplicationIcon] - <application ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -76,6 +75,40 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingAutoVerifyAttribute.md.html b/docs/checks/MissingAutoVerifyAttribute.md.html new file mode 100644 index 0000000..5f158db --- /dev/null +++ b/docs/checks/MissingAutoVerifyAttribute.md.html @@ -0,0 +1,152 @@ + +(#) Application has custom scheme intent filters with missing `autoVerify` attributes + +!!! WARNING: Application has custom scheme intent filters with missing `autoVerify` attributes + This is a warning. + +Id +: `MissingAutoVerifyAttribute` +Summary +: Application has custom scheme intent filters with missing `autoVerify` attributes +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/MissingAutoVerifyAttribute +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/CustomSchemeDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/CustomSchemeDetectorTest.kt) +Copyright Year +: 2024 + +Intent filters should contain the `autoVerify` attribute and explicitly +set it to true, in order to signal to the system to automatically verify +the associated hosts in your app's intent filters. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:5:Warning: Custom scheme intent filters should +explicitly set the autoVerify attribute to true +[MissingAutoVerifyAttribute] + <intent-filter android:autoVerify='false'> + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<application android:debuggable='false'> +<meta-data android:name='android.webkit.WebView.EnableSafeBrowsing'/> + <activity android:name='com.example.MainActivity'> + <intent-filter android:autoVerify='false'> + <action android:name='android.intent.action.VIEW' /> + <data android:scheme='telegram://' /> + </intent-filter> + </activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/CustomSchemeDetectorTest.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, `CustomSchemeDetector.testWhenFalseAutoVerifyAttributeSpecifiedOnCustomSchemeIntentFilter_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="MissingAutoVerifyAttribute"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <intent-filter tools:ignore="MissingAutoVerifyAttribute" .../> + ... + </manifest> + ``` + +* 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="MissingAutoVerifyAttribute" 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 'MissingAutoVerifyAttribute' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore MissingAutoVerifyAttribute ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/MissingBackupPin.md.html b/docs/checks/MissingBackupPin.md.html index 96a453b..23e6a76 100644 --- a/docs/checks/MissingBackupPin.md.html +++ b/docs/checks/MissingBackupPin.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/network_config.xml:5:Warning: A backup declaration is highly recommended [MissingBackupPin] - <pin-set> ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingClass.md.html b/docs/checks/MissingClass.md.html index f475d1a..f840334 100644 --- a/docs/checks/MissingClass.md.html +++ b/docs/checks/MissingClass.md.html @@ -46,12 +46,11 @@ res/layout/customview.xml:5:Error: Class referenced in the layout file, foo.bar.Baz, was not found in the project or the libraries [MissingClass] - <foo.bar.Baz /> --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/customview.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -65,6 +64,18 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MyView.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +abstract class MyView : androic.view.View(null) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/NotView.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg +abstract class NotView : android.app.Fragment() +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/MissingClassDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingColorAlphaChannel.md.html b/docs/checks/MissingColorAlphaChannel.md.html index 665ad89..7e67499 100644 --- a/docs/checks/MissingColorAlphaChannel.md.html +++ b/docs/checks/MissingColorAlphaChannel.md.html @@ -50,35 +50,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:6:Warning: Missing Color alpha channel [MissingColorAlphaChannel] - val color = Color(0x000000) -------- - - src/test/test.kt:8:Warning: Missing Color alpha channel [MissingColorAlphaChannel] - val color2 = Color(0xEEEEEE) -------- - - src/test/test.kt:10:Warning: Missing Color alpha channel [MissingColorAlphaChannel] - val color3 = Color(0xeeeeee) -------- - - src/test/test.kt:12:Warning: Missing Color alpha channel [MissingColorAlphaChannel] - val color3 = Color(0xeEeeEE) -------- - - src/test/test.kt:14:Warning: Missing Color alpha channel [MissingColorAlphaChannel] - val color4 = Color(0x00_00_00L) ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -119,17 +106,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-graphics-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-graphics-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-graphics-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-graphics-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-graphics-android) # libs.versions.toml [versions] -ui-graphics-android = "1.7.0-beta04" +ui-graphics-android = "1.7.0-beta05" [libraries] ui-graphics-android = { module = "androidx.compose.ui:ui-graphics-android", @@ -137,7 +124,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-graphics-android](androidx_compose_ui_ui-graphics-android.md.html). diff --git a/docs/checks/MissingConstraints.md.html b/docs/checks/MissingConstraints.md.html index fbd2925..eaeb1ff 100644 --- a/docs/checks/MissingConstraints.md.html +++ b/docs/checks/MissingConstraints.md.html @@ -44,31 +44,21 @@ res/layout/layout1.xml:11:Error: This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints [MissingConstraints] - <TextView -------- - - res/layout/layout1.xml:16:Error: This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints [MissingConstraints] - <TextView -------- - - res/layout/layout1.xml:38:Error: This view is not constrained vertically: at runtime it will jump to the top unless you add a vertical constraint [MissingConstraints] - <TextView -------- - - res/layout/layout1.xml:47:Error: This view is not constrained horizontally: at runtime it will jump to the left unless you add a horizontal constraint [MissingConstraints] - <TextView -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingDefaultResource.md.html b/docs/checks/MissingDefaultResource.md.html index 7d8673f..ad3e1f2 100644 --- a/docs/checks/MissingDefaultResource.md.html +++ b/docs/checks/MissingDefaultResource.md.html @@ -68,12 +68,19 @@ values-land has no declaration in the base values folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier [MissingDefaultResource] - <dimen name="extra_dimen1">1pt</dimen> <!-- error --> ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/dimen.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <dimen name="ok_dimen">base</dimen> <!-- ok --> + <style name="ok_style"></style> <!-- ok --> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values-land/dimen.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -85,6 +92,45 @@ </resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-v21/dimen.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <!-- We allow common scenario of having dedicated + resources for API levels, often used for theming --> + <dimen name="ok_extra_dimen">1pt</dimen> <!-- ok --> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-land-v21/dimen.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <dimen name="ok_extra_dimen">2pt</dimen> <!-- ok --> + <dimen name="extra_dimen2">1pt</dimen> <!-- error --> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/drawable-mdpi/ok_drawable.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <drawable name="color_drawable">#ffffffff</drawable> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/color/ok_color.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<color xmlns:android="http://schemas.android.com/apk/res/android" android:color="#ff0000" /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/color-port/extra_color.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<color xmlns:android="http://schemas.android.com/apk/res/android" android:color="#ff0000" /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout-land/extra_layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<merge/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/TranslationDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingFirebaseInstanceTokenRefresh.md.html b/docs/checks/MissingFirebaseInstanceTokenRefresh.md.html index d12836c..05d5e91 100644 --- a/docs/checks/MissingFirebaseInstanceTokenRefresh.md.html +++ b/docs/checks/MissingFirebaseInstanceTokenRefresh.md.html @@ -42,7 +42,6 @@ src/com/google/firebase/samples/messaging/advanced/services/MessagingService.java:5:Warning: Apps that use Firebase Cloud Messaging should implement onNewToken() in order to observe token changes [MissingFirebaseInstanceTokenRefresh] - public class MessagingService extends FirebaseMessagingService { ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingId.md.html b/docs/checks/MissingId.md.html index 02c3503..e4f0359 100644 --- a/docs/checks/MissingId.md.html +++ b/docs/checks/MissingId.md.html @@ -55,7 +55,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/fragment.xml:7:Warning: This tag should specify an id or a tag to preserve state across activity restarts [MissingId] - <fragment -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingInflatedId.md.html b/docs/checks/MissingInflatedId.md.html index 76ccadb..ac2d80e 100644 --- a/docs/checks/MissingInflatedId.md.html +++ b/docs/checks/MissingInflatedId.md.html @@ -39,14 +39,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/MyActivity.kt:15:Error: @layout/activity_main does not contain a declaration with id text_field [MissingInflatedId] - requireViewById<EditText>(R.id.text_field).isEnabled = false --------------- - - src/test/pkg/MyActivity.kt:21:Error: @layout/list_item does not contain a declaration with id image_view [MissingInflatedId] - val imgView = rootView.findViewById<ImageView>(R.id.image_view) --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -95,7 +91,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `test.pkg`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers @id/text_field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingIntentFilterForMediaSearch.md.html b/docs/checks/MissingIntentFilterForMediaSearch.md.html index 365a225..81b6eba 100644 --- a/docs/checks/MissingIntentFilterForMediaSearch.md.html +++ b/docs/checks/MissingIntentFilterForMediaSearch.md.html @@ -50,12 +50,11 @@ AndroidManifest.xml:6:Error: Missing intent-filter for action android.media.action.MEDIA_PLAY_FROM_SEARCH. [MissingIntentFilterForMediaSearch] - <application ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -87,6 +86,14 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/xml/automotive_app_desc.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<automotiveApp> + <uses name="media"/> +</automotiveApp> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/AndroidAutoDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingLeanbackLauncher.md.html b/docs/checks/MissingLeanbackLauncher.md.html index 497da1a..a031061 100644 --- a/docs/checks/MissingLeanbackLauncher.md.html +++ b/docs/checks/MissingLeanbackLauncher.md.html @@ -42,7 +42,6 @@ AndroidManifest.xml:2:Error: Expecting an activity to have android.intent.category.LEANBACK_LAUNCHER intent filter [MissingLeanbackLauncher] - <manifest xmlns:android="http://schemas.android.com/apk/res/android" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingLeanbackSupport.md.html b/docs/checks/MissingLeanbackSupport.md.html index f25e9e5..5fa3b0d 100644 --- a/docs/checks/MissingLeanbackSupport.md.html +++ b/docs/checks/MissingLeanbackSupport.md.html @@ -51,7 +51,6 @@ AndroidManifest.xml:2:Error: Expecting tag [MissingLeanbackSupport] - <manifest xmlns:android="http://schemas.android.com/apk/res/android" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingMediaBrowserServiceIntentFilter.md.html b/docs/checks/MissingMediaBrowserServiceIntentFilter.md.html index 007ed4d..9578cb1 100644 --- a/docs/checks/MissingMediaBrowserServiceIntentFilter.md.html +++ b/docs/checks/MissingMediaBrowserServiceIntentFilter.md.html @@ -51,12 +51,11 @@ AndroidManifest.xml:6:Error: Missing intent-filter for action android.media.browse.MediaBrowserService that is required for android auto support [MissingMediaBrowserServiceIntentFilter] - <application ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -85,6 +84,14 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/xml/automotive_app_desc.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<automotiveApp> + <uses name="media"/> +</automotiveApp> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/AndroidAutoDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingOnPlayFromSearch.md.html b/docs/checks/MissingOnPlayFromSearch.md.html index 8446bb4..7edbce6 100644 --- a/docs/checks/MissingOnPlayFromSearch.md.html +++ b/docs/checks/MissingOnPlayFromSearch.md.html @@ -43,12 +43,53 @@ does not override onPlayFromSearch from MediaSession.Callback The method should be overridden and implemented to support Voice search on Android Auto. [MissingOnPlayFromSearch] - public class MSessionCallback extends Callback { ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.example.android.uamp"> + + <application + android:name=".UAMPApplication" + android:label="@string/app_name" + android:theme="@style/UAmpAppTheme"> + + <meta-data + android:name="com.google.android.gms.car.application" + android:resource="@xml/automotive_app_desc"/> + + <service + android:name=".MusicService" + android:exported="true" + tools:ignore="ExportedService"> + <intent-filter> + <action android:name="android.media.browse.MediaBrowserService"/> + </intent-filter> + <intent-filter> + <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH"/> + <category android:name="android.intent.category.DEFAULT"/> + </intent-filter> + </service> + + </application> + +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/xml/automotive_app_desc.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<automotiveApp> + <uses name="media"/> +</automotiveApp> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/com/example/android/uamp/MSessionCallback.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -77,6 +118,22 @@ You can suppress false positives using one of the following mechanisms: +* Adding the suppression attribute + `tools:ignore="MissingOnPlayFromSearch"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <automotiveApp tools:ignore="MissingOnPlayFromSearch" .../> + ... + </manifest> + ``` + * Using a suppression annotation like this on the enclosing element: @@ -105,22 +162,6 @@ problematicStatement() ``` -* Adding the suppression attribute - `tools:ignore="MissingOnPlayFromSearch"` 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 - <?xml version="1.0" encoding="UTF-8"?> - <manifest xmlns:tools="http://schemas.android.com/tools"> - ... - <automotiveApp tools:ignore="MissingOnPlayFromSearch" .../> - ... - </manifest> - ``` - * 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: diff --git a/docs/checks/MissingPermission.md.html b/docs/checks/MissingPermission.md.html index cc6bb3e..ac90a2e 100644 --- a/docs/checks/MissingPermission.md.html +++ b/docs/checks/MissingPermission.md.html @@ -48,7 +48,6 @@ src/test/pkg/PermissionTest.java:7:Error: Missing permissions required by LocationManager.myMethod: android.permission.ACCESS_FINE_LOCATION or android.permission.ACCESS_COARSE_LOCATION [MissingPermission] - LocationManager.Location location = locationManager.myMethod(provider); ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingPrefix.md.html b/docs/checks/MissingPrefix.md.html index a5bd28f..9071029 100644 --- a/docs/checks/MissingPrefix.md.html +++ b/docs/checks/MissingPrefix.md.html @@ -46,14 +46,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/namespace.xml:2:Error: Attribute is missing the Android namespace prefix [MissingPrefix] - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:other="http://foo.bar" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" orientation="true"> ------------------ - - res/layout/namespace.xml:3:Error: Attribute is missing the Android namespace prefix [MissingPrefix] - <Button style="@style/setupWizardOuterFrame" android.text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingQuantity.md.html b/docs/checks/MissingQuantity.md.html index 16dab08..af965a8 100644 --- a/docs/checks/MissingQuantity.md.html +++ b/docs/checks/MissingQuantity.md.html @@ -52,12 +52,34 @@ res/values-pl/plurals2.xml:3:Error: For locale "pl" (Polish) the following quantity should also be defined: many (e.g. "5 miesięcy") [MissingQuantity] - <plurals name="numberOfSongsAvailable"> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`res/values/plurals.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <plurals name="my_plural"> + <item quantity="one">@string/hello</item> + <item quantity="few">@string/hello</item> + <item quantity="other">@string/hello</item> + </plurals> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/plurals2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <plurals name="numberOfSongsAvailable"> + <item quantity="one">One song found.</item> + <item quantity="other">%d songs found.</item> + </plurals> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/values-pl/plurals2.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers diff --git a/docs/checks/MissingResourceImportAlias.md.html b/docs/checks/MissingResourceImportAlias.md.html index b618634..62ffa0c 100644 --- a/docs/checks/MissingResourceImportAlias.md.html +++ b/docs/checks/MissingResourceImportAlias.md.html @@ -1,13 +1,13 @@ -(#) Missing import alias for R class. +(#) Missing import alias for R class -!!! ERROR: Missing import alias for R class. +!!! ERROR: Missing import alias for R class This is an error. Id : `MissingResourceImportAlias` Summary -: Missing import alias for R class. +: Missing import alias for R class Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/resources/MissingResourceImportAliasDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/resources/MissingResourceImportAliasDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/resources/MissingResourceImportAliasDetectorTest.kt) Copyright Year @@ -73,7 +73,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/lint/test/pkg/MyClass.kt:3:Error: Use an import alias for R classes from other modules [MissingResourceImportAlias] - import slack.l10n.R ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingScrollbars.md.html b/docs/checks/MissingScrollbars.md.html index a67a8d5..663a114 100644 --- a/docs/checks/MissingScrollbars.md.html +++ b/docs/checks/MissingScrollbars.md.html @@ -1,13 +1,13 @@ -(#) Scroll views should declare a scrollbar. +(#) Scroll views should declare a scrollbar -!!! WARNING: Scroll views should declare a scrollbar. +!!! WARNING: Scroll views should declare a scrollbar This is a warning. Id : `MissingScrollbars` Summary -: Scroll views should declare a scrollbar. +: Scroll views should declare a scrollbar Severity : Warning Category @@ -29,10 +29,47 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/MissingScrollbarsDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MissingScrollbarsDetectorTest.kt) Every scroll view should explicitly define whether it has scrollbars (none | vertical | horizontal). +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:1:Warning: Missing scrollbars on ScrollView +[MissingScrollbars] +<ScrollView +^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<ScrollView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MissingScrollbarsDetectorTest.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, `MissingScrollbarsDetector.scrollView`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/MissingSuperCall.md.html b/docs/checks/MissingSuperCall.md.html index e510ab1..8417945 100644 --- a/docs/checks/MissingSuperCall.md.html +++ b/docs/checks/MissingSuperCall.md.html @@ -41,7 +41,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/ParentClass.kt:11:Error: Overriding method should call super.someMethod [MissingSuperCall] - override fun someMethod(arg: Int) { ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingTranslation.md.html b/docs/checks/MissingTranslation.md.html index 5782fab..dba02c7 100644 --- a/docs/checks/MissingTranslation.md.html +++ b/docs/checks/MissingTranslation.md.html @@ -54,27 +54,20 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/strings.xml:20:Error: "show_all_apps" is not translated in "nl" (Dutch) [MissingTranslation] - <string name="show_all_apps">All</string> -------------------- - - res/values/strings.xml:23:Error: "menu_wallpaper" is not translated in "nl" (Dutch) [MissingTranslation] - <string name="menu_wallpaper">Wallpaper</string> --------------------- - - res/values/strings.xml:25:Error: "menu_settings" is not translated in "cs" (Czech), "de" (German), "es" (Spanish), "nl" (Dutch) [MissingTranslation] - <string name="menu_settings">Settings</string> -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/values/strings.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -111,6 +104,146 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values-cs/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Domů"</string> + <string name="show_all_apps">"Vše"</string> + <string name="menu_wallpaper">"Tapeta"</string> + <string name="menu_search">"Hledat"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Klepnutím na obrázek nastavíte tapetu portrétu"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-de-rDE/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Startseite"</string> + <string name="show_all_apps">"Alle"</string> + <string name="menu_wallpaper">"Bildschirmhintergrund"</string> + <string name="menu_search">"Suchen"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Tippen Sie auf Bild, um Porträt-Bildschirmhintergrund einzustellen"</string> + <string name="continue_skip_label">"Weiter"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-es/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Casa"</string> + <string name="show_all_apps">"Todo"</string> + <string name="menu_wallpaper">"Papel tapiz"</string> + <string name="menu_search">"Búsqueda"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string> + + <string-array name="security_questions"> + <item>"Comida favorita"</item> + <item>"Ciudad de nacimiento"</item> + <item>"Nombre de tu mejor amigo/a de la infancia"</item> + <item>"Nombre de tu colegio"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-es-rUS/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="menu_search">"Búsqueda"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-land/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap image to set landscape wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-cs/arrays.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string-array name="security_questions"> + <item>"Oblíbené jídlo?"</item> + <item>"Město narození."</item> + <item>"Jméno nejlepšího kamaráda z dětství?"</item> + <item>"Název střední školy"</item> + </string-array> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-es/donottranslate.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="full_wday_month_day_no_year">EEEE, d MMMM</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values-nl-rNL/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="home_title">"Start"</string> + <!-- Commented out in the unit test to generate extra warnings: + <string name="show_all_apps">"Alles"</string> + <string name="menu_wallpaper">"Achtergrond"</string> + --> + <string name="menu_search">"Zoeken"</string> + <!-- no translation found for menu_settings (1769059051084007158) --> + <skip /> + <string name="wallpaper_instructions">"Tik op afbeelding om portretachtergrond in te stellen"</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/public.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources><public /></resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/foo.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout-ja/foo.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/TranslationDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MissingTvBanner.md.html b/docs/checks/MissingTvBanner.md.html index 2cfa476..ca713cb 100644 --- a/docs/checks/MissingTvBanner.md.html +++ b/docs/checks/MissingTvBanner.md.html @@ -45,7 +45,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:5:Error: Expecting android:banner with the tag or each Leanback launcher activity [MissingTvBanner] - <application> ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingVersion.md.html b/docs/checks/MissingVersion.md.html index 462e690..7b5830d 100644 --- a/docs/checks/MissingVersion.md.html +++ b/docs/checks/MissingVersion.md.html @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:1:Warning: Should set android:versionName to specify the application version [MissingVersion] - <manifest xmlns:android="http://schemas.android.com/apk/res/android" -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MissingXmlHeader.md.html b/docs/checks/MissingXmlHeader.md.html index e4751d3..a02ac6f 100644 --- a/docs/checks/MissingXmlHeader.md.html +++ b/docs/checks/MissingXmlHeader.md.html @@ -1,13 +1,13 @@ -(#) Flags xml files that don't have a header. +(#) Flags xml files that don't have a header -!!! WARNING: Flags xml files that don't have a header. +!!! WARNING: Flags xml files that don't have a header This is a warning. Id : `MissingXmlHeader` Summary -: Flags xml files that don't have a header. +: Flags xml files that don't have a header Severity : Warning Category @@ -29,10 +29,43 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/MissingXmlHeaderDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MissingXmlHeaderDetectorTest.kt) An xml file should always have the xml header to declare that it is an xml file despite the file ending. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/values/strings.xml:1:Warning: Missing an xml header +[MissingXmlHeader] +<resources/> +------------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/MissingXmlHeaderDetectorTest.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, `MissingXmlHeaderDetector.missingHeader`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/MockLocation.md.html b/docs/checks/MockLocation.md.html index c913262..5f2a2b9 100644 --- a/docs/checks/MockLocation.md.html +++ b/docs/checks/MockLocation.md.html @@ -51,12 +51,11 @@ src/main/AndroidManifest.xml:8:Error: Mock locations should only be requested in a test or debug-specific manifest file (typically src/debug/AndroidManifest.xml) [MockLocation] - <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> ------------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/main/AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -72,6 +71,48 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/debug/AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="foo.bar2" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="14" /> + <uses-permission android:name="com.example.helloworld.permission" /> + <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> + +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="foo.bar2" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="14" /> + <uses-permission android:name="com.example.helloworld.permission" /> + <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> + +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +android { + compileSdkVersion 25 + defaultConfig { + applicationId "com.android.tools.test" + minSdkVersion 5 + targetSdkVersion 16 + versionCode 2 + versionName "MyName" + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ModifierFactoryExtensionFunction.md.html b/docs/checks/ModifierFactoryExtensionFunction.md.html index 07e5d6e..505699d 100644 --- a/docs/checks/ModifierFactoryExtensionFunction.md.html +++ b/docs/checks/ModifierFactoryExtensionFunction.md.html @@ -45,61 +45,49 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/androidx/compose/ui/foo/TestModifier.kt:8:Warning: Modifier factory +src/androidx/compose/ui/foo/test.kt:6:Warning: Modifier factory functions should be extensions on Modifier [ModifierFactoryExtensionFunction] - fun fooModifier(): Modifier { ----------- - - -src/androidx/compose/ui/foo/TestModifier.kt:12:Warning: Modifier factory +src/androidx/compose/ui/foo/test.kt:10:Warning: Modifier factory functions should be extensions on Modifier [ModifierFactoryExtensionFunction] - val fooModifier get(): Modifier { ----------- - - -src/androidx/compose/ui/foo/TestModifier.kt:16:Warning: Modifier factory +src/androidx/compose/ui/foo/test.kt:14:Warning: Modifier factory functions should be extensions on Modifier [ModifierFactoryExtensionFunction] - val fooModifier2: Modifier get() { ------------ - - -src/androidx/compose/ui/foo/TestModifier.kt:20:Warning: Modifier factory +src/androidx/compose/ui/foo/test.kt:18:Warning: Modifier factory functions should be extensions on Modifier [ModifierFactoryExtensionFunction] - - val fooModifier3: Modifier get() = TestModifier + val fooModifier3: Modifier get() = Modifier ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`src/androidx/compose/ui/foo/TestModifier.kt`: +`src/androidx/compose/ui/foo/test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers package androidx.compose.ui.foo import androidx.compose.ui.Modifier -object TestModifier : Modifier.Element - fun fooModifier(): Modifier { - return this.then(TestModifier) + return Modifier } val fooModifier get(): Modifier { - return this.then(TestModifier) + return Modifier } val fooModifier2: Modifier get() { - return this.then(TestModifier) + return Modifier } -val fooModifier3: Modifier get() = TestModifier +val fooModifier3: Modifier get() = Modifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the @@ -119,17 +107,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -137,7 +125,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/ModifierFactoryReturnType.md.html b/docs/checks/ModifierFactoryReturnType.md.html index d2dc43d..22d064c 100644 --- a/docs/checks/ModifierFactoryReturnType.md.html +++ b/docs/checks/ModifierFactoryReturnType.md.html @@ -48,7 +48,6 @@ src/androidx/compose/ui/foo/TestModifier.kt:8:Warning: Modifier factory functions should have a return type of Modifier [ModifierFactoryReturnType] - fun Modifier.fooModifier(): Modifier.Element { ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -64,7 +63,7 @@ object TestModifier : Modifier.Element fun Modifier.fooModifier(): Modifier.Element { - return this.then(TestModifier) + return TestModifier } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -85,17 +84,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -103,7 +102,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/ModifierFactoryUnreferencedReceiver.md.html b/docs/checks/ModifierFactoryUnreferencedReceiver.md.html index 6fdac56..f884be4 100644 --- a/docs/checks/ModifierFactoryUnreferencedReceiver.md.html +++ b/docs/checks/ModifierFactoryUnreferencedReceiver.md.html @@ -55,8 +55,7 @@ src/androidx/compose/ui/foo/TestModifier.kt:8:Error: Modifier factory functions must use the receiver Modifier instance [ModifierFactoryUnreferencedReceiver] - - fun Modifier.fooModifier() = TestModifier + fun Modifier.fooModifier(): Modifier.Element { ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -70,7 +69,9 @@ object TestModifier : Modifier.Element -fun Modifier.fooModifier() = TestModifier +fun Modifier.fooModifier(): Modifier.Element { + return TestModifier +} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the @@ -78,7 +79,7 @@ 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, `ModifierDeclarationDetector.functionImplicitlyReturnsModifierElement`. +found for this lint check, `ModifierDeclarationDetector.functionReturnsModifierElement`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=612128. @@ -90,17 +91,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -108,7 +109,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/ModifierNodeInspectableProperties.md.html b/docs/checks/ModifierNodeInspectableProperties.md.html index 7253feb..8188c8c 100644 --- a/docs/checks/ModifierNodeInspectableProperties.md.html +++ b/docs/checks/ModifierNodeInspectableProperties.md.html @@ -54,7 +54,6 @@ properties reflectively. Override inspectableProperties() if you'd like to customize this modifier's presentation in the layout inspector. [ModifierNodeInspectableProperties] - class Element : ModifierNodeElement<Modifier.Node>() { ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -92,17 +91,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -110,7 +109,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/ModifierParameter.md.html b/docs/checks/ModifierParameter.md.html index c437301..f3551a4 100644 --- a/docs/checks/ModifierParameter.md.html +++ b/docs/checks/ModifierParameter.md.html @@ -54,7 +54,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/androidx/compose/ui/foo/test.kt:10:Warning: Modifier parameter should be named modifier [ModifierParameter] - buttonModifier: Modifier = Modifier, -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -94,17 +93,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -112,7 +111,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/ModuleCompanionObjects.md.html b/docs/checks/ModuleCompanionObjects.md.html index ca050f7..9ea6537 100644 --- a/docs/checks/ModuleCompanionObjects.md.html +++ b/docs/checks/ModuleCompanionObjects.md.html @@ -1,13 +1,13 @@ -(#) Module companion objects should not be annotated with @Module. +(#) Module companion objects should not be annotated with @Module -!!! WARNING: Module companion objects should not be annotated with @Module. +!!! WARNING: Module companion objects should not be annotated with @Module This is a warning. Id : `ModuleCompanionObjects` Summary -: Module companion objects should not be annotated with @Module. +: Module companion objects should not be annotated with @Module Severity : Warning Category @@ -49,21 +49,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:66:Warning: Module companion objects should not be annotated with @Module. [ModuleCompanionObjects] - // This should fail because the companion object is part of ClassModule ^ - - src/foo/MyQualifier.kt:78:Warning: Module companion objects should not be annotated with @Module. [ModuleCompanionObjects] - // This should fail because the companion object is part of ClassModule ^ - - src/foo/MyQualifier.kt:101:Warning: Module companion objects should not be annotated with @Module. [ModuleCompanionObjects] - // This is should fail because this should be extracted to a standalone object. ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ModuleCompanionObjectsNotInModuleParent.md.html b/docs/checks/ModuleCompanionObjectsNotInModuleParent.md.html index bde99f8..6a752a2 100644 --- a/docs/checks/ModuleCompanionObjectsNotInModuleParent.md.html +++ b/docs/checks/ModuleCompanionObjectsNotInModuleParent.md.html @@ -1,13 +1,13 @@ -(#) Companion objects should not be annotated with @Module. +(#) Companion objects should not be annotated with @Module -!!! WARNING: Companion objects should not be annotated with @Module. +!!! WARNING: Companion objects should not be annotated with @Module This is a warning. Id : `ModuleCompanionObjectsNotInModuleParent` Summary -: Companion objects should not be annotated with @Module. +: Companion objects should not be annotated with @Module Severity : Warning Category diff --git a/docs/checks/MonochromeLauncherIcon.md.html b/docs/checks/MonochromeLauncherIcon.md.html index 1d663a9..7eb5696 100644 --- a/docs/checks/MonochromeLauncherIcon.md.html +++ b/docs/checks/MonochromeLauncherIcon.md.html @@ -46,14 +46,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/drawable-ldpi/ic_icon.xml:2:Warning: The application adaptive icon is missing a monochrome tag [MonochromeLauncherIcon] - <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> ^ - - res/drawable-ldpi/ic_round_icon.xml:2:Warning: The application adaptive roundIcon is missing a monochrome tag [MonochromeLauncherIcon] - <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageAdaptedByRequiresAdapter.md.html b/docs/checks/MoshiUsageAdaptedByRequiresAdapter.md.html index 5e6cba0..c2c5789 100644 --- a/docs/checks/MoshiUsageAdaptedByRequiresAdapter.md.html +++ b/docs/checks/MoshiUsageAdaptedByRequiresAdapter.md.html @@ -1,13 +1,13 @@ -(#) @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory. +(#) @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory -!!! ERROR: @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory. +!!! ERROR: @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory This is an error. Id : `MoshiUsageAdaptedByRequiresAdapter` Summary -: @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory. +: @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,15 +50,11 @@ src/slack/model/Example1.kt:14:Error: @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory. [MoshiUsageAdaptedByRequiresAdapter] - @AdaptedBy(NotAnAdapter::class) ------------------- - - src/slack/model/Example1.kt:20:Error: @AdaptedBy.adapter must be a JsonAdapter or JsonAdapter.Factory. [MoshiUsageAdaptedByRequiresAdapter] - @AdaptedBy(NotAnAdapter::class) val value2: String ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageAdaptedByRequiresKeep.md.html b/docs/checks/MoshiUsageAdaptedByRequiresKeep.md.html index 433754c..030b108 100644 --- a/docs/checks/MoshiUsageAdaptedByRequiresKeep.md.html +++ b/docs/checks/MoshiUsageAdaptedByRequiresKeep.md.html @@ -1,13 +1,13 @@ -(#) Adapters targeted by @AdaptedBy must have @Keep. +(#) Adapters targeted by @AdaptedBy must have @Keep -!!! ERROR: Adapters targeted by @AdaptedBy must have @Keep. +!!! ERROR: Adapters targeted by @AdaptedBy must have @Keep This is an error. Id : `MoshiUsageAdaptedByRequiresKeep` Summary -: Adapters targeted by @AdaptedBy must have @Keep. +: Adapters targeted by @AdaptedBy must have @Keep Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example1.kt:23:Error: Adapters targeted by @AdaptedBy must have @Keep. [MoshiUsageAdaptedByRequiresKeep] - @AdaptedBy(CustomAdapterMissingKeep::class) ------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageArray.md.html b/docs/checks/MoshiUsageArray.md.html index cdfafa5..90c7db1 100644 --- a/docs/checks/MoshiUsageArray.md.html +++ b/docs/checks/MoshiUsageArray.md.html @@ -1,13 +1,13 @@ -(#) Prefer List over Array. +(#) Prefer List over Array -!!! WARNING: Prefer List over Array. +!!! WARNING: Prefer List over Array This is a warning. Id : `MoshiUsageArray` Summary -: Prefer List over Array. +: Prefer List over Array Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -53,33 +53,40 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:43:Warning: Prefer List over Array. [MoshiUsageArray] - val arrayType: Array<String>, ------------- - - src/slack/model/Example.kt:44:Warning: Prefer List over Array. [MoshiUsageArray] - val intArray: IntArray, -------- - - src/slack/model/Example.kt:45:Warning: Prefer List over Array. [MoshiUsageArray] - val boolArray: BooleanArray, ------------ - - src/slack/model/Example.kt:46:Warning: Prefer List over Array. [MoshiUsageArray] - val complexArray: Array<List<String>>, ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageBlankGenerator.md.html b/docs/checks/MoshiUsageBlankGenerator.md.html index b2e8039..e230752 100644 --- a/docs/checks/MoshiUsageBlankGenerator.md.html +++ b/docs/checks/MoshiUsageBlankGenerator.md.html @@ -1,13 +1,13 @@ -(#) Don't use blank JsonClass.generator values. +(#) Don't use blank JsonClass.generator values -!!! ERROR: Don't use blank JsonClass.generator values. +!!! ERROR: Don't use blank JsonClass.generator values This is an error. Id : `MoshiUsageBlankGenerator` Summary -: Don't use blank JsonClass.generator values. +: Don't use blank JsonClass.generator values Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:5:Error: Don't use blank JsonClass.generator values. [MoshiUsageBlankGenerator] - @JsonClass(generateAdapter = true, generator = "") -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageBlankJsonName.md.html b/docs/checks/MoshiUsageBlankJsonName.md.html index edbc5ca..b3f9061 100644 --- a/docs/checks/MoshiUsageBlankJsonName.md.html +++ b/docs/checks/MoshiUsageBlankJsonName.md.html @@ -1,13 +1,13 @@ -(#) Don't use blank names in `@Json`. +(#) Don't use blank names in `@Json` -!!! ERROR: Don't use blank names in `@Json`. +!!! ERROR: Don't use blank names in `@Json` This is an error. Id : `MoshiUsageBlankJsonName` Summary -: Don't use blank names in `@Json`. +: Don't use blank names in `@Json` Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:7:Error: Don't use blank names in @Json. [MoshiUsageBlankJsonName] - data class Example(@Json(name = "") val value: String) -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageBlankTypeLabel.md.html b/docs/checks/MoshiUsageBlankTypeLabel.md.html index e9cf331..307de44 100644 --- a/docs/checks/MoshiUsageBlankTypeLabel.md.html +++ b/docs/checks/MoshiUsageBlankTypeLabel.md.html @@ -1,13 +1,13 @@ -(#) Moshi-sealed requires a type label specified after the 'sealed:' prefix. +(#) Moshi-sealed requires a type label specified after the 'sealed:' prefix -!!! ERROR: Moshi-sealed requires a type label specified after the 'sealed:' prefix. +!!! ERROR: Moshi-sealed requires a type label specified after the 'sealed:' prefix This is an error. Id : `MoshiUsageBlankTypeLabel` Summary -: Moshi-sealed requires a type label specified after the 'sealed:' prefix. +: Moshi-sealed requires a type label specified after the 'sealed:' prefix Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/BaseType.kt:5:Error: Moshi-sealed requires a type label specified after the 'sealed:' prefix. [MoshiUsageBlankTypeLabel] - @JsonClass(generateAdapter = true, generator = "sealed:") ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageClassVisibility.md.html b/docs/checks/MoshiUsageClassVisibility.md.html index d679c02..d84bfa9 100644 --- a/docs/checks/MoshiUsageClassVisibility.md.html +++ b/docs/checks/MoshiUsageClassVisibility.md.html @@ -1,13 +1,13 @@ -(#) @JsonClass-annotated types must be public, package-private, or internal. +(#) @JsonClass-annotated types must be public, package-private, or internal -!!! ERROR: @JsonClass-annotated types must be public, package-private, or internal. +!!! ERROR: @JsonClass-annotated types must be public, package-private, or internal This is an error. Id : `MoshiUsageClassVisibility` Summary -: @JsonClass-annotated types must be public, package-private, or internal. +: @JsonClass-annotated types must be public, package-private, or internal Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,15 +50,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/PrivateClass.kt:6:Error: @JsonClass-annotated types must be public, package-private, or internal. [MoshiUsageClassVisibility] - private data class PrivateClass(val value: String) ------- - - src/slack/model/PrivateClass.kt:10:Error: @JsonClass-annotated types must be public, package-private, or internal. [MoshiUsageClassVisibility] - protected data class ProtectedClass(val value: String) --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageDoubleClassAnnotation.md.html b/docs/checks/MoshiUsageDoubleClassAnnotation.md.html index 992685c..962f345 100644 --- a/docs/checks/MoshiUsageDoubleClassAnnotation.md.html +++ b/docs/checks/MoshiUsageDoubleClassAnnotation.md.html @@ -1,13 +1,13 @@ -(#) Only use one of @AdaptedBy or @JsonClass. +(#) Only use one of @AdaptedBy or @JsonClass -!!! ERROR: Only use one of @AdaptedBy or @JsonClass. +!!! ERROR: Only use one of @AdaptedBy or @JsonClass This is an error. Id : `MoshiUsageDoubleClassAnnotation` Summary -: Only use one of @AdaptedBy or @JsonClass. +: Only use one of @AdaptedBy or @JsonClass Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,14 +49,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:8:Error: Only use one of @AdaptedBy or @JsonClass. [MoshiUsageDoubleClassAnnotation] - @JsonClass(generateAdapter = true) ---------------------------------- - - src/slack/model/Example.kt:9:Error: Only use one of @AdaptedBy or @JsonClass. [MoshiUsageDoubleClassAnnotation] - @AdaptedBy(CustomFactory::class) -------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageDoubleTypeLabel.md.html b/docs/checks/MoshiUsageDoubleTypeLabel.md.html index 78f06a0..06c860a 100644 --- a/docs/checks/MoshiUsageDoubleTypeLabel.md.html +++ b/docs/checks/MoshiUsageDoubleTypeLabel.md.html @@ -1,13 +1,13 @@ -(#) Only use one of @TypeLabel or @DefaultObject. +(#) Only use one of @TypeLabel or @DefaultObject -!!! ERROR: Only use one of @TypeLabel or @DefaultObject. +!!! ERROR: Only use one of @TypeLabel or @DefaultObject This is an error. Id : `MoshiUsageDoubleTypeLabel` Summary -: Only use one of @TypeLabel or @DefaultObject. +: Only use one of @TypeLabel or @DefaultObject Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,14 +49,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/BaseType.kt:10:Error: Only use one of @TypeLabel or @DefaultObject. [MoshiUsageDoubleTypeLabel] - @TypeLabel(label = "one") ------------------------- - - src/slack/model/BaseType.kt:11:Error: Only use one of @TypeLabel or @DefaultObject. [MoshiUsageDoubleTypeLabel] - @DefaultObject -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageDuplicateJsonName.md.html b/docs/checks/MoshiUsageDuplicateJsonName.md.html index 11d540c..a167154 100644 --- a/docs/checks/MoshiUsageDuplicateJsonName.md.html +++ b/docs/checks/MoshiUsageDuplicateJsonName.md.html @@ -1,13 +1,13 @@ -(#) Duplicate JSON names are errors as JSON does not allow duplicate keys in objects. +(#) Duplicate JSON names are errors as JSON does not allow duplicate keys in objects -!!! ERROR: Duplicate JSON names are errors as JSON does not allow duplicate keys in objects. +!!! ERROR: Duplicate JSON names are errors as JSON does not allow duplicate keys in objects This is an error. Id : `MoshiUsageDuplicateJsonName` Summary -: Duplicate JSON names are errors as JSON does not allow duplicate keys in objects. +: Duplicate JSON names are errors as JSON does not allow duplicate keys in objects Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,28 +49,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:8:Error: Name 'value' is duplicated by member 'anotherValue'. [MoshiUsageDuplicateJsonName] - val value: String, ----- - - src/slack/model/Example.kt:9:Error: Name 'value' is duplicated by member 'value'. [MoshiUsageDuplicateJsonName] - @Json(name = "value") val anotherValue: String, ------------ - - src/slack/model/Example.kt:10:Error: Name 'value2' is duplicated by member 'anotherValue3'. [MoshiUsageDuplicateJsonName] - @Json(name = "value2") val anotherValue2: String, ------------- - - src/slack/model/Example.kt:11:Error: Name 'value2' is duplicated by member 'anotherValue2'. [MoshiUsageDuplicateJsonName] - @Json(name = "value2") val anotherValue3: String ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageEnumAnnotatedUnknown.md.html b/docs/checks/MoshiUsageEnumAnnotatedUnknown.md.html index c32ebeb..fc0b177 100644 --- a/docs/checks/MoshiUsageEnumAnnotatedUnknown.md.html +++ b/docs/checks/MoshiUsageEnumAnnotatedUnknown.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year diff --git a/docs/checks/MoshiUsageEnumCasing.md.html b/docs/checks/MoshiUsageEnumCasing.md.html index 081fecb..091114e 100644 --- a/docs/checks/MoshiUsageEnumCasing.md.html +++ b/docs/checks/MoshiUsageEnumCasing.md.html @@ -1,13 +1,13 @@ -(#) Consider using `@Json(name = ...)` rather than lower casing. +(#) Consider using `@Json(name = ...)` rather than lower casing -!!! WARNING: Consider using `@Json(name = ...)` rather than lower casing. +!!! WARNING: Consider using `@Json(name = ...)` rather than lower casing This is a warning. Id : `MoshiUsageEnumCasing` Summary -: Consider using `@Json(name = ...)` rather than lower casing. +: Consider using `@Json(name = ...)` rather than lower casing Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year diff --git a/docs/checks/MoshiUsageEnumJsonClassGenerated.md.html b/docs/checks/MoshiUsageEnumJsonClassGenerated.md.html index e58ae02..b997e09 100644 --- a/docs/checks/MoshiUsageEnumJsonClassGenerated.md.html +++ b/docs/checks/MoshiUsageEnumJsonClassGenerated.md.html @@ -1,13 +1,13 @@ -(#) Enums annotated with @JsonClass must not set `generateAdapter` to true. +(#) Enums annotated with @JsonClass must not set `generateAdapter` to true -!!! ERROR: Enums annotated with @JsonClass must not set `generateAdapter` to true. +!!! ERROR: Enums annotated with @JsonClass must not set `generateAdapter` to true This is an error. Id : `MoshiUsageEnumJsonClassGenerated` Summary -: Enums annotated with @JsonClass must not set `generateAdapter` to true. +: Enums annotated with @JsonClass must not set `generateAdapter` to true Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year diff --git a/docs/checks/MoshiUsageEnumMissingJsonClass.md.html b/docs/checks/MoshiUsageEnumMissingJsonClass.md.html index 4189494..a6cab58 100644 --- a/docs/checks/MoshiUsageEnumMissingJsonClass.md.html +++ b/docs/checks/MoshiUsageEnumMissingJsonClass.md.html @@ -1,13 +1,13 @@ -(#) Enums serialized with Moshi should be annotated with @JsonClass. +(#) Enums serialized with Moshi should be annotated with @JsonClass -!!! ERROR: Enums serialized with Moshi should be annotated with @JsonClass. +!!! ERROR: Enums serialized with Moshi should be annotated with @JsonClass This is an error. Id : `MoshiUsageEnumMissingJsonClass` Summary -: Enums serialized with Moshi should be annotated with @JsonClass. +: Enums serialized with Moshi should be annotated with @JsonClass Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year diff --git a/docs/checks/MoshiUsageEnumMissingUnknown.md.html b/docs/checks/MoshiUsageEnumMissingUnknown.md.html index 1c3e971..85a5a8e 100644 --- a/docs/checks/MoshiUsageEnumMissingUnknown.md.html +++ b/docs/checks/MoshiUsageEnumMissingUnknown.md.html @@ -1,13 +1,13 @@ -(#) Enums serialized with Moshi must reserve the first member as UNKNOWN. +(#) Enums serialized with Moshi must reserve the first member as UNKNOWN -!!! ERROR: Enums serialized with Moshi must reserve the first member as UNKNOWN. +!!! ERROR: Enums serialized with Moshi must reserve the first member as UNKNOWN This is an error. Id : `MoshiUsageEnumMissingUnknown` Summary -: Enums serialized with Moshi must reserve the first member as UNKNOWN. +: Enums serialized with Moshi must reserve the first member as UNKNOWN Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year diff --git a/docs/checks/MoshiUsageEnumPropertyCouldBeMoshi.md.html b/docs/checks/MoshiUsageEnumPropertyCouldBeMoshi.md.html index c9b0b65..2184f0d 100644 --- a/docs/checks/MoshiUsageEnumPropertyCouldBeMoshi.md.html +++ b/docs/checks/MoshiUsageEnumPropertyCouldBeMoshi.md.html @@ -1,13 +1,13 @@ -(#) Consider making enum properties also use Moshi. +(#) Consider making enum properties also use Moshi -!!! WARNING: Consider making enum properties also use Moshi. +!!! WARNING: Consider making enum properties also use Moshi This is a warning. Id : `MoshiUsageEnumPropertyCouldBeMoshi` Summary -: Consider making enum properties also use Moshi. +: Consider making enum properties also use Moshi Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:6:Warning: Consider making enum properties also use Moshi. [MoshiUsageEnumPropertyCouldBeMoshi] - data class Example(val value: TestEnum) -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageEnumPropertyDefaultUnknown.md.html b/docs/checks/MoshiUsageEnumPropertyDefaultUnknown.md.html index fd297d3..dcf3593 100644 --- a/docs/checks/MoshiUsageEnumPropertyDefaultUnknown.md.html +++ b/docs/checks/MoshiUsageEnumPropertyDefaultUnknown.md.html @@ -1,13 +1,13 @@ -(#) Suspicious default value to 'UNKNOWN' for a Moshi enum. +(#) Suspicious default value to 'UNKNOWN' for a Moshi enum -!!! ERROR: Suspicious default value to 'UNKNOWN' for a Moshi enum. +!!! ERROR: Suspicious default value to 'UNKNOWN' for a Moshi enum This is an error. Id : `MoshiUsageEnumPropertyDefaultUnknown` Summary -: Suspicious default value to 'UNKNOWN' for a Moshi enum. +: Suspicious default value to 'UNKNOWN' for a Moshi enum Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -52,21 +52,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:9:Error: Suspicious default value to 'UNKNOWN' for a Moshi enum. [MoshiUsageEnumPropertyDefaultUnknown] - val value3: TestEnum? = UNKNOWN, ------- - - src/slack/model/Example.kt:10:Error: Suspicious default value to 'UNKNOWN' for a Moshi enum. [MoshiUsageEnumPropertyDefaultUnknown] - val value4: TestEnum = UNKNOWN, ------- - - src/slack/model/Example.kt:11:Error: Suspicious default value to 'UNKNOWN' for a Moshi enum. [MoshiUsageEnumPropertyDefaultUnknown] - val value5: TestEnum = TestEnum.UNKNOWN, ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageGenerateAdapterShouldBeTrue.md.html b/docs/checks/MoshiUsageGenerateAdapterShouldBeTrue.md.html index 84d9964..7709cd1 100644 --- a/docs/checks/MoshiUsageGenerateAdapterShouldBeTrue.md.html +++ b/docs/checks/MoshiUsageGenerateAdapterShouldBeTrue.md.html @@ -1,13 +1,13 @@ -(#) JsonClass.generateAdapter must be true in order for Moshi code gen to run. +(#) JsonClass.generateAdapter must be true in order for Moshi code gen to run -!!! ERROR: JsonClass.generateAdapter must be true in order for Moshi code gen to run. +!!! ERROR: JsonClass.generateAdapter must be true in order for Moshi code gen to run This is an error. Id : `MoshiUsageGenerateAdapterShouldBeTrue` Summary -: JsonClass.generateAdapter must be true in order for Moshi code gen to run. +: JsonClass.generateAdapter must be true in order for Moshi code gen to run Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ src/slack/model/Example.kt:5:Error: JsonClass.generateAdapter must be true in order for Moshi code gen to run. [MoshiUsageGenerateAdapterShouldBeTrue] - @JsonClass(generateAdapter = false) ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageGenericSealedSubtype.md.html b/docs/checks/MoshiUsageGenericSealedSubtype.md.html index 3fcbc3d..01e9c48 100644 --- a/docs/checks/MoshiUsageGenericSealedSubtype.md.html +++ b/docs/checks/MoshiUsageGenericSealedSubtype.md.html @@ -1,13 +1,13 @@ -(#) Sealed subtypes used with moshi-sealed cannot be generic. +(#) Sealed subtypes used with moshi-sealed cannot be generic -!!! ERROR: Sealed subtypes used with moshi-sealed cannot be generic. +!!! ERROR: Sealed subtypes used with moshi-sealed cannot be generic This is an error. Id : `MoshiUsageGenericSealedSubtype` Summary -: Sealed subtypes used with moshi-sealed cannot be generic. +: Sealed subtypes used with moshi-sealed cannot be generic Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/BaseType.kt:11:Error: Sealed subtypes used with moshi-sealed cannot be generic. [MoshiUsageGenericSealedSubtype] - data class Subtype<T>(val foo: T) : BaseType<T>() --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageInappropriateTypeLabel.md.html b/docs/checks/MoshiUsageInappropriateTypeLabel.md.html index 5fc1f45..d20c7f2 100644 --- a/docs/checks/MoshiUsageInappropriateTypeLabel.md.html +++ b/docs/checks/MoshiUsageInappropriateTypeLabel.md.html @@ -1,13 +1,13 @@ -(#) Inappropriate @TypeLabel or @DefaultObject annotation. +(#) Inappropriate @TypeLabel or @DefaultObject annotation -!!! ERROR: Inappropriate @TypeLabel or @DefaultObject annotation. +!!! ERROR: Inappropriate @TypeLabel or @DefaultObject annotation This is an error. Id : `MoshiUsageInappropriateTypeLabel` Summary -: Inappropriate @TypeLabel or @DefaultObject annotation. +: Inappropriate @TypeLabel or @DefaultObject annotation Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,21 +50,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Subtype.kt:7:Error: Inappropriate @TypeLabel or @DefaultObject annotation. [MoshiUsageInappropriateTypeLabel] - @TypeLabel(label = "one") ------------------------- - - src/slack/model/Subtype.kt:11:Error: Inappropriate @TypeLabel or @DefaultObject annotation. [MoshiUsageInappropriateTypeLabel] - @TypeLabel(label = "two") ------------------------- - - src/slack/model/Subtype.kt:14:Error: Inappropriate @TypeLabel or @DefaultObject annotation. [MoshiUsageInappropriateTypeLabel] - @DefaultObject -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageMissingPrimary.md.html b/docs/checks/MoshiUsageMissingPrimary.md.html index 74d68da..0b19a92 100644 --- a/docs/checks/MoshiUsageMissingPrimary.md.html +++ b/docs/checks/MoshiUsageMissingPrimary.md.html @@ -1,13 +1,13 @@ -(#) @JsonClass-annotated types must have a primary constructor or be sealed. +(#) @JsonClass-annotated types must have a primary constructor or be sealed -!!! ERROR: @JsonClass-annotated types must have a primary constructor or be sealed. +!!! ERROR: @JsonClass-annotated types must have a primary constructor or be sealed This is an error. Id : `MoshiUsageMissingPrimary` Summary -: @JsonClass-annotated types must have a primary constructor or be sealed. +: @JsonClass-annotated types must have a primary constructor or be sealed Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:6:Error: @JsonClass-annotated types must have a primary constructor or be sealed. [MoshiUsageMissingPrimary] - class Example ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageMissingTypeLabel.md.html b/docs/checks/MoshiUsageMissingTypeLabel.md.html index 20b7acf..25c989f 100644 --- a/docs/checks/MoshiUsageMissingTypeLabel.md.html +++ b/docs/checks/MoshiUsageMissingTypeLabel.md.html @@ -1,13 +1,13 @@ -(#) Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject. +(#) Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject -!!! ERROR: Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject. +!!! ERROR: Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject This is an error. Id : `MoshiUsageMissingTypeLabel` Summary -: Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject. +: Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,15 +50,11 @@ src/slack/model/BaseType.kt:9:Error: Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject. [MoshiUsageMissingTypeLabel] - data class Subtype(val foo: String) : BaseType() ------- - - src/slack/model/BaseType.kt:11:Error: Sealed Moshi subtypes must be annotated with @TypeLabel or @DefaultObject. [MoshiUsageMissingTypeLabel] - object ObjectSubType : BaseType() ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageMutableCollections.md.html b/docs/checks/MoshiUsageMutableCollections.md.html index 1f2a6d6..feb2e52 100644 --- a/docs/checks/MoshiUsageMutableCollections.md.html +++ b/docs/checks/MoshiUsageMutableCollections.md.html @@ -1,13 +1,13 @@ -(#) Use immutable collections rather than mutable versions. +(#) Use immutable collections rather than mutable versions -!!! ERROR: Use immutable collections rather than mutable versions. +!!! ERROR: Use immutable collections rather than mutable versions This is an error. Id : `MoshiUsageMutableCollections` Summary -: Use immutable collections rather than mutable versions. +: Use immutable collections rather than mutable versions Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,33 +50,40 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:53:Error: Use immutable collections rather than mutable versions. [MoshiUsageMutableCollections] - val mutableList: MutableList<Int>, ---------------- - - src/slack/model/Example.kt:54:Error: Use immutable collections rather than mutable versions. [MoshiUsageMutableCollections] - val mutableSet: MutableSet<Int>, --------------- - - src/slack/model/Example.kt:55:Error: Use immutable collections rather than mutable versions. [MoshiUsageMutableCollections] - val mutableCollection: MutableCollection<Int>, ---------------------- - - src/slack/model/Example.kt:56:Error: Use immutable collections rather than mutable versions. [MoshiUsageMutableCollections] - val mutableMap: MutableMap<String, String> -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageNonMoshiClassCollection.md.html b/docs/checks/MoshiUsageNonMoshiClassCollection.md.html index 17fa1d0..09f1b6a 100644 --- a/docs/checks/MoshiUsageNonMoshiClassCollection.md.html +++ b/docs/checks/MoshiUsageNonMoshiClassCollection.md.html @@ -1,13 +1,13 @@ -(#) Concrete Collection type '%HINT%' is not natively supported by Moshi. +(#) Concrete Collection type '%HINT%' is not natively supported by Moshi -!!! Tip: Concrete Collection type '%HINT%' is not natively supported by Moshi. +!!! Tip: Concrete Collection type '%HINT%' is not natively supported by Moshi Advice from this check is just a tip. Id : `MoshiUsageNonMoshiClassCollection` Summary -: Concrete Collection type '%HINT%' is not natively supported by Moshi. +: Concrete Collection type '%HINT%' is not natively supported by Moshi Severity : Information Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -53,20 +53,33 @@ src/slack/model/Example.kt:25:Information: Concrete Collection type 'ArrayList' is not natively supported by Moshi. [MoshiUsageNonMoshiClassCollection] - val concreteList: ArrayList<Int>, -------------- - - src/slack/model/Example.kt:26:Information: Concrete Collection type 'HashSet' is not natively supported by Moshi. [MoshiUsageNonMoshiClassCollection] - val concreteSet: HashSet<Int>, ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageNonMoshiClassExternal.md.html b/docs/checks/MoshiUsageNonMoshiClassExternal.md.html index 6f125ff..2b2910c 100644 --- a/docs/checks/MoshiUsageNonMoshiClassExternal.md.html +++ b/docs/checks/MoshiUsageNonMoshiClassExternal.md.html @@ -1,13 +1,13 @@ -(#) External type '%HINT%' is not natively supported by Moshi. +(#) External type '%HINT%' is not natively supported by Moshi -!!! ERROR: External type '%HINT%' is not natively supported by Moshi. +!!! ERROR: External type '%HINT%' is not natively supported by Moshi This is an error. Id : `MoshiUsageNonMoshiClassExternal` Summary -: External type '%HINT%' is not natively supported by Moshi. +: External type '%HINT%' is not natively supported by Moshi Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -54,33 +54,40 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:32:Error: External type 'ExternalType' is not natively supported by Moshi. [MoshiUsageNonMoshiClassExternal] - val externalType: ExternalType, ------------ - - src/slack/model/Example.kt:47:Error: External type 'ExternalType' is not natively supported by Moshi. [MoshiUsageNonMoshiClassExternal] - val badGeneric: List<ExternalType>, ------------------ - - src/slack/model/Example.kt:48:Error: External type 'ExternalType' is not natively supported by Moshi. [MoshiUsageNonMoshiClassExternal] - val badGeneric2: CustomGenericType<ExternalType>, ------------------------------- - - src/slack/model/Example.kt:49:Error: External type 'ExternalType' is not natively supported by Moshi. [MoshiUsageNonMoshiClassExternal] - val badNestedGeneric: CustomGenericType<List<ExternalType>>, ------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageNonMoshiClassInternal.md.html b/docs/checks/MoshiUsageNonMoshiClassInternal.md.html index 9c78577..4919239 100644 --- a/docs/checks/MoshiUsageNonMoshiClassInternal.md.html +++ b/docs/checks/MoshiUsageNonMoshiClassInternal.md.html @@ -1,13 +1,13 @@ -(#) Non-Moshi internal type '%HINT%' is not natively supported by Moshi. +(#) Non-Moshi internal type '%HINT%' is not natively supported by Moshi -!!! Tip: Non-Moshi internal type '%HINT%' is not natively supported by Moshi. +!!! Tip: Non-Moshi internal type '%HINT%' is not natively supported by Moshi Advice from this check is just a tip. Id : `MoshiUsageNonMoshiClassInternal` Summary -: Non-Moshi internal type '%HINT%' is not natively supported by Moshi. +: Non-Moshi internal type '%HINT%' is not natively supported by Moshi Severity : Information Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -52,12 +52,28 @@ src/slack/model/Example.kt:35:Information: Non-Moshi internal type 'InternalType' is not natively supported by Moshi. [MoshiUsageNonMoshiClassInternal] - val internalType: InternalType, ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageNonMoshiClassMap.md.html b/docs/checks/MoshiUsageNonMoshiClassMap.md.html index 87dd1b2..4fef577 100644 --- a/docs/checks/MoshiUsageNonMoshiClassMap.md.html +++ b/docs/checks/MoshiUsageNonMoshiClassMap.md.html @@ -1,13 +1,13 @@ -(#) Concrete Map type '%HINT%' is not natively supported by Moshi. +(#) Concrete Map type '%HINT%' is not natively supported by Moshi -!!! Tip: Concrete Map type '%HINT%' is not natively supported by Moshi. +!!! Tip: Concrete Map type '%HINT%' is not natively supported by Moshi Advice from this check is just a tip. Id : `MoshiUsageNonMoshiClassMap` Summary -: Concrete Map type '%HINT%' is not natively supported by Moshi. +: Concrete Map type '%HINT%' is not natively supported by Moshi Severity : Information Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -51,12 +51,28 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:27:Information: Concrete Map type 'HashMap' is not natively supported by Moshi. [MoshiUsageNonMoshiClassMap] - val concreteMap: HashMap<String, String>, ----------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageNonMoshiClassPlatform.md.html b/docs/checks/MoshiUsageNonMoshiClassPlatform.md.html index 517faff..cb7d1d5 100644 --- a/docs/checks/MoshiUsageNonMoshiClassPlatform.md.html +++ b/docs/checks/MoshiUsageNonMoshiClassPlatform.md.html @@ -1,13 +1,13 @@ -(#) Platform type '%HINT%' is not natively supported by Moshi. +(#) Platform type '%HINT%' is not natively supported by Moshi -!!! WARNING: Platform type '%HINT%' is not natively supported by Moshi. +!!! WARNING: Platform type '%HINT%' is not natively supported by Moshi This is a warning. Id : `MoshiUsageNonMoshiClassPlatform` Summary -: Platform type '%HINT%' is not natively supported by Moshi. +: Platform type '%HINT%' is not natively supported by Moshi Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -53,12 +53,28 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:29:Warning: Platform type 'Date' is not natively supported by Moshi. [MoshiUsageNonMoshiClassPlatform] - val platformType: Date, ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/external/ExternalType.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +class ExternalType +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/external/ExternalTypeAnnotated.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package external + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class ExternalTypeAnnotated(val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/slack/model/Example.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/MoshiUsageObject.md.html b/docs/checks/MoshiUsageObject.md.html index 443c391..46ccd58 100644 --- a/docs/checks/MoshiUsageObject.md.html +++ b/docs/checks/MoshiUsageObject.md.html @@ -1,13 +1,13 @@ -(#) Object types cannot be annotated with @JsonClass. +(#) Object types cannot be annotated with @JsonClass -!!! ERROR: Object types cannot be annotated with @JsonClass. +!!! ERROR: Object types cannot be annotated with @JsonClass This is an error. Id : `MoshiUsageObject` Summary -: Object types cannot be annotated with @JsonClass. +: Object types cannot be annotated with @JsonClass Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:5:Error: Object types cannot be annotated with @JsonClass. [MoshiUsageObject] - @JsonClass(generateAdapter = true) ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageParamNeedsInit.md.html b/docs/checks/MoshiUsageParamNeedsInit.md.html index ba806f4..0df4fea 100644 --- a/docs/checks/MoshiUsageParamNeedsInit.md.html +++ b/docs/checks/MoshiUsageParamNeedsInit.md.html @@ -1,13 +1,13 @@ -(#) Constructor non-property parameters in Moshi classes must have default values. +(#) Constructor non-property parameters in Moshi classes must have default values -!!! ERROR: Constructor non-property parameters in Moshi classes must have default values. +!!! ERROR: Constructor non-property parameters in Moshi classes must have default values This is an error. Id : `MoshiUsageParamNeedsInit` Summary -: Constructor non-property parameters in Moshi classes must have default values. +: Constructor non-property parameters in Moshi classes must have default values Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:7:Error: Constructor non-property parameters in Moshi classes must have default values. [MoshiUsageParamNeedsInit] - class Example(val value: String, nonProp: String, @Transient val transientProp: String) --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsagePrivateConstructor.md.html b/docs/checks/MoshiUsagePrivateConstructor.md.html index 0cdb4dd..e82c2cc 100644 --- a/docs/checks/MoshiUsagePrivateConstructor.md.html +++ b/docs/checks/MoshiUsagePrivateConstructor.md.html @@ -1,13 +1,13 @@ -(#) Constructors in Moshi classes cannot be private. +(#) Constructors in Moshi classes cannot be private -!!! ERROR: Constructors in Moshi classes cannot be private. +!!! ERROR: Constructors in Moshi classes cannot be private This is an error. Id : `MoshiUsagePrivateConstructor` Summary -: Constructors in Moshi classes cannot be private. +: Constructors in Moshi classes cannot be private Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,14 +49,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:6:Error: Constructors in Moshi classes cannot be private. [MoshiUsagePrivateConstructor] - data class Example private constructor(val value: String) ------- - - src/slack/model/Example.kt:9:Error: Constructors in Moshi classes cannot be private. [MoshiUsagePrivateConstructor] - data class Example2 protected constructor(val value: String) --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsagePrivateConstructorProperty.md.html b/docs/checks/MoshiUsagePrivateConstructorProperty.md.html index 887d42b..070d6fc 100644 --- a/docs/checks/MoshiUsagePrivateConstructorProperty.md.html +++ b/docs/checks/MoshiUsagePrivateConstructorProperty.md.html @@ -1,13 +1,13 @@ -(#) Constructor parameter properties in Moshi classes cannot be private. +(#) Constructor parameter properties in Moshi classes cannot be private -!!! ERROR: Constructor parameter properties in Moshi classes cannot be private. +!!! ERROR: Constructor parameter properties in Moshi classes cannot be private This is an error. Id : `MoshiUsagePrivateConstructorProperty` Summary -: Constructor parameter properties in Moshi classes cannot be private. +: Constructor parameter properties in Moshi classes cannot be private Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:6:Error: Constructor parameter properties in Moshi classes cannot be private. [MoshiUsagePrivateConstructorProperty] - data class Example(private val value: String, protected val value2: String) --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageQualifierRetention.md.html b/docs/checks/MoshiUsageQualifierRetention.md.html index 6ec1b83..da4ff46 100644 --- a/docs/checks/MoshiUsageQualifierRetention.md.html +++ b/docs/checks/MoshiUsageQualifierRetention.md.html @@ -1,13 +1,13 @@ -(#) JsonQualifiers must have RUNTIME retention. +(#) JsonQualifiers must have RUNTIME retention -!!! ERROR: JsonQualifiers must have RUNTIME retention. +!!! ERROR: JsonQualifiers must have RUNTIME retention This is an error. Id : `MoshiUsageQualifierRetention` Summary -: JsonQualifiers must have RUNTIME retention. +: JsonQualifiers must have RUNTIME retention Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/NoAnnotationsIsOk.kt:37:Error: JsonQualifiers must have RUNTIME retention. [MoshiUsageQualifierRetention] - @Retention(AnnotationRetention.BINARY) -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageQualifierTarget.md.html b/docs/checks/MoshiUsageQualifierTarget.md.html index 4ff97d2..41f19d4 100644 --- a/docs/checks/MoshiUsageQualifierTarget.md.html +++ b/docs/checks/MoshiUsageQualifierTarget.md.html @@ -1,13 +1,13 @@ -(#) JsonQualifiers must include FIELD targeting. +(#) JsonQualifiers must include FIELD targeting -!!! ERROR: JsonQualifiers must include FIELD targeting. +!!! ERROR: JsonQualifiers must include FIELD targeting This is an error. Id : `MoshiUsageQualifierTarget` Summary -: JsonQualifiers must include FIELD targeting. +: JsonQualifiers must include FIELD targeting Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/NoAnnotationsIsOk.kt:33:Error: JsonQualifiers must include FIELD targeting. [MoshiUsageQualifierTarget] - @Target(PROPERTY) ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageRedundantJsonName.md.html b/docs/checks/MoshiUsageRedundantJsonName.md.html index b669ed3..7667575 100644 --- a/docs/checks/MoshiUsageRedundantJsonName.md.html +++ b/docs/checks/MoshiUsageRedundantJsonName.md.html @@ -1,13 +1,13 @@ -(#) Json.name with the same value as the property/enum member name is redundant. +(#) Json.name with the same value as the property/enum member name is redundant -!!! WARNING: Json.name with the same value as the property/enum member name is redundant. +!!! WARNING: Json.name with the same value as the property/enum member name is redundant This is a warning. Id : `MoshiUsageRedundantJsonName` Summary -: Json.name with the same value as the property/enum member name is redundant. +: Json.name with the same value as the property/enum member name is redundant Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -51,7 +51,6 @@ src/slack/model/Example.kt:7:Warning: Json.name with the same value as the property/enum member name is redundant. [MoshiUsageRedundantJsonName] - data class Example(@Json(name = "value") val value: String) ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageRedundantSiteTarget.md.html b/docs/checks/MoshiUsageRedundantSiteTarget.md.html index 9db5d20..5250fd9 100644 --- a/docs/checks/MoshiUsageRedundantSiteTarget.md.html +++ b/docs/checks/MoshiUsageRedundantSiteTarget.md.html @@ -1,13 +1,13 @@ -(#) Use of site-targets on @Json are redundant. +(#) Use of site-targets on @Json are redundant -!!! ERROR: Use of site-targets on @Json are redundant. +!!! ERROR: Use of site-targets on @Json are redundant This is an error. Id : `MoshiUsageRedundantSiteTarget` Summary -: Use of site-targets on @Json are redundant. +: Use of site-targets on @Json are redundant Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:8:Error: Use of site-targets on @Json are redundant. [MoshiUsageRedundantSiteTarget] - @field:Json(name = "foo") val value: String ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageSealedMustBeSealed.md.html b/docs/checks/MoshiUsageSealedMustBeSealed.md.html index dfd3b9f..9bc240c 100644 --- a/docs/checks/MoshiUsageSealedMustBeSealed.md.html +++ b/docs/checks/MoshiUsageSealedMustBeSealed.md.html @@ -1,13 +1,13 @@ -(#) Moshi-sealed can only be applied to 'sealed' types. +(#) Moshi-sealed can only be applied to 'sealed' types -!!! ERROR: Moshi-sealed can only be applied to 'sealed' types. +!!! ERROR: Moshi-sealed can only be applied to 'sealed' types This is an error. Id : `MoshiUsageSealedMustBeSealed` Summary -: Moshi-sealed can only be applied to 'sealed' types. +: Moshi-sealed can only be applied to 'sealed' types Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/BaseType.kt:6:Error: Moshi-sealed can only be applied to 'sealed' types. [MoshiUsageSealedMustBeSealed] - abstract class BaseType -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageSerializedName.md.html b/docs/checks/MoshiUsageSerializedName.md.html index 6913750..5fb0b24 100644 --- a/docs/checks/MoshiUsageSerializedName.md.html +++ b/docs/checks/MoshiUsageSerializedName.md.html @@ -1,13 +1,13 @@ -(#) Use Moshi's @Json rather than Gson's @SerializedName. +(#) Use Moshi's @Json rather than Gson's @SerializedName -!!! ERROR: Use Moshi's @Json rather than Gson's @SerializedName. +!!! ERROR: Use Moshi's @Json rather than Gson's @SerializedName This is an error. Id : `MoshiUsageSerializedName` Summary -: Use Moshi's @Json rather than Gson's @SerializedName. +: Use Moshi's @Json rather than Gson's @SerializedName Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,35 +50,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:11:Error: Use Moshi's @Json rather than Gson's @SerializedName. [MoshiUsageSerializedName] - @SerializedName("full_gson") val fullGson: String, ---------------------------- - - src/slack/model/Example.kt:12:Error: Use Moshi's @Json rather than Gson's @SerializedName. [MoshiUsageSerializedName] - @SerializedName("full_gson_alts", alternate = ["foo"]) val fullGsonAlternates: String, ------------------------------------------------------ - - src/slack/model/Example.kt:13:Error: Use Moshi's @Json rather than Gson's @SerializedName. [MoshiUsageSerializedName] - @Json(name = "mixed") @SerializedName("mixed") val mixedSame: String, ------------------------ - - src/slack/model/Example.kt:14:Error: Use Moshi's @Json rather than Gson's @SerializedName. [MoshiUsageSerializedName] - @Json(name = "mixed_diff") @SerializedName("mixed_diff_2") val mixedDiff: String, ------------------------------- - - src/slack/model/Example.kt:15:Error: Use Moshi's @Json rather than Gson's @SerializedName. [MoshiUsageSerializedName] - @Json(name = "mixed_alts") @SerializedName("mixed_alts", alternate = ["foo"]) val mixedAlternates: String, -------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageSnakeCase.md.html b/docs/checks/MoshiUsageSnakeCase.md.html index 666623d..5a38cf5 100644 --- a/docs/checks/MoshiUsageSnakeCase.md.html +++ b/docs/checks/MoshiUsageSnakeCase.md.html @@ -1,13 +1,13 @@ -(#) Consider using `@Json(name = ...)` rather than direct snake casing. +(#) Consider using `@Json(name = ...)` rather than direct snake casing -!!! WARNING: Consider using `@Json(name = ...)` rather than direct snake casing. +!!! WARNING: Consider using `@Json(name = ...)` rather than direct snake casing This is a warning. Id : `MoshiUsageSnakeCase` Summary -: Consider using `@Json(name = ...)` rather than direct snake casing. +: Consider using `@Json(name = ...)` rather than direct snake casing Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:8:Warning: Consider using @Json(name = ...) rather than direct snake casing. [MoshiUsageSnakeCase] - val snake_case: String, ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageTransientNeedsInit.md.html b/docs/checks/MoshiUsageTransientNeedsInit.md.html index a211678..7f0f9f7 100644 --- a/docs/checks/MoshiUsageTransientNeedsInit.md.html +++ b/docs/checks/MoshiUsageTransientNeedsInit.md.html @@ -1,13 +1,13 @@ -(#) Transient constructor properties must have default values. +(#) Transient constructor properties must have default values -!!! ERROR: Transient constructor properties must have default values. +!!! ERROR: Transient constructor properties must have default values This is an error. Id : `MoshiUsageTransientNeedsInit` Summary -: Transient constructor properties must have default values. +: Transient constructor properties must have default values Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:7:Error: Transient constructor properties must have default values. [MoshiUsageTransientNeedsInit] - class Example(val value: String, nonProp: String, @Transient val transientProp: String) ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageUnsupportedType.md.html b/docs/checks/MoshiUsageUnsupportedType.md.html index 6d45aaf..abeef00 100644 --- a/docs/checks/MoshiUsageUnsupportedType.md.html +++ b/docs/checks/MoshiUsageUnsupportedType.md.html @@ -1,13 +1,13 @@ -(#) This type cannot be annotated with @JsonClass. +(#) This type cannot be annotated with @JsonClass -!!! ERROR: This type cannot be annotated with @JsonClass. +!!! ERROR: This type cannot be annotated with @JsonClass This is an error. Id : `MoshiUsageUnsupportedType` Summary -: This type cannot be annotated with @JsonClass. +: This type cannot be annotated with @JsonClass Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,28 +50,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:6:Error: This type cannot be annotated with @JsonClass. [MoshiUsageUnsupportedType] - @JsonClass(generateAdapter = true) ---------------------------------- - - src/slack/model/Example.kt:9:Error: This type cannot be annotated with @JsonClass. [MoshiUsageUnsupportedType] - @JsonClass(generateAdapter = true) ---------------------------------- - - src/slack/model/Example.kt:12:Error: This type cannot be annotated with @JsonClass. [MoshiUsageUnsupportedType] - @JsonClass(generateAdapter = true) ---------------------------------- - - src/slack/model/Example.kt:15:Error: This type cannot be annotated with @JsonClass. [MoshiUsageUnsupportedType] - @JsonClass(generateAdapter = true) ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageUseData.md.html b/docs/checks/MoshiUsageUseData.md.html index 4739d86..7c3174e 100644 --- a/docs/checks/MoshiUsageUseData.md.html +++ b/docs/checks/MoshiUsageUseData.md.html @@ -1,13 +1,13 @@ -(#) Model classes should be immutable data classes. +(#) Model classes should be immutable data classes -!!! ERROR: Model classes should be immutable data classes. +!!! ERROR: Model classes should be immutable data classes This is an error. Id : `MoshiUsageUseData` Summary -: Model classes should be immutable data classes. +: Model classes should be immutable data classes Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -52,7 +52,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:7:Error: Model classes should be immutable data classes. [MoshiUsageUseData] - class Example(val value: String, nonProp: String, @Transient val transientProp: String) ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MoshiUsageVarProperty.md.html b/docs/checks/MoshiUsageVarProperty.md.html index 0ab3cca..9939370 100644 --- a/docs/checks/MoshiUsageVarProperty.md.html +++ b/docs/checks/MoshiUsageVarProperty.md.html @@ -1,13 +1,13 @@ -(#) Moshi properties should be immutable. +(#) Moshi properties should be immutable -!!! WARNING: Moshi properties should be immutable. +!!! WARNING: Moshi properties should be immutable This is a warning. Id : `MoshiUsageVarProperty` Summary -: Moshi properties should be immutable. +: Moshi properties should be immutable Severity : Warning Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MoshiUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MoshiUsageDetectorTest.kt) Copyright Year @@ -50,7 +50,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/model/Example.kt:6:Warning: Moshi properties should be immutable. [MoshiUsageVarProperty] - data class Example(var value: String) --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MotionLayoutInvalidSceneFileReference.md.html b/docs/checks/MotionLayoutInvalidSceneFileReference.md.html index 1d103ea..f9c335a 100644 --- a/docs/checks/MotionLayoutInvalidSceneFileReference.md.html +++ b/docs/checks/MotionLayoutInvalidSceneFileReference.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/motion_test.xml:5:Error: The motion scene file: @xml/motion_scene doesn't exist [MotionLayoutInvalidSceneFileReference] - app:layoutDescription="@xml/motion_scene" ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MotionLayoutMissingId.md.html b/docs/checks/MotionLayoutMissingId.md.html index 9c8ccfd..a59c7e4 100644 --- a/docs/checks/MotionLayoutMissingId.md.html +++ b/docs/checks/MotionLayoutMissingId.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/motion_test.xml:9:Error: Views inside MotionLayout require an android:id attribute [MotionLayoutMissingId] - <View ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MotionSceneFileValidationError.md.html b/docs/checks/MotionSceneFileValidationError.md.html index 6be13d6..117d1bd 100644 --- a/docs/checks/MotionSceneFileValidationError.md.html +++ b/docs/checks/MotionSceneFileValidationError.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/missing_custom_attribute_name.xml:7:Error: attributeName should be defined [MotionSceneFileValidationError] - <CustomAttribute app:customPixelDimension="2sp"/> --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MultipleAwaitPointerEventScopes.md.html b/docs/checks/MultipleAwaitPointerEventScopes.md.html index bf62022..11c810b 100644 --- a/docs/checks/MultipleAwaitPointerEventScopes.md.html +++ b/docs/checks/MultipleAwaitPointerEventScopes.md.html @@ -52,17 +52,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -70,7 +70,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/MultipleUsesSdk.md.html b/docs/checks/MultipleUsesSdk.md.html index 8b871b5..bbb6052 100644 --- a/docs/checks/MultipleUsesSdk.md.html +++ b/docs/checks/MultipleUsesSdk.md.html @@ -45,12 +45,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:7:Error: There should only be a single element in the manifest: merge these together [MultipleUsesSdk] - <uses-sdk android:targetSdkVersion="14" /> -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -80,6 +79,40 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Home --> + <string name="home_title">Home Sample</string> + <string name="show_all_apps">All</string> + + <!-- Home Menus --> + <string name="menu_wallpaper">Wallpaper</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + <string name="sample" translatable="false">Ignore Me</string> + + <!-- Wallpaper --> + <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ManifestDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/MustBeInModule.md.html b/docs/checks/MustBeInModule.md.html index a93c8a9..b734264 100644 --- a/docs/checks/MustBeInModule.md.html +++ b/docs/checks/MustBeInModule.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -48,28 +48,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyModule.kt:7:Error: @Binds/@Provides functions must be in modules [MustBeInModule] - @Binds fun invalidBind(real: Int): Number ----------------------------------------- - - src/foo/MyModule.kt:10:Error: @Binds/@Provides functions must be in modules [MustBeInModule] - @Provides fun invalidBind(): Int = 3 ------------------------------------ - - src/foo/MyModule.kt:15:Error: @Binds/@Provides functions must be in modules [MustBeInModule] - @Binds abstract fun invalidBind(real: Int): Number -------------------------------------------------- - - src/foo/MyModule.kt:18:Error: @Binds/@Provides functions must be in modules [MustBeInModule] - @Provides fun invalidBind(): Int = 3 ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MustUseNamedParams.md.html b/docs/checks/MustUseNamedParams.md.html index e9bfbeb..a84d198 100644 --- a/docs/checks/MustUseNamedParams.md.html +++ b/docs/checks/MustUseNamedParams.md.html @@ -1,13 +1,13 @@ -(#) Calls to @MustUseNamedParams-annotated methods must name all parameters. +(#) Calls to @MustUseNamedParams-annotated methods must name all parameters -!!! ERROR: Calls to @MustUseNamedParams-annotated methods must name all parameters. +!!! ERROR: Calls to @MustUseNamedParams-annotated methods must name all parameters This is an error. Id : `MustUseNamedParams` Summary -: Calls to @MustUseNamedParams-annotated methods must name all parameters. +: Calls to @MustUseNamedParams-annotated methods must name all parameters Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/MustUseNamedParamsDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/MustUseNamedParamsDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/MustUseNamedParamsDetectorTest.kt) Copyright Year @@ -49,7 +49,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/TestFile.kt:16:Error: Calls to @MustUseNamedParams-annotated methods must name all parameters. [MustUseNamedParams] - methodWithAnnotation("Zac") --------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/MutableCollectionMutableState.md.html b/docs/checks/MutableCollectionMutableState.md.html index fc985a3..d698dfb 100644 --- a/docs/checks/MutableCollectionMutableState.md.html +++ b/docs/checks/MutableCollectionMutableState.md.html @@ -52,70 +52,42 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:12:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val listProperty = mutableStateOf(list) -------------- - - src/test/test.kt:14:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val setFunction = mutableStateOf(mutableSetOf(1)) -------------- - - src/test/test.kt:15:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val setProperty = mutableStateOf(set) -------------- - - src/test/test.kt:17:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val mapFunction = mutableStateOf(mutableMapOf(1 to 1)) -------------- - - src/test/test.kt:18:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val mapProperty = mutableStateOf(map) -------------- - - src/test/test.kt:20:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val collectionProperty = mutableStateOf(collection) -------------- - - src/test/test.kt:28:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val listParameter = mutableStateOf(listParam) -------------- - - src/test/test.kt:29:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val setParameter = mutableStateOf(setParam) -------------- - - src/test/test.kt:30:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val mapParameter = mutableStateOf(mapParam) -------------- - - src/test/test.kt:31:Warning: Creating a MutableState object with a mutable collection type [MutableCollectionMutableState] - val collectionProperty = mutableStateOf(collectionParam) -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -174,17 +146,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -192,7 +164,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/MutableImplicitPendingIntent.md.html b/docs/checks/MutableImplicitPendingIntent.md.html index 244cc22..84d2f35 100644 --- a/docs/checks/MutableImplicitPendingIntent.md.html +++ b/docs/checks/MutableImplicitPendingIntent.md.html @@ -40,6 +40,114 @@ !!! Tip This lint check has an associated quickfix available in the IDE. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/test/pkg/PendingIntentJavaTest.java:10:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getActivity(null, 0, new Intent(), PendingIntent.FLAG_MUTABLE); + ---------------------------------------------------------------------------- +src/test/pkg/PendingIntentJavaTest.java:11:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getBroadcast(null, 0, new Intent("TEST"), PendingIntent.FLAG_MUTABLE); + ----------------------------------------------------------------------------------- +src/test/pkg/PendingIntentJavaTest.java:13:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getService(null, 0, mIntent, PendingIntent.FLAG_MUTABLE); + ---------------------------------------------------------------------- +src/test/pkg/PendingIntentJavaTest.java:14:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getActivities(null, 0, { new Intent(), mIntent }, PendingIntent.FLAG_MUTABLE); + ------------------------------------------------------------------------------------------- +src/test/pkg/PendingIntentKotlinTest.kt:10:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getActivity(null, 0, Intent(), PendingIntent.FLAG_MUTABLE) + ------------------------------------------------------------------------ +src/test/pkg/PendingIntentKotlinTest.kt:11:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getBroadcast(null, 0, Intent("TEST"), PendingIntent.FLAG_MUTABLE) + ------------------------------------------------------------------------------- +src/test/pkg/PendingIntentKotlinTest.kt:13:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getService(null, 0, mIntent, PendingIntent.FLAG_MUTABLE) + ---------------------------------------------------------------------- +src/test/pkg/PendingIntentKotlinTest.kt:14:Error: Mutable implicit +PendingIntent will throw an exception, follow either of these +recommendations: for an existing PendingIntent use FLAG_NO_CREATE and +for a new PendingIntent either make it immutable or make the Intent +within explicit [MutableImplicitPendingIntent] + PendingIntent.getActivities(null, 0, listOf(Intent(), mIntent), PendingIntent.FLAG_MUTABLE) + ------------------------------------------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`src/test/pkg/PendingIntentJavaTest.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.PendingIntent; +import android.content.Intent; +import android.net.Uri; + +public class PendingIntentJavaTest { + Uri mUri; + protected void test() { + PendingIntent.getActivity(null, 0, new Intent(), PendingIntent.FLAG_MUTABLE); + PendingIntent.getBroadcast(null, 0, new Intent("TEST"), PendingIntent.FLAG_MUTABLE); + Intent mIntent = new Intent("TEST", mUri); + PendingIntent.getService(null, 0, mIntent, PendingIntent.FLAG_MUTABLE); + PendingIntent.getActivities(null, 0, { new Intent(), mIntent }, PendingIntent.FLAG_MUTABLE); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/PendingIntentKotlinTest.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.app.PendingIntent +import android.content.Intent +import android.net.Uri + +class PendingIntentKotlinTest { + val mUri: Uri + fun test() { + PendingIntent.getActivity(null, 0, Intent(), PendingIntent.FLAG_MUTABLE) + PendingIntent.getBroadcast(null, 0, Intent("TEST"), PendingIntent.FLAG_MUTABLE) + val mIntent = Intent("TEST", mUri) + PendingIntent.getService(null, 0, mIntent, PendingIntent.FLAG_MUTABLE) + PendingIntent.getActivities(null, 0, listOf(Intent(), mIntent), PendingIntent.FLAG_MUTABLE) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/PendingIntentMutableImplicitDetectorTest.kt) +for the unit tests for this check to see additional scenarios. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/MutatingSharedPrefs.md.html b/docs/checks/MutatingSharedPrefs.md.html index c109f63..d225b4a 100644 --- a/docs/checks/MutatingSharedPrefs.md.html +++ b/docs/checks/MutatingSharedPrefs.md.html @@ -42,14 +42,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/test.kt:11:Warning: Do not modify the set returned by SharedPreferences.getStringSet()` [MutatingSharedPrefs] - s.removeIf { it.length < 3 } ---------------------------- - - src/test/pkg/test.kt:12:Warning: Do not modify the set returned by SharedPreferences.getStringSet()` [MutatingSharedPrefs] - s.add("error") -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NamespaceTypo.md.html b/docs/checks/NamespaceTypo.md.html index 4267544..be5e952 100644 --- a/docs/checks/NamespaceTypo.md.html +++ b/docs/checks/NamespaceTypo.md.html @@ -45,7 +45,6 @@ res/layout/wrong_namespace.xml:2:Error: Unexpected namespace URI bound to the "android" prefix, was http://schemas.android.com/apk/res/andriod, expected http://schemas.android.com/apk/res/android [NamespaceTypo] - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andriod" ------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NamingPattern.md.html b/docs/checks/NamingPattern.md.html index bfe231c..24eee09 100644 --- a/docs/checks/NamingPattern.md.html +++ b/docs/checks/NamingPattern.md.html @@ -1,13 +1,13 @@ -(#) Names should be well named. +(#) Names should be well named -!!! WARNING: Names should be well named. +!!! WARNING: Names should be well named This is a warning. Id : `NamingPattern` Summary -: Names should be well named. +: Names should be well named Severity : Warning Category @@ -29,12 +29,48 @@ : 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/kotlin/com/vanniktech/lintrules/android/NamingPatternDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/NamingPatternDetectorTest.kt) Sometimes there is more than one reasonable way to convert an English phrase into camel case, such as when acronyms or unusual constructs like "IPv6" or "iOS" are present. XML HTTP request becomes XmlHttpRequest. XMLHTTPRequest would be incorrect. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Foo.java:5:Warning: iOSVersion is not named in defined camel +case [NamingPattern] + String iOSVersion; + ---------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Foo.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +class Foo { + private void fun() { + String iOSVersion; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/NamingPatternDetectorTest.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, `NamingPatternDetector.incorrectVariableName`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/NegativeMargin.md.html b/docs/checks/NegativeMargin.md.html index 13cdf5a..c6f6958 100644 --- a/docs/checks/NegativeMargin.md.html +++ b/docs/checks/NegativeMargin.md.html @@ -46,7 +46,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/negative_margins.xml:11:Warning: Margin values should not be negative [NegativeMargin] - <TextView android:layout_marginTop="-1dp"/> <!-- WARNING --> ------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NestedScrolling.md.html b/docs/checks/NestedScrolling.md.html index 90e7a42..2903524 100644 --- a/docs/checks/NestedScrolling.md.html +++ b/docs/checks/NestedScrolling.md.html @@ -39,7 +39,6 @@ res/layout/scrolling.xml:11:Warning: The vertically scrolling ScrollView should not contain another vertically scrolling widget (ListView) [NestedScrolling] - <ListView -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NestedWeights.md.html b/docs/checks/NestedWeights.md.html index dc6014d..524e169 100644 --- a/docs/checks/NestedWeights.md.html +++ b/docs/checks/NestedWeights.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/nested_weights.xml:23:Warning: Nested weights are bad for performance [NestedWeights] - android:layout_weight="1" ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NetworkSecurityConfig.md.html b/docs/checks/NetworkSecurityConfig.md.html index 8ced687..dde1e85 100644 --- a/docs/checks/NetworkSecurityConfig.md.html +++ b/docs/checks/NetworkSecurityConfig.md.html @@ -46,21 +46,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/network_config.xml:4:Error: Unexpected element [NetworkSecurityConfig] - <include domain="file"/> ------- - - res/xml/network_config.xml:7:Error: Nested elements are not allowed in base-config [NetworkSecurityConfig] - <domain-config> ------------- - - res/xml/network_config.xml:12:Error: No elements in [NetworkSecurityConfig] - <domain-config> ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NewApi.md.html b/docs/checks/NewApi.md.html index 9c5ba2a..24b54cc 100644 --- a/docs/checks/NewApi.md.html +++ b/docs/checks/NewApi.md.html @@ -63,7 +63,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test.kt:6:Error: Call requires API level 23 (current min is 21): android.net.ConnectivityManager#getActiveNetwork [NewApi] - val network = cm.activeNetwork // Error: Requires API 23 ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NewerVersionAvailable.md.html b/docs/checks/NewerVersionAvailable.md.html index 6502477..11dbc93 100644 --- a/docs/checks/NewerVersionAvailable.md.html +++ b/docs/checks/NewerVersionAvailable.md.html @@ -45,50 +45,48 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -build.gradle:8:Warning: A newer version of com.google.guava:guava than -24.1-android is available: 30.1-android [NewerVersionAvailable] - - compile 'com.google.guava:guava:24.1-android' - ------------------------------------- - - -build.gradle:9:Warning: A newer version of com.google.guava:guava than -24.1-jre is available: 30.1-jre [NewerVersionAvailable] - - compile 'com.google.guava:guava:24.1-jre' - --------------------------------- - - -build.gradle:10:Warning: A newer version of com.google.guava:guava than -16.0-rc1 is available: 30.1-android [NewerVersionAvailable] - - compile 'com.google.guava:guava:16.0-rc1' - --------------------------------- - - -build.gradle:11:Warning: A newer version of com.google.guava:guava than -16.0 is available: 30.1-android [NewerVersionAvailable] - - compile 'com.google.guava:guava:16.0' - ----------------------------- +../gradle/libs.versions.toml:12:Warning: A newer version of +com.autonomousapps.dependency-analysis than 1.0.0 is available: 1.20.0 +[NewerVersionAvailable] +gradlePlugins-dependency-analysis = "1.0.0" + ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`build.gradle`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers -apply plugin: 'com.android.application' - -android { - compileSdkVersion 29 -} - -dependencies { - compile 'com.google.guava:guava:24.1-android' - compile 'com.google.guava:guava:24.1-jre' - compile 'com.google.guava:guava:16.0-rc1' - compile 'com.google.guava:guava:16.0' -} +`../gradle/libs.versions.toml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~toml linenumbers +[versions] +guavaVersion = "11.0.2" +appCompatVersion="13.0.0" +wearableVersion=" 1.2.0 " +# Test comment suppression: +#noinspection GradleDependency +multi-dex="1.0.0" +gradlePlugins-agp = "8.0.0" +gradlePlugins-agp-alpha = "8.1.0-alpha01" +gradlePlugins-agp-dev = "8.2.0-dev" +gradlePlugins-crashlytics = "2.9.2" +gradlePlugins-dependency-analysis = "1.0.0" + +[libraries] +com-google-guava = { module = "com.google.guava:guava", version.ref = "guavaVersion"} +appcompat = { module = "com.android.support:appcompat-v7", version.ref = "appCompatVersion" } +wearable-support = { group = " com.google.android.support ", name =" wearable ", version.ref = " wearableVersion " } +multidex-lib = { module = "com.android.support:multidex", version.ref = "multi-dex" } + +[bundles] +misc = [ + "com-google-guava", + "appcompat", +] + +[plugins] +android-application = { id = "com.android.application", version.ref = "gradlePlugins-agp" } +android-application2 = { id = "com.android.application", version.ref = "gradlePlugins-agp-alpha" } +android-application3 = { id = "com.android.application", version.ref = "gradlePlugins-agp-dev" } +crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "gradlePlugins-crashlytics" } +dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "gradlePlugins-dependency-analysis" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the @@ -96,7 +94,7 @@ 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, `GradleDetector.testGuavaVersionsAndroidVsJre`. +found for this lint check, `GradleDetector.testTomlVersionCatalogFile`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. diff --git a/docs/checks/NfcTechWhitespace.md.html b/docs/checks/NfcTechWhitespace.md.html index d34e61c..afbf135 100644 --- a/docs/checks/NfcTechWhitespace.md.html +++ b/docs/checks/NfcTechWhitespace.md.html @@ -46,21 +46,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/nfc_tech_list_formatted.xml:6:Error: There should not be any whitespace inside elements [NfcTechWhitespace] - android.nfc.tech.NfcA --------------------- - - res/xml/nfc_tech_list_formatted.xml:12:Error: There should not be any whitespace inside elements [NfcTechWhitespace] - android.nfc.tech.MifareUltralight --------------------------------- - - res/xml/nfc_tech_list_formatted.xml:18:Error: There should not be any whitespace inside elements [NfcTechWhitespace] - android.nfc.tech.ndefformatable ------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NoCollectCallFound.md.html b/docs/checks/NoCollectCallFound.md.html index f60b1d0..846cb5a 100644 --- a/docs/checks/NoCollectCallFound.md.html +++ b/docs/checks/NoCollectCallFound.md.html @@ -50,49 +50,30 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/com/example/test.kt:9:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- - - src/com/example/test.kt:13:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- - - src/com/example/test.kt:17:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- - - src/com/example/test.kt:26:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- - - src/com/example/test.kt:29:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- - - src/com/example/test.kt:35:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- - - src/com/example/test.kt:39:Error: You must call collect() on Flow progress [NoCollectCallFound] - PredictiveBackHandler { progress -> } -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NoHardKeywords.md.html b/docs/checks/NoHardKeywords.md.html index ebe4ee8..286ef54 100644 --- a/docs/checks/NoHardKeywords.md.html +++ b/docs/checks/NoHardKeywords.md.html @@ -51,21 +51,17 @@ hard keywords ("fun"); see https://android.github.io/kotlin-guides/interop.html#no-hard-keywords [NoHardKeywords] - public void fun() { } --- - - src/test/pkg/Test.java:7:Warning: Avoid field names that are Kotlin hard keywords ("object"); see https://android.github.io/kotlin-guides/interop.html#no-hard-keywords [NoHardKeywords] - public Object object = null; ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/Test.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -79,6 +75,23 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/Keywords.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import org.json.JSONException; +import org.json.JSONStringer; + +@SuppressWarnings("ClassNameDiffersFromFileName") + public class Keywords extends JSONStringer { + // Using Kotlin hard keyword, but can't be helped; overrides library name + @Override + public JSONStringer object() throws JSONException { + return super.object(); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/InteroperabilityDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/NoOp.md.html b/docs/checks/NoOp.md.html index a63a243..941f5c1 100644 --- a/docs/checks/NoOp.md.html +++ b/docs/checks/NoOp.md.html @@ -64,19 +64,12 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/Test.kt:3:Warning: This reference is unused: s === o [NoOp] - s === o // ERROR 1 ------- - - src/Test.kt:4:Warning: This call result is unused: toString [NoOp] - o.toString() // ERROR 2 ------------ - - src/Test.kt:5:Warning: This reference is unused: length [NoOp] - s.length // ERROR 3 ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NonConstantResourceId.md.html b/docs/checks/NonConstantResourceId.md.html index 99ad669..e790ffb 100644 --- a/docs/checks/NonConstantResourceId.md.html +++ b/docs/checks/NonConstantResourceId.md.html @@ -43,15 +43,11 @@ src/test/pkg/SwitchTest.java:13:Warning: Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements [NonConstantResourceId] - case R.styleable.FontFamilyFont_android_fontWeight: someValue = 1; break; --------------------------------------------- - - src/test/pkg/SwitchTest.java:17:Warning: Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements [NonConstantResourceId] - case R.id.text: someValue = 3; break; --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NonResizeableActivity.md.html b/docs/checks/NonResizeableActivity.md.html index 8ac4aef..61442ad 100644 --- a/docs/checks/NonResizeableActivity.md.html +++ b/docs/checks/NonResizeableActivity.md.html @@ -50,7 +50,6 @@ advantage of the multi-window environment on all devices. NOTE: beginning with Android 12, all apps run in multi-window mode on large screen devices. [NonResizeableActivity] - <activity android:name=".MainActivity" android:resizeableActivity="false"/> ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NotConstructor.md.html b/docs/checks/NotConstructor.md.html index b41be27..02b8f64 100644 --- a/docs/checks/NotConstructor.md.html +++ b/docs/checks/NotConstructor.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/PnrUtils.java:4:Warning: Method PnrUtils looks like a constructor but is a normal method [NotConstructor] - public PnrUtils PnrUtils() { ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NotInterpolated.md.html b/docs/checks/NotInterpolated.md.html index 5ab2da0..9dc4d7a 100644 --- a/docs/checks/NotInterpolated.md.html +++ b/docs/checks/NotInterpolated.md.html @@ -44,7 +44,6 @@ build.gradle:5:Error: It looks like you are trying to substitute a version variable, but using single quotes ('). For Groovy string interpolation you must use double quotes ("). [NotInterpolated] - compile 'com.android.support:design:${supportLibVersion}' --------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NotSibling.md.html b/docs/checks/NotSibling.md.html index 157ed5d..1e99bcf 100644 --- a/docs/checks/NotSibling.md.html +++ b/docs/checks/NotSibling.md.html @@ -41,12 +41,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/layout1.xml:18:Error: @id/my_id1 is not a sibling in the same RelativeLayout [NotSibling] - android:layout_alignTop="@id/my_id1" ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/layout1.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -97,6 +96,33 @@ </RelativeLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/layout2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/my_id2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers + +<resources> + + <item name="my_id0" type="id"/> + <item name="my_id1" type="id"/> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/WrongIdDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/NotificationIconCompatibility.md.html b/docs/checks/NotificationIconCompatibility.md.html index 9755b49..3df0096 100644 --- a/docs/checks/NotificationIconCompatibility.md.html +++ b/docs/checks/NotificationIconCompatibility.md.html @@ -42,11 +42,53 @@ res/drawable/icon1.xml:Warning: Notification icon icon1 has to have a raster image to support Android versions below 5.0 (API 21) [NotificationIconCompatibility] - 0 errors, 1 warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/NotificationTest.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Notification; +import android.app.Notification.Builder; +import android.content.Context; +import android.graphics.Bitmap; + +@SuppressWarnings({ "deprecation", "unused", "javadoc" }) +class NotificationTest { + public void test1() { + Notification notification = new Notification(R.drawable.icon1, "Test1", 0); + } + + public void test2() { + int resource = R.drawable.icon2; + Notification notification = new Notification(resource, "Test1", 0); + } + + public void test3() { + int icon = R.drawable.icon3; + CharSequence tickerText = "Hello"; + long when = System.currentTimeMillis(); + Notification notification = new Notification(icon, tickerText, when); + } + + public void test4(Context context, String sender, String subject, Bitmap bitmap) { + Notification notification = new Notification.Builder(context) + .setContentTitle("New mail from " + sender.toString()) + .setContentText(subject).setSmallIcon(R.drawable.icon4) + .setLargeIcon(bitmap).build(); + } + + public void test5(Context context, String sender, String subject, Bitmap bitmap) { + Notification notification = new Builder(context) + .setContentTitle("New mail from " + sender.toString()) + .setContentText(subject).setSmallIcon(R.drawable.icon5) + .setLargeIcon(bitmap).build(); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/drawable/icon1.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -66,22 +108,6 @@ You can suppress false positives using one of the following mechanisms: -* Adding the suppression attribute - `tools:ignore="NotificationIconCompatibility"` 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 - <?xml version="1.0" encoding="UTF-8"?> - <manifest xmlns:tools="http://schemas.android.com/tools"> - ... - <application tools:ignore="NotificationIconCompatibility" .../> - ... - </manifest> - ``` - * Using a suppression annotation like this on the enclosing element: @@ -110,6 +136,22 @@ problematicStatement() ``` +* Adding the suppression attribute + `tools:ignore="NotificationIconCompatibility"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <application tools:ignore="NotificationIconCompatibility" .../> + ... + </manifest> + ``` + * 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: diff --git a/docs/checks/NotificationId0.md.html b/docs/checks/NotificationId0.md.html index 650b950..cb539c4 100644 --- a/docs/checks/NotificationId0.md.html +++ b/docs/checks/NotificationId0.md.html @@ -38,14 +38,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/ServiceTest.kt:13:Error: The notification id cannot be 0 [NotificationId0] - service.startForeground(0, notification) // ERROR 1: cannot be zero - - - src/test/pkg/ServiceTest.kt:14:Error: The notification id cannot be 0 [NotificationId0] - service.startForeground(MY_ID, notification, 1) // ERROR 2: cannot be zero ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NotificationPermission.md.html b/docs/checks/NotificationPermission.md.html index 3d4dfab..4cbcff6 100644 --- a/docs/checks/NotificationPermission.md.html +++ b/docs/checks/NotificationPermission.md.html @@ -39,7 +39,6 @@ src/test/pkg/NotificationTestAndroidx.java:21:Error: When targeting Android 13 or higher, posting a permission requires holding the POST_NOTIFICATIONS permission [NotificationPermission] - notificationManager.notify(id, notification); -------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NotificationTrampoline.md.html b/docs/checks/NotificationTrampoline.md.html index f07258c..d0a5c12 100644 --- a/docs/checks/NotificationTrampoline.md.html +++ b/docs/checks/NotificationTrampoline.md.html @@ -44,21 +44,37 @@ BroadcastReceiver (BroadcastTrampoline) which launches activities; this indirection is bad for performance, and activities should be launched directly from the notification [NotificationTrampoline] - .setContentIntent(notificationPendingIntent) ------------------------------------------- - - src/test/pkg/NotificationTest.java:38:Error: This intent launches a BroadcastReceiver (BroadcastTrampoline) which launches activities; this indirection is bad for performance, and activities should be launched directly from the notification [NotificationTrampoline] - .addAction(android.R.drawable.ic_dialog_email, "Launch Receiver From Action", ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/BroadcastTrampoline.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class BroadcastTrampoline extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + // The start below will be blocked + Intent i = new Intent(); + i.setClassName("test.pkg", "test.pkg.SecondActivity"); + i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(i); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/NotificationTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/NotifyDataSetChanged.md.html b/docs/checks/NotifyDataSetChanged.md.html index 27e37ad..71002ce 100644 --- a/docs/checks/NotifyDataSetChanged.md.html +++ b/docs/checks/NotifyDataSetChanged.md.html @@ -42,7 +42,6 @@ src/test/pkg/RecyclerViewTest.java:24:Warning: It will always be more efficient to use more specific change events if you can. Rely on notifyDataSetChanged as a last resort. [NotifyDataSetChanged] - notifyDataSetChanged(); ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/NullSafeMutableLiveData-2.md.html b/docs/checks/NullSafeMutableLiveData-2.md.html index 6360291..42903c6 100644 --- a/docs/checks/NullSafeMutableLiveData-2.md.html +++ b/docs/checks/NullSafeMutableLiveData-2.md.html @@ -34,9 +34,9 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-ktx-lint/src/main/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetector.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-lint/src/main/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetector.kt) Tests -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-ktx-lint/src/test/java/androidx/lifecycle/livedata/core/lint/NonNullableMutableLiveDataDetectorTest.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-lint/src/test/java/androidx/lifecycle/livedata/core/lint/NonNullableMutableLiveDataDetectorTest.kt) Copyright Year : 2019 diff --git a/docs/checks/NullSafeMutableLiveData.md.html b/docs/checks/NullSafeMutableLiveData.md.html index ab7faf2..77eeda8 100644 --- a/docs/checks/NullSafeMutableLiveData.md.html +++ b/docs/checks/NullSafeMutableLiveData.md.html @@ -34,9 +34,9 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-ktx-lint/src/main/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetector.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-lint/src/main/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetector.kt) Tests -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-ktx-lint/src/test/java/androidx/lifecycle/livedata/core/lint/NonNullableMutableLiveDataDetectorTest.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-lint/src/test/java/androidx/lifecycle/livedata/core/lint/NonNullableMutableLiveDataDetectorTest.kt) Copyright Year : 2019 diff --git a/docs/checks/ObjectAnimatorBinding.md.html b/docs/checks/ObjectAnimatorBinding.md.html index 897b771..b2c5430 100644 --- a/docs/checks/ObjectAnimatorBinding.md.html +++ b/docs/checks/ObjectAnimatorBinding.md.html @@ -38,129 +38,38 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/main/java/test/pkg/AnimatorTest.java:21:Error: The setter for this +src/main/java/AnimationExample.java:9:Error: The setter for this property does not match the expected signature (public void setProp2(int arg) [ObjectAnimatorBinding] - - ObjectAnimator.ofInt(myObject, "prop2", 0, 1, 2, 5).start(); - ------- - - -src/main/java/test/pkg/AnimatorTest.java:24:Error: Could not find -property setter method setUnknown on test.pkg.AnimatorTest.MyObject -[ObjectAnimatorBinding] - - ObjectAnimator.ofInt(myObject, "unknown", 0, 1, 2, 5).start(); - --------- - - -src/main/java/test/pkg/AnimatorTest.java:27:Error: The setter for this -property (test.pkg.AnimatorTest.MyObject.setProp3) should not be static -[ObjectAnimatorBinding] - - ObjectAnimator.ofInt(myObject, "prop3", 0, 1, 2, 5).start(); - ------- - - -src/main/java/test/pkg/AnimatorTest.java:40:Error: Could not find -property setter method setAlpha2 on android.widget.Button -[ObjectAnimatorBinding] - - ObjectAnimator.ofArgb(button, "alpha2", 1, 5); // Missing - -------- + ObjectAnimator animator2 = ObjectAnimator.ofInt(myObject, "prop2", 0, 1, 2, 5); + ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -`src/main/java/test/pkg/AnimatorTest.java`: +`src/main/java/AnimationExample.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -package test.pkg; - - import android.animation.ObjectAnimator; -import android.animation.PropertyValuesHolder; -import androidx.annotation.Keep; -import android.view.View; -import android.widget.Button; -import android.animation.FloatEvaluator; -@SuppressWarnings("unused") -public class AnimatorTest { - public void testObjectAnimator(Button button) { +public class AnimationExample { + public void startAnimations() { Object myObject = new MyObject(); ObjectAnimator animator1 = ObjectAnimator.ofInt(myObject, "prop1", 0, 1, 2, 5); - animator1.setDuration(10); animator1.start(); - - // Incorrect type (float parameter) warning - ObjectAnimator.ofInt(myObject, "prop2", 0, 1, 2, 5).start(); - - // Missing method warning - ObjectAnimator.ofInt(myObject, "unknown", 0, 1, 2, 5).start(); - - // Static method warning - ObjectAnimator.ofInt(myObject, "prop3", 0, 1, 2, 5).start(); - - // OK: Already marked @Keep - ObjectAnimator.ofInt(myObject, "prop4", 0, 1, 2, 5).start(); - - // OK: multi int - ObjectAnimator.ofMultiInt(myObject, "prop4", new int[0][]).start(); - - // OK: multi int - ObjectAnimator.ofMultiFloat(myObject, "prop5", new float[0][]).start(); - - // View stuff - ObjectAnimator.ofFloat(button, "alpha", 1, 5); // TODO: Warn about better method?, e.g. button.animate().alpha(...) - ObjectAnimator.ofArgb(button, "alpha2", 1, 5); // Missing - } - - public void testPropertyHolder() { - Object myObject = new MyObject(); - - PropertyValuesHolder p1 = PropertyValuesHolder.ofInt("prop1", 50); - PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("prop2", 100f); - ObjectAnimator.ofPropertyValuesHolder(myObject, p1, p2).start(); - ObjectAnimator.ofPropertyValuesHolder(myObject, - PropertyValuesHolder.ofInt("prop1", 50), - PropertyValuesHolder.ofFloat("prop2", 100f)).start(); + ObjectAnimator animator2 = ObjectAnimator.ofInt(myObject, "prop2", 0, 1, 2, 5); + animator2.start(); } private static class MyObject { public void setProp1(int x) { + // Implementation here } private void setProp2(float x) { - } - - public static void setProp3(int x) { - } - - @Keep - public void setProp4(int[] x) { - } - - @Keep - public void setProp5(float[] x) { - } - - @Keep - public void setProp4(int x) { - } - - @Keep - public void setProp5(float x) { + // Implementation here } } - - public void testEvaluators() { - Object myObject = new MyObject(); - PropertyValuesHolder p1 = PropertyValuesHolder.ofObject("prop5", new FloatEvaluator()); - ObjectAnimator.ofPropertyValuesHolder(myObject, p1); - ObjectAnimator.ofObject(myObject, "prop5", new FloatEvaluator(), 1f, 2f); - } - } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -168,11 +77,6 @@ [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/ObjectAnimatorDetectorTest.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, `ObjectAnimatorDetector.testBasic`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/ObsoleteLayoutParam.md.html b/docs/checks/ObsoleteLayoutParam.md.html index 0d6b543..8e2b19d 100644 --- a/docs/checks/ObsoleteLayoutParam.md.html +++ b/docs/checks/ObsoleteLayoutParam.md.html @@ -44,49 +44,30 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/wrongparams.xml:11:Warning: Invalid layout param in a FrameLayout: layout_weight [ObsoleteLayoutParam] - android:layout_weight="1" ------------------------- - - res/layout/wrongparams.xml:23:Warning: Invalid layout param in a LinearLayout: layout_alignParentLeft [ObsoleteLayoutParam] - android:layout_alignParentLeft="true" ------------------------------------- - - res/layout/wrongparams.xml:24:Warning: Invalid layout param in a LinearLayout: layout_alignParentTop [ObsoleteLayoutParam] - android:layout_alignParentTop="true" ------------------------------------ - - res/layout/wrongparams.xml:33:Warning: Invalid layout param in a LinearLayout: layout_alignBottom [ObsoleteLayoutParam] - android:layout_alignBottom="@+id/button1" ----------------------------------------- - - res/layout/wrongparams.xml:34:Warning: Invalid layout param in a LinearLayout: layout_toRightOf [ObsoleteLayoutParam] - android:layout_toRightOf="@+id/button1" --------------------------------------- - - res/layout/wrongparams.xml:42:Warning: Invalid layout param in a LinearLayout: layout_alignLeft [ObsoleteLayoutParam] - android:layout_alignLeft="@+id/button1" --------------------------------------- - - res/layout/wrongparams.xml:43:Warning: Invalid layout param in a LinearLayout: layout_below [ObsoleteLayoutParam] - android:layout_below="@+id/button1" ----------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ObsoleteSdkInt.md.html b/docs/checks/ObsoleteSdkInt.md.html index 2e0c738..8c793bf 100644 --- a/docs/checks/ObsoleteSdkInt.md.html +++ b/docs/checks/ObsoleteSdkInt.md.html @@ -47,14 +47,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/ObsoleteSdkInt.kt:4:Warning: Unnecessary; SDK_INT is always >= 23 [ObsoleteSdkInt] - if (Build.VERSION.SDK_INT >= 21) { // UNNECESSARY, always true --------------------------- - - src/ObsoleteSdkInt.kt:7:Warning: Unnecessary; SDK_INT is never < 23 [ObsoleteSdkInt] - if (Build.VERSION.SDK_INT < 21) { // UNNECESSARY, never true -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/OldTargetApi.md.html b/docs/checks/OldTargetApi.md.html index ddc5c62..9a61f67 100644 --- a/docs/checks/OldTargetApi.md.html +++ b/docs/checks/OldTargetApi.md.html @@ -59,7 +59,6 @@ Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details. [OldTargetApi] - <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="33" /> ----------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/OnClick.md.html b/docs/checks/OnClick.md.html index 60d3066..13f42c4 100644 --- a/docs/checks/OnClick.md.html +++ b/docs/checks/OnClick.md.html @@ -43,69 +43,44 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/onclick.xml:10:Error: Corresponding method handler 'public void nonexistent(android.view.View)' not found [OnClick] - android:onClick="nonexistent" ----------------------------- - - res/layout/onclick.xml:16:Error: Corresponding method handler 'public void wrong1(android.view.View)' not found [OnClick] - android:onClick="wrong1" ------------------------ - - res/layout/onclick.xml:22:Error: Corresponding method handler 'public void wrong2(android.view.View)' not found [OnClick] - android:onClick="wrong2" ------------------------ - - res/layout/onclick.xml:28:Error: Corresponding method handler 'public void wrong3(android.view.View)' not found [OnClick] - android:onClick="wrong3" ------------------------ - - res/layout/onclick.xml:58:Error: Corresponding method handler 'public void simple_typo(android.view.View)' not found (did you mean OnClickActivity#simple_tyop ?) [OnClick] - android:onClick="simple_typo" ----------------------------- - - res/layout/onclick.xml:82:Error: onClick handler method name cannot start with the character '1' [OnClick] - android:onClick="1invalidname" ------------ - - res/layout/onclick.xml:88:Error: There should be no spaces in the onClick handler name [OnClick] - android:onClick="invalid name" ------------ - - res/layout/onclick.xml:94:Error: onClick handler method name cannot contain the character '(' [OnClick] - android:onClick="invalidname()" ------------- - - res/layout/onclick.xml:100:Error: onClick handler method name cannot be a Java keyword [OnClick] - android:onClick="new" --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `res/layout/onclick.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -214,6 +189,58 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/OnClickActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; +import android.util.Log; +import android.view.View; + +/** Test data for the OnClickDetector */ +public class OnClickActivity extends Activity { + // Wrong argument type 1 + public void wrong1() { + } + + // Wrong argument type 2 + public void wrong2(int i) { + } + + // Wrong argument type 3 + public void wrong3(View view, int i) { + } + + // Return type is allowed to not be void + public int ok2(View view) { + return 0; + } + + // Wrong modifier (not public) + void wrong5(View view) { + } + + // Wrong modifier (is static) + public static void wrong6(View view) { + } + + public void ok(View view) { + } + + // Ok: Unicode escapes + public void myሴmethod(View view) { + } + + // Typo + public void simple_tyop(View view) { + } + + void wrong7(View view) { + Log.i("x", "wrong7: called"); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/OnClickDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/OpaqueUnitKey.md.html b/docs/checks/OpaqueUnitKey.md.html index 05fd834..ead1b8d 100644 --- a/docs/checks/OpaqueUnitKey.md.html +++ b/docs/checks/OpaqueUnitKey.md.html @@ -61,7 +61,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/test.kt:10:Warning: Implicitly passing Unit as argument to key1 [OpaqueUnitKey] - val x = remember(unitProperty) { listOf(1, 2, 3) } ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -99,17 +98,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -117,7 +116,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/OpenForTesting.md.html b/docs/checks/OpenForTesting.md.html index f3d7426..0250af5 100644 --- a/docs/checks/OpenForTesting.md.html +++ b/docs/checks/OpenForTesting.md.html @@ -38,21 +38,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/Builder1.kt:10:Error: Builder1 should only be subclassed from tests [OpenForTesting] - class MyBuilder1 : Builder1() { // ERROR 1 -------- - - src/test/pkg/Builder1.kt:22:Error: Builder2.someMethod should only be overridden from tests [OpenForTesting] - override fun someMethod(arg: Int) { } // ERROR 2 ---------- - - src/test/pkg/MyBuilder3.java:2:Error: Builder1 should only be subclassed from tests [OpenForTesting] - class MyBuilder3 extends Builder1 { // ERROR 3 -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Orientation.md.html b/docs/checks/Orientation.md.html index 416c171..a77858e 100644 --- a/docs/checks/Orientation.md.html +++ b/docs/checks/Orientation.md.html @@ -52,7 +52,6 @@ orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width="match_parent" [Orientation] - <LinearLayout ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/OutdatedLibrary.md.html b/docs/checks/OutdatedLibrary.md.html index ae92231..c125fe3 100644 --- a/docs/checks/OutdatedLibrary.md.html +++ b/docs/checks/OutdatedLibrary.md.html @@ -48,11 +48,8 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:5:Warning: log4j:log4j version 1.2.15 has been reported as outdated by its author [OutdatedLibrary] - compile 'log4j:log4j:1.2.15' // Outdated NON_BLOCKING -------------------- - - build.gradle:8:Error: [Prevents app release in Google Play Console] log4j:log4j version 1.2.12 has been reported as outdated by its author and will block publishing of your app to Play Console. @@ -62,14 +59,10 @@ These versions have not been reviewed by Google Play. They could contain vulnerabilities or policy violations. Carefully evaluate any third-party SDKs before integrating them into your app. [OutdatedLibrary] - compile 'log4j:log4j:1.2.12' // OUTDATED BLOCKING -------------------- - - build.gradle:13:Warning: com.example.ads.third.party:example version 7.2.0 has been reported as outdated by its author [OutdatedLibrary] - compile 'com.example.ads.third.party:example:7.2.0' // Outdated + Critical + Policy (multiple issues), no severity ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Overdraw.md.html b/docs/checks/Overdraw.md.html index 4866d04..1ac20e1 100644 --- a/docs/checks/Overdraw.md.html +++ b/docs/checks/Overdraw.md.html @@ -57,12 +57,71 @@ res/layout/sixth.xml:4:Warning: Possible overdraw: Root element paints background @drawable/custombg with a theme that also paints a background (inferred theme is @style/MyTheme) [Overdraw] - android:background="@drawable/custombg" --------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="test.pkg" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="10" /> + + <application + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/MyTheme" > + <activity + android:name=".OverdrawActivity" + android:label="@string/app_name" + android:theme="@style/MyTheme.First" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name=".SecondActivity" + android:label="@string/app_name" > + </activity> + <activity + android:name=".ThirdActivity" + android:label="@string/app_name" > + </activity> + <activity + android:name="test.pkg.FourthActivity" + android:label="@string/app_name" + android:theme="@style/MyTheme.Fourth" > + </activity> + </application> + +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/drawable/custombg.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<bitmap + xmlns:android="http://schemas.android.com/apk/res/android" + android:src="@drawable/ic_launcher" + android:tileMode="clamp" /> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/drawable/custombg2.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:drawable="@drawable/ic_launcher" /> +</selector> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/layout/sixth.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -81,6 +140,200 @@ </LinearLayout> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/fifth.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@drawable/custombg2" + android:orientation="vertical" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/fourth.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@drawable/ic_launcher" + android:orientation="vertical" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/main.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@drawable/ic_launcher" + android:orientation="vertical" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/second.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@drawable/ic_launcher" + android:orientation="vertical" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/layout/third.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@drawable/ic_launcher" + android:orientation="vertical" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="hello">Hello World, OverdrawActivity!</string> + <string name="app_name">Overdraw</string> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`res/values/styles.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <style name="MyTheme" parent="@android:style/Theme.Light"> + <item name="android:windowBackground">@drawable/ic_launcher</item> + </style> + + <style name="MyTheme.First"> + <item name="android:textColor">#ff00ff00</item> + </style> + + <style name="MyTheme.Second"> + <item name="android:windowIsTranslucent">true</item> + </style> + + <style name="MyTheme.Third"> + <item name="android:textColor">#ff000000</item> + </style> + + <style name="MyTheme.Fourth"> + <item name="android:windowBackground">@null</item> + <item name="android:textColor">#ff000000</item> + </style> + +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/FourthActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; +import android.os.Bundle; + +public class FourthActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fourth); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/OverdrawActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; +import android.os.Bundle; + +public class OverdrawActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/SecondActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; +import android.os.Bundle; + +public class SecondActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.second); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/ThirdActivity.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; +import android.os.Bundle; + +public class ThirdActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setTheme(R.style.MyTheme_Third); + setContentView(R.layout.third); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/OverdrawDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/OverrideAbstract.md.html b/docs/checks/OverrideAbstract.md.html index 7f15e7c..c4b13a1 100644 --- a/docs/checks/OverrideAbstract.md.html +++ b/docs/checks/OverrideAbstract.md.html @@ -47,34 +47,24 @@ android.service.notification.NotificationListenerService.onNotificationPosted(android.service.notification.StatusBarNotification): Method was abstract until 21, and your minSdkVersion is 18 [OverrideAbstract] - private static class MyNotificationListenerService2 extends NotificationListenerService { ------------------------------ - - src/test/pkg/OverrideConcreteTest.java:30:Error: Must override android.service.notification.NotificationListenerService.onNotificationRemoved(android.service.notification.StatusBarNotification): Method was abstract until 21, and your minSdkVersion is 18 [OverrideAbstract] - private static class MyNotificationListenerService3 extends NotificationListenerService { ------------------------------ - - src/test/pkg/OverrideConcreteTest.java:37:Error: Must override android.service.notification.NotificationListenerService.onNotificationPosted(android.service.notification.StatusBarNotification): Method was abstract until 21, and your minSdkVersion is 18 [OverrideAbstract] - private static class MyNotificationListenerService4 extends NotificationListenerService { ------------------------------ - - src/test/pkg/OverrideConcreteTest.java:57:Error: Must override android.service.notification.NotificationListenerService.onNotificationRemoved(android.service.notification.StatusBarNotification): Method was abstract until 21, and your minSdkVersion is 18 [OverrideAbstract] - private static class MyNotificationListenerService7 extends MyNotificationListenerService3 { ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PackagedPrivateKey.md.html b/docs/checks/PackagedPrivateKey.md.html index db24232..59f0480 100644 --- a/docs/checks/PackagedPrivateKey.md.html +++ b/docs/checks/PackagedPrivateKey.md.html @@ -40,14 +40,13 @@ res/private_key.pem:Error: The res/private_key.pem file seems to be a private key file. Please make sure not to embed this in your APK file. [PackagedPrivateKey] - 1 errors, 0 warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `res/private_key.pem`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,77F426A58B274623 diff --git a/docs/checks/ParcelClassLoader.md.html b/docs/checks/ParcelClassLoader.md.html index 90c55d6..9f17dd9 100644 --- a/docs/checks/ParcelClassLoader.md.html +++ b/docs/checks/ParcelClassLoader.md.html @@ -52,79 +52,54 @@ the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - Parcelable error1 = in.readParcelable(null); -------------------- - - src/test/pkg/ParcelableDemo.java:11:Warning: Passing null here (to use the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - Parcelable[] error2 = in.readParcelableArray(null); ------------------------- - - src/test/pkg/ParcelableDemo.java:12:Warning: Passing null here (to use the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - Bundle error3 = in.readBundle(null); ---------------- - - src/test/pkg/ParcelableDemo.java:13:Warning: Passing null here (to use the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - Object[] error4 = in.readArray(null); --------------- - - src/test/pkg/ParcelableDemo.java:14:Warning: Passing null here (to use the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - SparseArray error5 = in.readSparseArray(null); --------------------- - - src/test/pkg/ParcelableDemo.java:15:Warning: Passing null here (to use the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - Object error6 = in.readValue(null); --------------- - - src/test/pkg/ParcelableDemo.java:16:Warning: Passing null here (to use the default class loader) will not work if you are restoring your own classes. Consider using for example getClass().getClassLoader() instead. [ParcelClassLoader] - Parcelable error7 = in.readPersistableBundle(null); --------------------------- - - src/test/pkg/ParcelableDemo.java:17:Warning: Using the default class loader will not work if you are restoring your own classes. Consider using for example readBundle(getClass().getClassLoader()) instead. [ParcelClassLoader] - Bundle error8 = in.readBundle(); ------------ - - src/test/pkg/ParcelableDemo.java:18:Warning: Using the default class loader will not work if you are restoring your own classes. Consider using for example readPersistableBundle(getClass().getClassLoader()) instead. [ParcelClassLoader] - Parcelable error9 = in.readPersistableBundle(); ----------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ParcelCreator.md.html b/docs/checks/ParcelCreator.md.html index f5bd207..3154f32 100644 --- a/docs/checks/ParcelCreator.md.html +++ b/docs/checks/ParcelCreator.md.html @@ -45,12 +45,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/bytecode/MyParcelable1.java:6:Error: This class implements Parcelable but does not provide a CREATOR field [ParcelCreator] - public class MyParcelable1 implements Parcelable { ------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/bytecode/MyParcelable1.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -71,6 +70,87 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/bytecode/MyParcelable2.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.bytecode; + +import android.os.Parcel; +import android.os.Parcelable; + +public class MyParcelable2 implements Parcelable { + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public MyParcelable2 createFromParcel(Parcel in) { + return new MyParcelable2(); + } + + public MyParcelable2[] newArray(int size) { + return new MyParcelable2[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel arg0, int arg1) { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/bytecode/MyParcelable3.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.bytecode; + +import android.os.Parcel; +import android.os.Parcelable; + +public class MyParcelable3 implements Parcelable { + public static final int CREATOR = 0; // Wrong type + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel arg0, int arg1) { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/bytecode/MyParcelable4.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.bytecode; + +import android.os.Parcel; +import android.os.Parcelable; + +public abstract class MyParcelable4 implements Parcelable { + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel arg0, int arg1) { + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/bytecode/MyParcelable5.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.bytecode; + +import android.os.Parcelable; + +public interface MyParcelable5 extends Parcelable { + @Override + public int describeContents(); +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ParcelDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ParcelizeFunctionProperty.md.html b/docs/checks/ParcelizeFunctionProperty.md.html index 0e941a3..2229e22 100644 --- a/docs/checks/ParcelizeFunctionProperty.md.html +++ b/docs/checks/ParcelizeFunctionProperty.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/parcel/ParcelizeFunctionPropertyDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/parcel/ParcelizeFunctionPropertyDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/parcel/ParcelizeFunctionPropertyDetectorTest.kt) Copyright Year @@ -54,57 +54,41 @@ classes. There are only limited conditions where it will work and it's usually a sign that you're modeling your data wrong. [ParcelizeFunctionProperty] - val functionType1: () -> String, ------------ - - src/test/pkg/Example1.kt:13:Error: While technically (and surprisingly) supported by Parcelize, function types should not be used in Parcelize classes. There are only limited conditions where it will work and it's usually a sign that you're modeling your data wrong. [ParcelizeFunctionProperty] - val functionType2: (String) -> String, ------------------ - - src/test/pkg/Example1.kt:14:Error: While technically (and surprisingly) supported by Parcelize, function types should not be used in Parcelize classes. There are only limited conditions where it will work and it's usually a sign that you're modeling your data wrong. [ParcelizeFunctionProperty] - val functionType3: String.() -> String, ------------------- - - src/test/pkg/Example1.kt:15:Error: While technically (and surprisingly) supported by Parcelize, function types should not be used in Parcelize classes. There are only limited conditions where it will work and it's usually a sign that you're modeling your data wrong. [ParcelizeFunctionProperty] - val functionType4: () -> Unit, ---------- - - src/test/pkg/Example1.kt:16:Error: While technically (and surprisingly) supported by Parcelize, function types should not be used in Parcelize classes. There are only limited conditions where it will work and it's usually a sign that you're modeling your data wrong. [ParcelizeFunctionProperty] - val functionType5: suspend () -> Unit, ------------------ - - src/test/pkg/Example1.kt:17:Error: While technically (and surprisingly) supported by Parcelize, function types should not be used in Parcelize classes. There are only limited conditions where it will work and it's usually a sign that you're modeling your data wrong. [ParcelizeFunctionProperty] - val aliasedFunction: FunctionType, ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PendingBindings.md.html b/docs/checks/PendingBindings.md.html index 1541ff0..44fb4fe 100644 --- a/docs/checks/PendingBindings.md.html +++ b/docs/checks/PendingBindings.md.html @@ -44,47 +44,34 @@ exits, otherwise, the DataBinding library will update the UI in the next animation frame causing a delayed update & potential jumps if the item resizes. [PendingBindings] - holder.dataBinder.someMethod(); // ERROR - no pending call ------------------------------ - - src/test/pkg/RecyclerViewTest2.java:40:Error: You must call holder.dataBinder.executePendingBindings() before the onBind method exits, otherwise, the DataBinding library will update the UI in the next animation frame causing a delayed update & potential jumps if the item resizes. [PendingBindings] - holder.dataBinder.someMethod(); // ERROR: After call ------------------------------ - - src/test/pkg/RecyclerViewTest2.java:48:Error: You must call holder.dataBinder.executePendingBindings() before the onBind method exits, otherwise, the DataBinding library will update the UI in the next animation frame causing a delayed update & potential jumps if the item resizes. [PendingBindings] - holder.dataBinder.someMethod(); // ERROR: can't reach pending ------------------------------ - - src/test/pkg/RecyclerViewTest2.java:116:Error: You must call holder.dataBinder.executePendingBindings() before the onBind method exits, otherwise, the DataBinding library will update the UI in the next animation frame causing a delayed update & potential jumps if the item resizes. [PendingBindings] - holder.dataBinder.someMethod(); // ERROR ------------------------------ - - src/test/pkg/RecyclerViewTest2.java:139:Error: You must call holder.dataBinder.executePendingBindings() before the onBind method exits, otherwise, the DataBinding library will update the UI in the next animation frame causing a delayed update & potential jumps if the item resizes. [PendingBindings] - holder.dataBinder.someMethod(); // ERROR: no fallthrough ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PermissionImpliesUnsupportedChromeOsHardware.md.html b/docs/checks/PermissionImpliesUnsupportedChromeOsHardware.md.html index baa02e8..576bb2a 100644 --- a/docs/checks/PermissionImpliesUnsupportedChromeOsHardware.md.html +++ b/docs/checks/PermissionImpliesUnsupportedChromeOsHardware.md.html @@ -48,7 +48,6 @@ AndroidManifest.xml:4:Error: Permission exists without corresponding hardware tag [PermissionImpliesUnsupportedChromeOsHardware] - <uses-permission android:name="android.permission.CALL_PHONE"/> --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PermissionImpliesUnsupportedHardware.md.html b/docs/checks/PermissionImpliesUnsupportedHardware.md.html index c69404a..6fc352f 100644 --- a/docs/checks/PermissionImpliesUnsupportedHardware.md.html +++ b/docs/checks/PermissionImpliesUnsupportedHardware.md.html @@ -48,7 +48,6 @@ AndroidManifest.xml:5:Warning: Permission exists without corresponding hardware tag [PermissionImpliesUnsupportedHardware] - <uses-permission android:name="android.permission.CALL_PHONE"/> --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PermissionNamingConvention.md.html b/docs/checks/PermissionNamingConvention.md.html index 23881b7..d7cf81b 100644 --- a/docs/checks/PermissionNamingConvention.md.html +++ b/docs/checks/PermissionNamingConvention.md.html @@ -46,37 +46,24 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:7:Warning: com.example.helloworld.FOO_BAR does not follow recommended naming convention [PermissionNamingConvention] - <permission android:name="com.example.helloworld.FOO_BAR" /> ------------------------------ - - AndroidManifest.xml:8:Warning: com.example.helloworld.permission.FOO-BAR does not follow recommended naming convention [PermissionNamingConvention] - <permission android:name="com.example.helloworld.permission.FOO-BAR" /> ----------------------------------------- - - AndroidManifest.xml:9:Warning: com.example.helloworld.permission.foo_bar does not follow recommended naming convention [PermissionNamingConvention] - <permission android:name="com.example.helloworld.permission.foo_bar" /> ----------------------------------------- - - AndroidManifest.xml:10:Warning: android.permission.FOO_BAR does not follow recommended naming convention [PermissionNamingConvention] - <permission android:name="android.permission.FOO_BAR" /> -------------------------- - - AndroidManifest.xml:11:Warning: FOO_BAR does not follow recommended naming convention [PermissionNamingConvention] - <permission android:name="FOO_BAR" /> ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PictureInPictureIssue.md.html b/docs/checks/PictureInPictureIssue.md.html index 863fe47..376550f 100644 --- a/docs/checks/PictureInPictureIssue.md.html +++ b/docs/checks/PictureInPictureIssue.md.html @@ -45,7 +45,6 @@ picture-in-picture and the targetSdkVersion is 31 or above; it is therefore strongly recommended to call both setAutoEnterEnabled(true) and setSourceRectHint(...) [PictureInPictureIssue] - <application ----------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -84,7 +83,7 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`src/TestActivity.kt`: +`src/test/pkg/TestActivity.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers package test.pkg diff --git a/docs/checks/PinSetExpiry.md.html b/docs/checks/PinSetExpiry.md.html index a4251fe..ec4ff29 100644 --- a/docs/checks/PinSetExpiry.md.html +++ b/docs/checks/PinSetExpiry.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/xml/network_config.xml:6:Warning: pin-set is expiring soon [PinSetExpiry] - <pin-set expiration="%1$s"> ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PlaySdkIndexNonCompliant.md.html b/docs/checks/PlaySdkIndexNonCompliant.md.html index 521305c..649449b 100644 --- a/docs/checks/PlaySdkIndexNonCompliant.md.html +++ b/docs/checks/PlaySdkIndexNonCompliant.md.html @@ -41,99 +41,65 @@ build.gradle:6:Warning: log4j:log4j version 1.2.14 has policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'log4j:log4j:1.2.14' // Non compliant -------------------- - - build.gradle:13:Warning: com.example.ads.third.party:example version 7.2.0 has User Data policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.2.0' // Outdated + Critical + Policy (multiple issues), no severity ------------------------------------------- - - build.gradle:14:Warning: com.example.ads.third.party:example version 7.1.0 has Ads policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.0' // Policy (Ads), non-blocking ------------------------------------------- - - build.gradle:15:Error: [Prevents app release in Google Play Console] com.example.ads.third.party:example version 7.1.1 has Device and Network Abuse policy issues that will block publishing of your app to Play Console [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.1' // Policy (Device and Network Abuse), blocking ------------------------------------------- - - build.gradle:16:Warning: com.example.ads.third.party:example version 7.1.2 has Deceptive Behavior policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.2' // Policy (Deceptive Behavior), no severity ------------------------------------------- - - build.gradle:17:Warning: com.example.ads.third.party:example version 7.1.3 has User Data policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.3' // Policy (User Data), non-blocking ------------------------------------------- - - build.gradle:18:Error: [Prevents app release in Google Play Console] com.example.ads.third.party:example version 7.1.4 has Permissions policy issues that will block publishing of your app to Play Console [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.4' // Policy (Permissions), blocking ------------------------------------------- - - build.gradle:19:Warning: com.example.ads.third.party:example version 7.1.5 has Mobile Unwanted Software policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.5' // Policy (Mobile Unwanted Software), no-severity ------------------------------------------- - - build.gradle:20:Warning: com.example.ads.third.party:example version 7.1.6 has Malware policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.6' // Policy (Malware), non-blocking ------------------------------------------- - - build.gradle:21:Warning: com.example.ads.third.party:example version 7.1.7 has User Data policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.7' // Policy (multiple types), non-blocking ------------------------------------------- - - build.gradle:22:Error: [Prevents app release in Google Play Console] com.example.ads.third.party:example version 7.1.8 has User Data policy issues that will block publishing of your app to Play Console [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.8' // Policy (multiple types), blocking ------------------------------------------- - - build.gradle:23:Warning: com.example.ads.third.party:example version 7.1.9 has Permissions policy issues that will block publishing of your app to Play Console in the future [PlaySdkIndexNonCompliant] - compile 'com.example.ads.third.party:example:7.1.9' // Policy (multiple types), no severity ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PluralsCandidate.md.html b/docs/checks/PluralsCandidate.md.html index 35c51f0..3597b43 100644 --- a/docs/checks/PluralsCandidate.md.html +++ b/docs/checks/PluralsCandidate.md.html @@ -60,7 +60,6 @@ res/values/plurals_candidates.xml:4:Warning: Formatting %d followed by words ("times"): This should probably be a plural rather than a string [PluralsCandidate] - <string name="lockscreen_too_many_failed_attempts_dialog_message1"> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PrivateApi.md.html b/docs/checks/PrivateApi.md.html index f846856..f672ade 100644 --- a/docs/checks/PrivateApi.md.html +++ b/docs/checks/PrivateApi.md.html @@ -43,23 +43,16 @@ src/test/pkg/myapplication/ReflectionTest1.java:8:Warning: Accessing internal APIs via reflection is not supported and may not work on all devices or in the future [PrivateApi] - Class<?> c = Class.forName("com.android.internal.widget.LockPatternUtils"); // ERROR ------------------------------------------------------------- - - src/test/pkg/myapplication/ReflectionTest1.java:9:Warning: Accessing internal APIs via reflection is not supported and may not work on all devices or in the future [PrivateApi] - int titleContainerId = (Integer) Class.forName("com.android.internal.R{$}id").getField("title_container").get(null); -------------------------------------------- - - src/test/pkg/myapplication/ReflectionTest1.java:11:Warning: Accessing internal APIs via reflection is not supported and may not work on all devices or in the future [PrivateApi] - Class SystemProperties = cl.loadClass("android.os.SystemProperties"); ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PrivateResource.md.html b/docs/checks/PrivateResource.md.html index 1f53295..d106089 100644 --- a/docs/checks/PrivateResource.md.html +++ b/docs/checks/PrivateResource.md.html @@ -41,7 +41,6 @@ src/main/res/layout/private.xml:10:Warning: The resource @string/my_private_string is marked as private in com.android.tools:test-library:1.0.0 [PrivateResource] - android:text="@string/my_private_string" /> ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ProduceStateDoesNotAssignValue.md.html b/docs/checks/ProduceStateDoesNotAssignValue.md.html index 61b9e9a..fdcb397 100644 --- a/docs/checks/ProduceStateDoesNotAssignValue.md.html +++ b/docs/checks/ProduceStateDoesNotAssignValue.md.html @@ -51,31 +51,21 @@ src/androidx/compose/runtime/foo/test.kt:8:Error: produceState calls should assign value inside the producer lambda [ProduceStateDoesNotAssignValue] - produceState(true, true) { ------------ - - src/androidx/compose/runtime/foo/test.kt:12:Error: produceState calls should assign value inside the producer lambda [ProduceStateDoesNotAssignValue] - produceState(true, true) { ------------ - - src/androidx/compose/runtime/foo/test.kt:17:Error: produceState calls should assign value inside the producer lambda [ProduceStateDoesNotAssignValue] - produceState(true, true) { ------------ - - src/androidx/compose/runtime/foo/test.kt:21:Error: produceState calls should assign value inside the producer lambda [ProduceStateDoesNotAssignValue] - produceState(true, true) { ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -131,17 +121,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -149,7 +139,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/Proguard.md.html b/docs/checks/Proguard.md.html index cfb7f4a..a9a43d0 100644 --- a/docs/checks/Proguard.md.html +++ b/docs/checks/Proguard.md.html @@ -49,7 +49,6 @@ proguard.cfg:21:Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard] - -keepclasseswithmembernames class * { ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -57,7 +56,7 @@ Here is the source file referenced above: `proguard.cfg`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~proguard linenumbers -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses diff --git a/docs/checks/ProguardSplit.md.html b/docs/checks/ProguardSplit.md.html index 6ff32b0..3875fd4 100644 --- a/docs/checks/ProguardSplit.md.html +++ b/docs/checks/ProguardSplit.md.html @@ -65,15 +65,14 @@ project.properties to define proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:myfile.txt and then keep only project-specific configuration here [ProguardSplit] - -keep public class * extends android.app.Activity ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `myfile.txt`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses @@ -112,6 +111,13 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`project.properties`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~properties linenumbers +target=android-14 +proguard.config=${sdk.dir}/foo.cfg:${user.home}/bar.pro;myfile.txt + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ProguardDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/PropertyEscape.md.html b/docs/checks/PropertyEscape.md.html index e246acf..b412c36 100644 --- a/docs/checks/PropertyEscape.md.html +++ b/docs/checks/PropertyEscape.md.html @@ -44,16 +44,12 @@ local.properties:11:Error: Windows file separators (\) and drive letter separators (':') must be escaped (\\) in property files; use C\:\\my\\path\\to\\sdk [PropertyEscape] - windows.dir=C:\my\path\to\sdk -------------- - - local.properties:14:Error: Windows file separators (\) and drive letter separators (':') must be escaped (\\) in property files; use C\:\\Documents and Settings\\UserName\\Local Settings\\Application Data\\Android\\android-studio\\sdk [PropertyEscape] - ok.sdk.dir=C:\\Documents and Settings\\UserName\\Local Settings\\Application Data\\Android\\android-studio\\sdk - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -61,7 +57,7 @@ Here is the source file referenced above: `local.properties`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~properties linenumbers ## This file is automatically generated by Android Studio. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # diff --git a/docs/checks/ProtectedPermissions.md.html b/docs/checks/ProtectedPermissions.md.html index 44cebd7..e8bf805 100644 --- a/docs/checks/ProtectedPermissions.md.html +++ b/docs/checks/ProtectedPermissions.md.html @@ -37,613 +37,10 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -AndroidManifest.xml:15:Error: Permission is only granted to system apps +AndroidManifest.xml:13:Error: Permission is only granted to system apps [ProtectedPermissions] - - <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE" /> - -------------------------------------------------------------------------- - - -AndroidManifest.xml:16:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" /> - --------------------------------------------------------- - - -AndroidManifest.xml:17:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" /> - ----------------------------------------------------------- - - -AndroidManifest.xml:18:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ACCESS_MTP" /> - -------------------------------------------- - - -AndroidManifest.xml:19:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> - -------------------------------------------------------- - - -AndroidManifest.xml:20:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ACCOUNT_MANAGER" /> - ------------------------------------------------- - - -AndroidManifest.xml:21:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK" /> - -------------------------------------------------------------- - - -AndroidManifest.xml:22:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ASEC_ACCESS" /> - --------------------------------------------- - - -AndroidManifest.xml:23:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ASEC_CREATE" /> - --------------------------------------------- - - -AndroidManifest.xml:24:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ASEC_DESTROY" /> - ---------------------------------------------- - - -AndroidManifest.xml:25:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ASEC_MOUNT_UNMOUNT" /> - ---------------------------------------------------- - - -AndroidManifest.xml:26:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.ASEC_RENAME" /> - --------------------------------------------- - - -AndroidManifest.xml:27:Error: Permission is only granted to system apps -[ProtectedPermissions] - <uses-permission android:name="android.permission.BACKUP" /> ---------------------------------------- - - -AndroidManifest.xml:28:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_APPWIDGET" /> - ------------------------------------------------ - - -AndroidManifest.xml:29:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" /> - --------------------------------------------------- - - -AndroidManifest.xml:30:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_INPUT_METHOD" /> - --------------------------------------------------- - - -AndroidManifest.xml:31:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_PACKAGE_VERIFIER" /> - ------------------------------------------------------- - - -AndroidManifest.xml:32:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_REMOTEVIEWS" /> - -------------------------------------------------- - - -AndroidManifest.xml:33:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_TEXT_SERVICE" /> - --------------------------------------------------- - - -AndroidManifest.xml:34:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_VPN_SERVICE" /> - -------------------------------------------------- - - -AndroidManifest.xml:35:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_WALLPAPER" /> - ------------------------------------------------ - - -AndroidManifest.xml:36:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BRICK" /> - --------------------------------------- - - -AndroidManifest.xml:37:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" /> - ----------------------------------------------------------- - - -AndroidManifest.xml:38:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BROADCAST_SMS" /> - ----------------------------------------------- - - -AndroidManifest.xml:39:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BROADCAST_WAP_PUSH" /> - ---------------------------------------------------- - - -AndroidManifest.xml:40:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CALL_PRIVILEGED" /> - ------------------------------------------------- - - -AndroidManifest.xml:41:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CHANGE_BACKGROUND_DATA_SETTING" /> - ---------------------------------------------------------------- - - -AndroidManifest.xml:42:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> - ---------------------------------------------------------------- - - -AndroidManifest.xml:43:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" /> - ----------------------------------------------------- - - -AndroidManifest.xml:44:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP" /> - ----------------------------------------------------- - - -AndroidManifest.xml:45:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> - ------------------------------------------------------- - - -AndroidManifest.xml:46:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /> - ---------------------------------------------------------- - - -AndroidManifest.xml:47:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.COPY_PROTECTED_DATA" /> - ----------------------------------------------------- - - -AndroidManifest.xml:48:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.CRYPT_KEEPER" /> - ---------------------------------------------- - - -AndroidManifest.xml:49:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.DELETE_CACHE_FILES" /> - ---------------------------------------------------- - - -AndroidManifest.xml:50:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.DELETE_PACKAGES" /> - ------------------------------------------------- - - -AndroidManifest.xml:51:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.DEVICE_POWER" /> - ---------------------------------------------- - - -AndroidManifest.xml:52:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.DIAGNOSTIC" /> - -------------------------------------------- - - -AndroidManifest.xml:53:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.DUMP" /> - -------------------------------------- - - -AndroidManifest.xml:54:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.FACTORY_TEST" /> - ---------------------------------------------- - - -AndroidManifest.xml:55:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.FORCE_BACK" /> - -------------------------------------------- - - -AndroidManifest.xml:56:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" /> - ----------------------------------------------------- - - -AndroidManifest.xml:57:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.GLOBAL_SEARCH" /> - ----------------------------------------------- - - -AndroidManifest.xml:58:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.GLOBAL_SEARCH_CONTROL" /> - ------------------------------------------------------- - - -AndroidManifest.xml:59:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.HARDWARE_TEST" /> - ----------------------------------------------- - - -AndroidManifest.xml:60:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.INJECT_EVENTS" /> - ----------------------------------------------- - - -AndroidManifest.xml:61:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" /> - ----------------------------------------------------------- - - -AndroidManifest.xml:62:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.INSTALL_PACKAGES" /> - -------------------------------------------------- - - -AndroidManifest.xml:63:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" /> - -------------------------------------------------------- - - -AndroidManifest.xml:64:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MANAGE_APP_TOKENS" /> - --------------------------------------------------- - - -AndroidManifest.xml:65:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" /> - ------------------------------------------------------- - - -AndroidManifest.xml:66:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MANAGE_USB" /> - -------------------------------------------- - - -AndroidManifest.xml:67:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MASTER_CLEAR" /> - ---------------------------------------------- - - -AndroidManifest.xml:68:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MODIFY_NETWORK_ACCOUNTING" /> - ----------------------------------------------------------- - - -AndroidManifest.xml:69:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> - ---------------------------------------------------- - - -AndroidManifest.xml:70:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MOVE_PACKAGE" /> - ---------------------------------------------- - - -AndroidManifest.xml:71:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.NET_ADMIN" /> - ------------------------------------------- - - -AndroidManifest.xml:72:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> - ---------------------------------------------------- - - -AndroidManifest.xml:73:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" /> - ----------------------------------------------------- - - -AndroidManifest.xml:74:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.PACKAGE_VERIFICATION_AGENT" /> - ------------------------------------------------------------ - - -AndroidManifest.xml:75:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.PERFORM_CDMA_PROVISIONING" /> - ----------------------------------------------------------- - - -AndroidManifest.xml:76:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> - --------------------------------------------------- - - -AndroidManifest.xml:77:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.READ_INPUT_STATE" /> - -------------------------------------------------- - - -AndroidManifest.xml:78:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY" /> - ------------------------------------------------------------ - - -AndroidManifest.xml:79:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> - ------------------------------------------------------------- - - -AndroidManifest.xml:80:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.REBOOT" /> - ---------------------------------------- - - -AndroidManifest.xml:81:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.RECEIVE_EMERGENCY_BROADCAST" /> - ------------------------------------------------------------- - - -AndroidManifest.xml:82:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.REMOVE_TASKS" /> - ---------------------------------------------- - - -AndroidManifest.xml:83:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.RETRIEVE_WINDOW_CONTENT" /> - --------------------------------------------------------- - - -AndroidManifest.xml:84:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SEND_SMS_NO_CONFIRMATION" /> - ---------------------------------------------------------- - - -AndroidManifest.xml:85:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" /> - ------------------------------------------------------ - - -AndroidManifest.xml:86:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_ORIENTATION" /> - ------------------------------------------------- - - -AndroidManifest.xml:87:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_POINTER_SPEED" /> - --------------------------------------------------- - - -AndroidManifest.xml:88:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" /> - ------------------------------------------------------------ - - -AndroidManifest.xml:89:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_SCREEN_COMPATIBILITY" /> - ---------------------------------------------------------- - - -AndroidManifest.xml:90:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_TIME" /> - ------------------------------------------ - - -AndroidManifest.xml:91:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> - --------------------------------------------------------- - - -AndroidManifest.xml:92:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.SHUTDOWN" /> - ------------------------------------------ - - -AndroidManifest.xml:93:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.STATUS_BAR" /> - -------------------------------------------- - - -AndroidManifest.xml:94:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /> - ---------------------------------------------------- - - -AndroidManifest.xml:95:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.STOP_APP_SWITCHES" /> - --------------------------------------------------- - - -AndroidManifest.xml:96:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" /> - ----------------------------------------------------- - - -AndroidManifest.xml:97:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" /> - ---------------------------------------------------- - - -AndroidManifest.xml:98:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.WRITE_GSERVICES" /> - ------------------------------------------------- - - -AndroidManifest.xml:99:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" /> - ----------------------------------------------------- - - -AndroidManifest.xml:100:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> - ------------------------------------------------------- - - -AndroidManifest.xml:101:Error: Permission is only granted to system apps -[ProtectedPermissions] - - <uses-permission android:name="android.permission.BIND_CALL_STREAMING_SERVICE" /> - ------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: @@ -658,113 +55,11 @@ <uses-sdk android:minSdkVersion="14" /> - <!-- No warnings for those --> - <uses-permission android:name="android.permission.GET_ACCOUNTS" /> - <uses-permission android:name="android.permission.SEND_SMS" /> + <!-- Ok: --> <uses-permission android:name="android.permission.INTERNET" /> - <!-- Warnings for those --> - <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE" /> - <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" /> - <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" /> - <uses-permission android:name="android.permission.ACCESS_MTP" /> - <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> - <uses-permission android:name="android.permission.ACCOUNT_MANAGER" /> - <uses-permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK" /> - <uses-permission android:name="android.permission.ASEC_ACCESS" /> - <uses-permission android:name="android.permission.ASEC_CREATE" /> - <uses-permission android:name="android.permission.ASEC_DESTROY" /> - <uses-permission android:name="android.permission.ASEC_MOUNT_UNMOUNT" /> - <uses-permission android:name="android.permission.ASEC_RENAME" /> + <!-- Error --> <uses-permission android:name="android.permission.BACKUP" /> - <uses-permission android:name="android.permission.BIND_APPWIDGET" /> - <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" /> - <uses-permission android:name="android.permission.BIND_INPUT_METHOD" /> - <uses-permission android:name="android.permission.BIND_PACKAGE_VERIFIER" /> - <uses-permission android:name="android.permission.BIND_REMOTEVIEWS" /> - <uses-permission android:name="android.permission.BIND_TEXT_SERVICE" /> - <uses-permission android:name="android.permission.BIND_VPN_SERVICE" /> - <uses-permission android:name="android.permission.BIND_WALLPAPER" /> - <uses-permission android:name="android.permission.BRICK" /> - <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" /> - <uses-permission android:name="android.permission.BROADCAST_SMS" /> - <uses-permission android:name="android.permission.BROADCAST_WAP_PUSH" /> - <uses-permission android:name="android.permission.CALL_PRIVILEGED" /> - <uses-permission android:name="android.permission.CHANGE_BACKGROUND_DATA_SETTING" /> - <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> - <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" /> - <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP" /> - <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> - <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /> - <uses-permission android:name="android.permission.COPY_PROTECTED_DATA" /> - <uses-permission android:name="android.permission.CRYPT_KEEPER" /> - <uses-permission android:name="android.permission.DELETE_CACHE_FILES" /> - <uses-permission android:name="android.permission.DELETE_PACKAGES" /> - <uses-permission android:name="android.permission.DEVICE_POWER" /> - <uses-permission android:name="android.permission.DIAGNOSTIC" /> - <uses-permission android:name="android.permission.DUMP" /> - <uses-permission android:name="android.permission.FACTORY_TEST" /> - <uses-permission android:name="android.permission.FORCE_BACK" /> - <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" /> - <uses-permission android:name="android.permission.GLOBAL_SEARCH" /> - <uses-permission android:name="android.permission.GLOBAL_SEARCH_CONTROL" /> - <uses-permission android:name="android.permission.HARDWARE_TEST" /> - <uses-permission android:name="android.permission.INJECT_EVENTS" /> - <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" /> - <uses-permission android:name="android.permission.INSTALL_PACKAGES" /> - <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" /> - <uses-permission android:name="android.permission.MANAGE_APP_TOKENS" /> - <uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" /> - <uses-permission android:name="android.permission.MANAGE_USB" /> - <uses-permission android:name="android.permission.MASTER_CLEAR" /> - <uses-permission android:name="android.permission.MODIFY_NETWORK_ACCOUNTING" /> - <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> - <uses-permission android:name="android.permission.MOVE_PACKAGE" /> - <uses-permission android:name="android.permission.NET_ADMIN" /> - <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> - <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" /> - <uses-permission android:name="android.permission.PACKAGE_VERIFICATION_AGENT" /> - <uses-permission android:name="android.permission.PERFORM_CDMA_PROVISIONING" /> - <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> - <uses-permission android:name="android.permission.READ_INPUT_STATE" /> - <uses-permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY" /> - <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> - <uses-permission android:name="android.permission.REBOOT" /> - <uses-permission android:name="android.permission.RECEIVE_EMERGENCY_BROADCAST" /> - <uses-permission android:name="android.permission.REMOVE_TASKS" /> - <uses-permission android:name="android.permission.RETRIEVE_WINDOW_CONTENT" /> - <uses-permission android:name="android.permission.SEND_SMS_NO_CONFIRMATION" /> - <uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" /> - <uses-permission android:name="android.permission.SET_ORIENTATION" /> - <uses-permission android:name="android.permission.SET_POINTER_SPEED" /> - <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" /> - <uses-permission android:name="android.permission.SET_SCREEN_COMPATIBILITY" /> - <uses-permission android:name="android.permission.SET_TIME" /> - <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> - <uses-permission android:name="android.permission.SHUTDOWN" /> - <uses-permission android:name="android.permission.STATUS_BAR" /> - <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /> - <uses-permission android:name="android.permission.STOP_APP_SWITCHES" /> - <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" /> - <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" /> - <uses-permission android:name="android.permission.WRITE_GSERVICES" /> - <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" /> - <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> - <uses-permission android:name="android.permission.BIND_CALL_STREAMING_SERVICE" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -773,11 +68,6 @@ [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/SystemPermissionsDetectorTest.java) 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, `SystemPermissionsDetector.testBrokenOrder`. -To report a problem with this extracted sample, visit -https://issuetracker.google.com/issues/new?component=192708. - (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-2.md.html b/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-2.md.html index e996e17..0d115b1 100644 --- a/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-2.md.html +++ b/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-2.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +(#) ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales -!!! WARNING: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +!!! WARNING: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales This is a warning. Id : `ProtoLayoutEdgeContentLayoutResponsive` Summary -: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales Severity : Warning Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ResponsiveLayoutDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.kt) Copyright Year : 2024 @@ -51,10 +53,10 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutEdgeContentLayoutResponsive: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. (this issue) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive.md.html) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive-2.md.html) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive-3.md.html) +* ProtoLayoutEdgeContentLayoutResponsive: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales (this issue) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive.md.html) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive-2.md.html) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive-3.md.html) (##) Including @@ -65,17 +67,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout-material:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout-material:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout-material:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout-material:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout-material) # libs.versions.toml [versions] -protolayout-material = "1.2.0-alpha05" +protolayout-material = "1.2.0-beta01" [libraries] protolayout-material = { module = "androidx.wear.protolayout:protolayout-material", @@ -83,7 +85,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout-material](androidx_wear_protolayout_protolayout-material.md.html). diff --git a/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-3.md.html b/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-3.md.html index 3f6d09d..70f369a 100644 --- a/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-3.md.html +++ b/docs/checks/ProtoLayoutEdgeContentLayoutResponsive-3.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +(#) ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales -!!! WARNING: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +!!! WARNING: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales This is a warning. Id : `ProtoLayoutEdgeContentLayoutResponsive` Summary -: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales Severity : Warning Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ResponsiveLayoutDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.kt) Copyright Year : 2024 @@ -51,10 +53,10 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutEdgeContentLayoutResponsive: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. (this issue) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive.md.html) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive-2.md.html) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive-3.md.html) +* ProtoLayoutEdgeContentLayoutResponsive: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales (this issue) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive.md.html) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive-2.md.html) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive-3.md.html) (##) Including @@ -65,17 +67,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout) # libs.versions.toml [versions] -protolayout = "1.2.0-alpha05" +protolayout = "1.2.0-beta01" [libraries] protolayout = { module = "androidx.wear.protolayout:protolayout", @@ -83,7 +85,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout](androidx_wear_protolayout_protolayout.md.html). diff --git a/docs/checks/ProtoLayoutEdgeContentLayoutResponsive.md.html b/docs/checks/ProtoLayoutEdgeContentLayoutResponsive.md.html index 1d1d3ef..ef8013a 100644 --- a/docs/checks/ProtoLayoutEdgeContentLayoutResponsive.md.html +++ b/docs/checks/ProtoLayoutEdgeContentLayoutResponsive.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +(#) ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales -!!! WARNING: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +!!! WARNING: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales This is a warning. Id : `ProtoLayoutEdgeContentLayoutResponsive` Summary -: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. +: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales Severity : Warning Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ResponsiveLayoutDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.kt) Copyright Year : 2024 @@ -51,10 +53,10 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutEdgeContentLayoutResponsive: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales. (this issue) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive.md.html) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive-2.md.html) -* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutEdgeContentLayoutResponsive-3.md.html) +* ProtoLayoutEdgeContentLayoutResponsive: ProtoLayout Material EdgeContentLayout should be used with responsivebehaviour to ensure the best behaviour across different screen sizes andlocales (this issue) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive.md.html) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive-2.md.html) +* [ProtoLayoutEdgeContentLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutEdgeContentLayoutResponsive-3.md.html) (##) Including @@ -65,17 +67,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout-expression:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout-expression:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout-expression) # libs.versions.toml [versions] -protolayout-expression = "1.2.0-alpha05" +protolayout-expression = "1.2.0-beta01" [libraries] protolayout-expression = { module = "androidx.wear.protolayout:protolayout-expression", @@ -83,7 +85,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout-expression](androidx_wear_protolayout_protolayout-expression.md.html). diff --git a/docs/checks/ProtoLayoutMinSchema-2.md.html b/docs/checks/ProtoLayoutMinSchema-2.md.html index bd9630b..de868d2 100644 --- a/docs/checks/ProtoLayoutMinSchema-2.md.html +++ b/docs/checks/ProtoLayoutMinSchema-2.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout feature is not guaranteed to be available on the target device API. +(#) ProtoLayout feature is not guaranteed to be available on the target device API -!!! ERROR: ProtoLayout feature is not guaranteed to be available on the target device API. +!!! ERROR: ProtoLayout feature is not guaranteed to be available on the target device API This is an error. Id : `ProtoLayoutMinSchema` Summary -: ProtoLayout feature is not guaranteed to be available on the target device API. +: ProtoLayout feature is not guaranteed to be available on the target device API Severity : Error Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ProtoLayoutMinSchemaDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/ProtoLayoutMinSchemaDetectorTest.kt) Copyright Year : 2023 @@ -55,15 +57,88 @@ Note that @RequiresSchemaVersion annotation on classes are mostly ignored (except for Builder classes). +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Bar.kt:6:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + private val fieldAssignment = withAnnotation.annotatedMethod() + -------------------------------- +src/foo/Bar.kt:12:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + bar() + ----- +src/foo/Bar.kt:14:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + withAnnotation.annotatedMethod() + -------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`src/foo/WithAnnotation.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.expression.RequiresSchemaVersion + +@RequiresSchemaVersion(major=1, minor=200) +class WithAnnotation { + fun unAnnotatedMethod(){} + + @RequiresSchemaVersion(major=1, minor=200) + fun annotatedMethod(){} + + @RequiresSchemaVersion(major=1, minor=200) + fun unreferencedMethod(){} + + companion object { + @RequiresSchemaVersion(major=1, minor=200) + const val ANNOTATED_CONST = 10 + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/foo/Bar.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.expression.RequiresSchemaVersion + +class Bar { + private val withAnnotation = WithAnnotation() + private val fieldAssignment = withAnnotation.annotatedMethod() + + @RequiresSchemaVersion(major=1, minor=200) + fun bar() {} + + fun baz() { + bar() + withAnnotation.unAnnotatedMethod() + withAnnotation.annotatedMethod() + //TODO: b/308552481 - This should fail + val b = withAnnotation.ANNOTATED_CONST + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/ProtoLayoutMinSchemaDetectorTest.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, `ProtoLayoutMinSchemaDetector.calling V1_2 API requires SDK version check`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=1112273. + (##) Repackaged This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutMinSchema: ProtoLayout feature is not guaranteed to be available on the target device API. (this issue) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutMinSchema.md.html) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutMinSchema-2.md.html) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutMinSchema-3.md.html) +* ProtoLayoutMinSchema: ProtoLayout feature is not guaranteed to be available on the target device API (this issue) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutMinSchema.md.html) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutMinSchema-2.md.html) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutMinSchema-3.md.html) (##) Including @@ -74,17 +149,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout-material:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout-material:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout-material:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout-material:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout-material) # libs.versions.toml [versions] -protolayout-material = "1.2.0-alpha05" +protolayout-material = "1.2.0-beta01" [libraries] protolayout-material = { module = "androidx.wear.protolayout:protolayout-material", @@ -92,7 +167,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout-material](androidx_wear_protolayout_protolayout-material.md.html). diff --git a/docs/checks/ProtoLayoutMinSchema-3.md.html b/docs/checks/ProtoLayoutMinSchema-3.md.html index 5fd0039..f962e98 100644 --- a/docs/checks/ProtoLayoutMinSchema-3.md.html +++ b/docs/checks/ProtoLayoutMinSchema-3.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout feature is not guaranteed to be available on the target device API. +(#) ProtoLayout feature is not guaranteed to be available on the target device API -!!! ERROR: ProtoLayout feature is not guaranteed to be available on the target device API. +!!! ERROR: ProtoLayout feature is not guaranteed to be available on the target device API This is an error. Id : `ProtoLayoutMinSchema` Summary -: ProtoLayout feature is not guaranteed to be available on the target device API. +: ProtoLayout feature is not guaranteed to be available on the target device API Severity : Error Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ProtoLayoutMinSchemaDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/ProtoLayoutMinSchemaDetectorTest.kt) Copyright Year : 2023 @@ -55,15 +57,88 @@ Note that @RequiresSchemaVersion annotation on classes are mostly ignored (except for Builder classes). +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Bar.kt:6:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + private val fieldAssignment = withAnnotation.annotatedMethod() + -------------------------------- +src/foo/Bar.kt:12:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + bar() + ----- +src/foo/Bar.kt:14:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + withAnnotation.annotatedMethod() + -------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`src/foo/WithAnnotation.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.expression.RequiresSchemaVersion + +@RequiresSchemaVersion(major=1, minor=200) +class WithAnnotation { + fun unAnnotatedMethod(){} + + @RequiresSchemaVersion(major=1, minor=200) + fun annotatedMethod(){} + + @RequiresSchemaVersion(major=1, minor=200) + fun unreferencedMethod(){} + + companion object { + @RequiresSchemaVersion(major=1, minor=200) + const val ANNOTATED_CONST = 10 + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/foo/Bar.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.expression.RequiresSchemaVersion + +class Bar { + private val withAnnotation = WithAnnotation() + private val fieldAssignment = withAnnotation.annotatedMethod() + + @RequiresSchemaVersion(major=1, minor=200) + fun bar() {} + + fun baz() { + bar() + withAnnotation.unAnnotatedMethod() + withAnnotation.annotatedMethod() + //TODO: b/308552481 - This should fail + val b = withAnnotation.ANNOTATED_CONST + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/ProtoLayoutMinSchemaDetectorTest.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, `ProtoLayoutMinSchemaDetector.calling V1_2 API requires SDK version check`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=1112273. + (##) Repackaged This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutMinSchema: ProtoLayout feature is not guaranteed to be available on the target device API. (this issue) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutMinSchema.md.html) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutMinSchema-2.md.html) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutMinSchema-3.md.html) +* ProtoLayoutMinSchema: ProtoLayout feature is not guaranteed to be available on the target device API (this issue) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutMinSchema.md.html) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutMinSchema-2.md.html) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutMinSchema-3.md.html) (##) Including @@ -74,17 +149,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout) # libs.versions.toml [versions] -protolayout = "1.2.0-alpha05" +protolayout = "1.2.0-beta01" [libraries] protolayout = { module = "androidx.wear.protolayout:protolayout", @@ -92,7 +167,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout](androidx_wear_protolayout_protolayout.md.html). diff --git a/docs/checks/ProtoLayoutMinSchema.md.html b/docs/checks/ProtoLayoutMinSchema.md.html index 5183761..381cd3c 100644 --- a/docs/checks/ProtoLayoutMinSchema.md.html +++ b/docs/checks/ProtoLayoutMinSchema.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout feature is not guaranteed to be available on the target device API. +(#) ProtoLayout feature is not guaranteed to be available on the target device API -!!! ERROR: ProtoLayout feature is not guaranteed to be available on the target device API. +!!! ERROR: ProtoLayout feature is not guaranteed to be available on the target device API This is an error. Id : `ProtoLayoutMinSchema` Summary -: ProtoLayout feature is not guaranteed to be available on the target device API. +: ProtoLayout feature is not guaranteed to be available on the target device API Severity : Error Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ProtoLayoutMinSchemaDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/ProtoLayoutMinSchemaDetectorTest.kt) Copyright Year : 2023 @@ -55,15 +57,88 @@ Note that @RequiresSchemaVersion annotation on classes are mostly ignored (except for Builder classes). +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Bar.kt:6:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + private val fieldAssignment = withAnnotation.annotatedMethod() + -------------------------------- +src/foo/Bar.kt:12:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + bar() + ----- +src/foo/Bar.kt:14:Error: This API is not guaranteed to be available on +the device (requires schema 1.200). [ProtoLayoutMinSchema] + withAnnotation.annotatedMethod() + -------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`src/foo/WithAnnotation.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.expression.RequiresSchemaVersion + +@RequiresSchemaVersion(major=1, minor=200) +class WithAnnotation { + fun unAnnotatedMethod(){} + + @RequiresSchemaVersion(major=1, minor=200) + fun annotatedMethod(){} + + @RequiresSchemaVersion(major=1, minor=200) + fun unreferencedMethod(){} + + companion object { + @RequiresSchemaVersion(major=1, minor=200) + const val ANNOTATED_CONST = 10 + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/foo/Bar.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.expression.RequiresSchemaVersion + +class Bar { + private val withAnnotation = WithAnnotation() + private val fieldAssignment = withAnnotation.annotatedMethod() + + @RequiresSchemaVersion(major=1, minor=200) + fun bar() {} + + fun baz() { + bar() + withAnnotation.unAnnotatedMethod() + withAnnotation.annotatedMethod() + //TODO: b/308552481 - This should fail + val b = withAnnotation.ANNOTATED_CONST + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/ProtoLayoutMinSchemaDetectorTest.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, `ProtoLayoutMinSchemaDetector.calling V1_2 API requires SDK version check`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=1112273. + (##) Repackaged This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutMinSchema: ProtoLayout feature is not guaranteed to be available on the target device API. (this issue) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutMinSchema.md.html) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutMinSchema-2.md.html) -* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutMinSchema-3.md.html) +* ProtoLayoutMinSchema: ProtoLayout feature is not guaranteed to be available on the target device API (this issue) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutMinSchema.md.html) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutMinSchema-2.md.html) +* [ProtoLayoutMinSchema from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutMinSchema-3.md.html) (##) Including @@ -74,17 +149,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout-expression:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout-expression:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout-expression) # libs.versions.toml [versions] -protolayout-expression = "1.2.0-alpha05" +protolayout-expression = "1.2.0-beta01" [libraries] protolayout-expression = { module = "androidx.wear.protolayout:protolayout-expression", @@ -92,7 +167,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout-expression](androidx_wear_protolayout_protolayout-expression.md.html). diff --git a/docs/checks/ProtoLayoutPrimaryLayoutResponsive-2.md.html b/docs/checks/ProtoLayoutPrimaryLayoutResponsive-2.md.html index 1e2436e..bc37ebf 100644 --- a/docs/checks/ProtoLayoutPrimaryLayoutResponsive-2.md.html +++ b/docs/checks/ProtoLayoutPrimaryLayoutResponsive-2.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +(#) ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales -!!! WARNING: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +!!! WARNING: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales This is a warning. Id : `ProtoLayoutPrimaryLayoutResponsive` Summary -: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales Severity : Warning Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ResponsiveLayoutDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.kt) Copyright Year : 2024 @@ -44,15 +46,118 @@ labels and bottom chip doesn't go off the screen (especially with different locales). +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Bar.kt:4:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] +val layout = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:9:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val layout = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:12:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val layoutFalse = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:17:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val l = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:24:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + PrimaryLayout.Builder().setResponsiveContentInsetEnabled(enabled) + --------------------- +src/foo/Bar.kt:32:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + return PrimaryLayout.Builder().build() + --------------------- +src/foo/Bar.kt:36:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + PrimaryLayout.Builder() + --------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Bar.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.material.layouts.PrimaryLayout + +val layout = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + .build() + +class Bar { + val layout = PrimaryLayout.Builder(null) + .build() + + val layoutFalse = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + .build() + + fun buildFalse() { + val l = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + return l.build() + } + + fun update() { + val enabled = false + PrimaryLayout.Builder().setResponsiveContentInsetEnabled(enabled) + } + + fun build() { + update().build() + } + + fun build2() { + return PrimaryLayout.Builder().build() + } + + fun doubleFalse() { + PrimaryLayout.Builder() + .setResponsiveContentInsetEnabled(true) + .setResponsiveContentInsetEnabled(false) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.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, `ResponsiveLayoutDetector.primaryLayout without responsiveness requires and fixes setter`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=1112273. + (##) Repackaged This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutPrimaryLayoutResponsive: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. (this issue) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive.md.html) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive-2.md.html) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive-3.md.html) +* ProtoLayoutPrimaryLayoutResponsive: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales (this issue) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive.md.html) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive-2.md.html) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive-3.md.html) (##) Including @@ -63,17 +168,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout-material:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout-material:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout-material:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout-material:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout-material) # libs.versions.toml [versions] -protolayout-material = "1.2.0-alpha05" +protolayout-material = "1.2.0-beta01" [libraries] protolayout-material = { module = "androidx.wear.protolayout:protolayout-material", @@ -81,7 +186,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout-material](androidx_wear_protolayout_protolayout-material.md.html). diff --git a/docs/checks/ProtoLayoutPrimaryLayoutResponsive-3.md.html b/docs/checks/ProtoLayoutPrimaryLayoutResponsive-3.md.html index bf2be6e..c2a5594 100644 --- a/docs/checks/ProtoLayoutPrimaryLayoutResponsive-3.md.html +++ b/docs/checks/ProtoLayoutPrimaryLayoutResponsive-3.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +(#) ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales -!!! WARNING: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +!!! WARNING: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales This is a warning. Id : `ProtoLayoutPrimaryLayoutResponsive` Summary -: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales Severity : Warning Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ResponsiveLayoutDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.kt) Copyright Year : 2024 @@ -44,15 +46,118 @@ labels and bottom chip doesn't go off the screen (especially with different locales). +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Bar.kt:4:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] +val layout = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:9:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val layout = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:12:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val layoutFalse = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:17:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val l = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:24:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + PrimaryLayout.Builder().setResponsiveContentInsetEnabled(enabled) + --------------------- +src/foo/Bar.kt:32:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + return PrimaryLayout.Builder().build() + --------------------- +src/foo/Bar.kt:36:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + PrimaryLayout.Builder() + --------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Bar.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.material.layouts.PrimaryLayout + +val layout = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + .build() + +class Bar { + val layout = PrimaryLayout.Builder(null) + .build() + + val layoutFalse = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + .build() + + fun buildFalse() { + val l = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + return l.build() + } + + fun update() { + val enabled = false + PrimaryLayout.Builder().setResponsiveContentInsetEnabled(enabled) + } + + fun build() { + update().build() + } + + fun build2() { + return PrimaryLayout.Builder().build() + } + + fun doubleFalse() { + PrimaryLayout.Builder() + .setResponsiveContentInsetEnabled(true) + .setResponsiveContentInsetEnabled(false) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.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, `ResponsiveLayoutDetector.primaryLayout without responsiveness requires and fixes setter`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=1112273. + (##) Repackaged This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutPrimaryLayoutResponsive: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. (this issue) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive.md.html) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive-2.md.html) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive-3.md.html) +* ProtoLayoutPrimaryLayoutResponsive: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales (this issue) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive.md.html) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive-2.md.html) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive-3.md.html) (##) Including @@ -63,17 +168,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout) # libs.versions.toml [versions] -protolayout = "1.2.0-alpha05" +protolayout = "1.2.0-beta01" [libraries] protolayout = { module = "androidx.wear.protolayout:protolayout", @@ -81,7 +186,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout](androidx_wear_protolayout_protolayout.md.html). diff --git a/docs/checks/ProtoLayoutPrimaryLayoutResponsive.md.html b/docs/checks/ProtoLayoutPrimaryLayoutResponsive.md.html index f0e9937..32ac4c0 100644 --- a/docs/checks/ProtoLayoutPrimaryLayoutResponsive.md.html +++ b/docs/checks/ProtoLayoutPrimaryLayoutResponsive.md.html @@ -1,13 +1,13 @@ -(#) ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +(#) ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales -!!! WARNING: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +!!! WARNING: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales This is a warning. Id : `ProtoLayoutPrimaryLayoutResponsive` Summary -: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. +: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales Severity : Warning Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/main/java/androidx/wear/protolayout/lint/ResponsiveLayoutDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.kt) Copyright Year : 2024 @@ -44,15 +46,118 @@ labels and bottom chip doesn't go off the screen (especially with different locales). +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Bar.kt:4:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] +val layout = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:9:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val layout = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:12:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val layoutFalse = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:17:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + val l = PrimaryLayout.Builder(null) + --------------------- +src/foo/Bar.kt:24:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + PrimaryLayout.Builder().setResponsiveContentInsetEnabled(enabled) + --------------------- +src/foo/Bar.kt:32:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + return PrimaryLayout.Builder().build() + --------------------- +src/foo/Bar.kt:36:Warning: PrimaryLayout used, but responsiveness isn't +set: Please call +setResponsiveContentInsetEnabled(true) for the best results across +different screen sizes. [ProtoLayoutPrimaryLayoutResponsive] + PrimaryLayout.Builder() + --------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Bar.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import androidx.wear.protolayout.material.layouts.PrimaryLayout + +val layout = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + .build() + +class Bar { + val layout = PrimaryLayout.Builder(null) + .build() + + val layoutFalse = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + .build() + + fun buildFalse() { + val l = PrimaryLayout.Builder(null) + .setResponsiveContentInsetEnabled(false) + return l.build() + } + + fun update() { + val enabled = false + PrimaryLayout.Builder().setResponsiveContentInsetEnabled(enabled) + } + + fun build() { + update().build() + } + + fun build2() { + return PrimaryLayout.Builder().build() + } + + fun doubleFalse() { + PrimaryLayout.Builder() + .setResponsiveContentInsetEnabled(true) + .setResponsiveContentInsetEnabled(false) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/wear/protolayout/protolayout-lint/src/test/java/PrimaryLayoutResponsiveDetectorTest.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, `ResponsiveLayoutDetector.primaryLayout without responsiveness requires and fixes setter`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=1112273. + (##) Repackaged This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* ProtoLayoutPrimaryLayoutResponsive: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales. (this issue) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive.md.html) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive-2.md.html) -* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-alpha05](ProtoLayoutPrimaryLayoutResponsive-3.md.html) +* ProtoLayoutPrimaryLayoutResponsive: ProtoLayout Material PrimaryLayout should be used with responsive behaviourto ensure the best behaviour across different screen sizes and locales (this issue) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-expression:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive.md.html) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout-material:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive-2.md.html) +* [ProtoLayoutPrimaryLayoutResponsive from androidx.wear.protolayout:protolayout:1.2.0-beta01](ProtoLayoutPrimaryLayoutResponsive-3.md.html) (##) Including @@ -63,17 +168,17 @@ ``` // build.gradle.kts -implementation("androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05") +implementation("androidx.wear.protolayout:protolayout-expression:1.2.0-beta01") // build.gradle -implementation 'androidx.wear.protolayout:protolayout-expression:1.2.0-alpha05' +implementation 'androidx.wear.protolayout:protolayout-expression:1.2.0-beta01' // build.gradle.kts with version catalogs: implementation(libs.protolayout-expression) # libs.versions.toml [versions] -protolayout-expression = "1.2.0-alpha05" +protolayout-expression = "1.2.0-beta01" [libraries] protolayout-expression = { module = "androidx.wear.protolayout:protolayout-expression", @@ -81,7 +186,7 @@ } ``` -1.2.0-alpha05 is the version this documentation was generated from; +1.2.0-beta01 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.wear.protolayout:protolayout-expression](androidx_wear_protolayout_protolayout-expression.md.html). diff --git a/docs/checks/ProviderReadPermissionOnly.md.html b/docs/checks/ProviderReadPermissionOnly.md.html index 89888f0..e27c284 100644 --- a/docs/checks/ProviderReadPermissionOnly.md.html +++ b/docs/checks/ProviderReadPermissionOnly.md.html @@ -52,16 +52,12 @@ implements {insert} write APIs but does not protect them with a permission. Update the tag to use android:permission or android:writePermission [ProviderReadPermissionOnly] - <provider android:name="test.pkg.JavaTestContentProvider" android:readPermission="android.permission.READ_DATA"/> ---------------------- - - AndroidManifest.xml:6:Warning: test.pkg.KotlinTestContentProvider implements {insert} write APIs but does not protect them with a permission. Update the tag to use android:permission or android:writePermission [ProviderReadPermissionOnly] - <provider android:name="test.pkg.KotlinTestContentProvider" android:readPermission="android.permission.READ_DATA"/> ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,7 +106,7 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`src/KotlinTestContentProvider.kt`: +`src/test/pkg/KotlinTestContentProvider.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers package test.pkg diff --git a/docs/checks/ProvidesMustNotBeAbstract.md.html b/docs/checks/ProvidesMustNotBeAbstract.md.html index 1cc895a..0542d98 100644 --- a/docs/checks/ProvidesMustNotBeAbstract.md.html +++ b/docs/checks/ProvidesMustNotBeAbstract.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -48,63 +48,38 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:25:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Int.bind(): Number = this@bind -------------------------------------------- - - src/foo/MyQualifier.kt:26:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Long.bind(): Number = this@bind --------------------------------------------- - - src/foo/MyQualifier.kt:27:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Double.bind(): Number = this@bind ----------------------------------------------- - - src/foo/MyQualifier.kt:28:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Float.bind(): Number = this@bind ---------------------------------------------- - - src/foo/MyQualifier.kt:29:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Short.bind(): Number = this@bind ---------------------------------------------- - - src/foo/MyQualifier.kt:30:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Byte.bind(): Number = this@bind --------------------------------------------- - - src/foo/MyQualifier.kt:31:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun Char.bind(): Comparable<Char> = this@bind ------------------------------------------------------- - - src/foo/MyQualifier.kt:32:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun String.bind(): Comparable<String> = this@bind ----------------------------------------------------------- - - src/foo/MyQualifier.kt:33:Error: @Provides functions cannot be abstract [ProvidesMustNotBeAbstract] - @Provides fun @receiver:MyQualifier Boolean.bind(): Comparable<Boolean> = this@bind ----------------------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ProxyPassword.md.html b/docs/checks/ProxyPassword.md.html index 63471b9..59afc46 100644 --- a/docs/checks/ProxyPassword.md.html +++ b/docs/checks/ProxyPassword.md.html @@ -40,7 +40,6 @@ gradle.properties:1:Warning: Storing passwords in clear text is risky; make sure this file is not shared or checked in via version control [ProxyPassword] - systemProp.http.proxyPassword=something --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -48,7 +47,7 @@ Here is the source file referenced above: `gradle.properties`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~properties linenumbers systemProp.http.proxyPassword=something ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/PublicKeyCredential.md.html b/docs/checks/PublicKeyCredential.md.html index 141e793..509ddbd 100644 --- a/docs/checks/PublicKeyCredential.md.html +++ b/docs/checks/PublicKeyCredential.md.html @@ -40,7 +40,6 @@ src/main/kotlin/test/pkg/Test.kt:7:Warning: PublicKeyCredential is only supported from Android 9 (API level 28) and higher [PublicKeyCredential] - val request = CreatePublicKeyCredentialRequest() ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -67,13 +66,6 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`src/CreatePublicKeyCredentialRequest.kt`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers -package androidx.credentials - -class CreatePublicKeyCredentialRequest -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 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/PublicKeyCredentialDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/PxUsage.md.html b/docs/checks/PxUsage.md.html index 193e633..1d92cff 100644 --- a/docs/checks/PxUsage.md.html +++ b/docs/checks/PxUsage.md.html @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/now_playing_after.xml:41:Warning: Avoid using "px" as units; use "dp" instead [PxUsage] - android:layout_width="2px" -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/QueryAllPackagesPermission.md.html b/docs/checks/QueryAllPackagesPermission.md.html index b192e16..e08d420 100644 --- a/docs/checks/QueryAllPackagesPermission.md.html +++ b/docs/checks/QueryAllPackagesPermission.md.html @@ -45,12 +45,11 @@ used instead of QUERY_ALL_PACKAGES; see https://g.co/dev/packagevisibility for details [QueryAllPackagesPermission] - <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/><!-- ERROR --> ---------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -63,6 +62,41 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/MainActivity.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import android.app.Activity +import android.content.Intent +import android.os.Bundle + +class MainActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val context = applicationContext + val pm = context.packageManager + + pm.getInstalledPackages(0) // ERROR + pm.getInstalledApplications(0) // ERROR + + pm.queryBroadcastReceivers(Intent(), 0) // ERROR + pm.queryContentProviders("", 0, 0) // ERROR + pm.queryIntentServices(Intent(), 0) // ERROR + pm.queryIntentActivities(Intent(), 0) // ERROR + + Intent().resolveActivity(pm) // ERROR + Intent().resolveActivityInfo(pm, 0) // ERROR + + this.getInstalledPackages() // OK + this.resolveActivity() // OK + } + + private fun getInstalledPackages() = Unit + private fun resolveActivity() = Unit +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/PackageVisibilityDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/QueryPermissionsNeeded.md.html b/docs/checks/QueryPermissionsNeeded.md.html index cdb6bf8..0ce4be0 100644 --- a/docs/checks/QueryPermissionsNeeded.md.html +++ b/docs/checks/QueryPermissionsNeeded.md.html @@ -49,63 +49,41 @@ src/test/pkg/MainActivity.kt:14:Warning: As of Android 11, this method no longer returns information about all apps; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - pm.getInstalledPackages(0) // ERROR -------------------- - - src/test/pkg/MainActivity.kt:15:Warning: As of Android 11, this method no longer returns information about all apps; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - pm.getInstalledApplications(0) // ERROR ------------------------ - - src/test/pkg/MainActivity.kt:17:Warning: Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - pm.queryBroadcastReceivers(Intent(), 0) // ERROR ----------------------- - - src/test/pkg/MainActivity.kt:18:Warning: Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - pm.queryContentProviders("", 0, 0) // ERROR --------------------- - - src/test/pkg/MainActivity.kt:19:Warning: Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - pm.queryIntentServices(Intent(), 0) // ERROR ------------------- - - src/test/pkg/MainActivity.kt:20:Warning: Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - pm.queryIntentActivities(Intent(), 0) // ERROR --------------------- - - src/test/pkg/MainActivity.kt:22:Warning: Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - Intent().resolveActivity(pm) // ERROR --------------- - - src/test/pkg/MainActivity.kt:23:Warning: Consider adding a declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details [QueryPermissionsNeeded] - Intent().resolveActivityInfo(pm, 0) // ERROR ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Range.md.html b/docs/checks/Range.md.html index 74eff68..c7745ff 100644 --- a/docs/checks/Range.md.html +++ b/docs/checks/Range.md.html @@ -38,275 +38,154 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/RangeTest.java:32:Error: Expected length 5 (was 4) [Range] - printExact("1234"); // ERROR ------ - - src/test/pkg/RangeTest.java:34:Error: Expected length 5 (was 6) [Range] - printExact("123456"); // ERROR -------- - - src/test/pkg/RangeTest.java:36:Error: Expected length ≥ 5 (was 4) [Range] - printMin("1234"); // ERROR ------ - - src/test/pkg/RangeTest.java:43:Error: Expected length ≤ 8 (was 9) [Range] - printMax("123456789"); // ERROR ----------- - - src/test/pkg/RangeTest.java:45:Error: Expected length ≥ 4 (was 3) [Range] - printRange("123"); // ERROR ----- - - src/test/pkg/RangeTest.java:49:Error: Expected length ≤ 6 (was 7) [Range] - printRange("1234567"); // ERROR --------- - - src/test/pkg/RangeTest.java:53:Error: Expected size 5 (was 4) [Range] - printExact(new int[]{1, 2, 3, 4}); // ERROR --------------------- - - src/test/pkg/RangeTest.java:55:Error: Expected size 5 (was 6) [Range] - printExact(new int[]{1, 2, 3, 4, 5, 6}); // ERROR --------------------------- - - src/test/pkg/RangeTest.java:57:Error: Expected size ≥ 5 (was 4) [Range] - printMin(new int[]{1, 2, 3, 4}); // ERROR --------------------- - - src/test/pkg/RangeTest.java:65:Error: Expected size ≤ 8 (was 9) [Range] - printMax(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}); // ERROR ------------------------------------ - - src/test/pkg/RangeTest.java:67:Error: Expected size ≥ 4 (was 3) [Range] - printRange(new int[] {1,2,3}); // ERROR ----------------- - - src/test/pkg/RangeTest.java:71:Error: Expected size ≤ 6 (was 7) [Range] - printRange(new int[] {1,2,3,4,5,6,7}); // ERROR ------------------------- - - src/test/pkg/RangeTest.java:74:Error: Expected size to be a multiple of 3 (was 4 and should be either 3 or 6) [Range] - printMultiple(new int[] {1,2,3,4}); // ERROR ------------------- - - src/test/pkg/RangeTest.java:75:Error: Expected size to be a multiple of 3 (was 5 and should be either 3 or 6) [Range] - printMultiple(new int[] {1,2,3,4,5}); // ERROR --------------------- - - src/test/pkg/RangeTest.java:77:Error: Expected size to be a multiple of 3 (was 7 and should be either 6 or 9) [Range] - printMultiple(new int[] {1,2,3,4,5,6,7}); // ERROR ------------------------- - - src/test/pkg/RangeTest.java:80:Error: Expected size ≥ 4 (was 3) [Range] - printMinMultiple(new int[]{1, 2, 3}); // ERROR ------------------ - - src/test/pkg/RangeTest.java:84:Error: Value must be ≥ 4 (was 3) [Range] - printAtLeast(3); // ERROR - - - src/test/pkg/RangeTest.java:91:Error: Value must be ≤ 7 (was 8) [Range] - printAtMost(8); // ERROR - - - src/test/pkg/RangeTest.java:93:Error: Value must be ≥ 4 (was 3) [Range] - printBetween(3); // ERROR - - - src/test/pkg/RangeTest.java:98:Error: Value must be ≤ 7 (was 8) [Range] - printBetween(8); // ERROR - - - src/test/pkg/RangeTest.java:102:Error: Value must be ≥ 2.5 (was 2.49) [Range] - printAtLeastInclusive(2.49f); // ERROR ----- - - src/test/pkg/RangeTest.java:106:Error: Value must be > 2.5 (was 2.49) [Range] - printAtLeastExclusive(2.49f); // ERROR ----- - - src/test/pkg/RangeTest.java:107:Error: Value must be > 2.5 (was 2.5) [Range] - printAtLeastExclusive(2.5f); // ERROR ---- - - src/test/pkg/RangeTest.java:113:Error: Value must be ≤ 7.0 (was 7.1) [Range] - printAtMostInclusive(7.1f); // ERROR ---- - - src/test/pkg/RangeTest.java:117:Error: Value must be < 7.0 (was 7.0) [Range] - printAtMostExclusive(7.0f); // ERROR ---- - - src/test/pkg/RangeTest.java:118:Error: Value must be < 7.0 (was 7.1) [Range] - printAtMostExclusive(7.1f); // ERROR ---- - - src/test/pkg/RangeTest.java:120:Error: Value must be ≥ 2.5 (was 2.4) [Range] - printBetweenFromInclusiveToInclusive(2.4f); // ERROR ---- - - src/test/pkg/RangeTest.java:124:Error: Value must be ≤ 5.0 (was 5.1) [Range] - printBetweenFromInclusiveToInclusive(5.1f); // ERROR ---- - - src/test/pkg/RangeTest.java:126:Error: Value must be > 2.5 (was 2.4) [Range] - printBetweenFromExclusiveToInclusive(2.4f); // ERROR ---- - - src/test/pkg/RangeTest.java:127:Error: Value must be > 2.5 (was 2.5) [Range] - printBetweenFromExclusiveToInclusive(2.5f); // ERROR ---- - - src/test/pkg/RangeTest.java:129:Error: Value must be ≤ 5.0 (was 5.1) [Range] - printBetweenFromExclusiveToInclusive(5.1f); // ERROR ---- - - src/test/pkg/RangeTest.java:131:Error: Value must be ≥ 2.5 (was 2.4) [Range] - printBetweenFromInclusiveToExclusive(2.4f); // ERROR ---- - - src/test/pkg/RangeTest.java:135:Error: Value must be < 5.0 (was 5.0) [Range] - printBetweenFromInclusiveToExclusive(5.0f); // ERROR ---- - - src/test/pkg/RangeTest.java:137:Error: Value must be > 2.5 (was 2.4) [Range] - printBetweenFromExclusiveToExclusive(2.4f); // ERROR ---- - - src/test/pkg/RangeTest.java:138:Error: Value must be > 2.5 (was 2.5) [Range] - printBetweenFromExclusiveToExclusive(2.5f); // ERROR ---- - - src/test/pkg/RangeTest.java:141:Error: Value must be < 5.0 (was 5.0) [Range] - printBetweenFromExclusiveToExclusive(5.0f); // ERROR ---- - - src/test/pkg/RangeTest.java:145:Error: Value must be ≥ 4 (was -7) [Range] - printBetween(-7); // ERROR -- - - src/test/pkg/RangeTest.java:146:Error: Value must be > 2.5 (was -10.0) [Range] - printAtLeastExclusive(-10.0f); // ERROR ------ - - src/test/pkg/RangeTest.java:156:Error: Value must be ≥ -1 (was -2) [Range] - printIndirect(-2); // ERROR -- - - src/test/pkg/RangeTest.java:157:Error: Value must be ≤ 42 (was 43) [Range] - printIndirect(43); // ERROR -- - - src/test/pkg/RangeTest.java:158:Error: Expected length 5 (was 7) [Range] - printIndirectSize("1234567"); // ERROR --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RawColor.md.html b/docs/checks/RawColor.md.html index bca2a66..89bd3e3 100644 --- a/docs/checks/RawColor.md.html +++ b/docs/checks/RawColor.md.html @@ -1,13 +1,13 @@ -(#) Flags color that are not defined as resource. +(#) Flags color that are not defined as resource -!!! WARNING: Flags color that are not defined as resource. +!!! WARNING: Flags color that are not defined as resource This is a warning. Id : `RawColor` Summary -: Flags color that are not defined as resource. +: Flags color that are not defined as resource Severity : Warning Category @@ -29,12 +29,43 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/RawColorDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/RawColorDetectorTest.kt) Color value should all be defined as color resources. This has the benefit that you can easily see all of your colors in one file. One benefit is an easier addition to Dark Theme for instance. This check will run on layouts as well as xml drawables. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/layout.xml:2:Warning: Should be using a color resource +instead. [RawColor] + app:someCustomColor="#fff"/> + ---- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/layout.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView xmlns:app="http://schemas.android.com/apk/res-auto" + app:someCustomColor="#fff"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/RawColorDetectorTest.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, `RawColorDetector.appCustomColor`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RawDimen.md.html b/docs/checks/RawDimen.md.html index 2689265..2aa3d9a 100644 --- a/docs/checks/RawDimen.md.html +++ b/docs/checks/RawDimen.md.html @@ -1,13 +1,13 @@ -(#) Flags dimensions that are not defined as resource. +(#) Flags dimensions that are not defined as resource -!!! WARNING: Flags dimensions that are not defined as resource. +!!! WARNING: Flags dimensions that are not defined as resource This is a warning. Id : `RawDimen` Summary -: Flags dimensions that are not defined as resource. +: Flags dimensions that are not defined as resource Severity : Warning Category @@ -29,6 +29,10 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/RawDimenDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/RawDimenDetectorTest.kt) Dimensions should all be defined as dimension resources. This has the benefit that you can easily see all of your dimensions in one file. One @@ -36,6 +40,32 @@ you only have to adjust it in one place. This check will run on layouts as well as xml drawables. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:1:Warning: Should be using a dimension resource +instead. [RawDimen] +<TextView xmlns:app="http://schemas.android.com/apk/res-auto" app:someCustomAttribute="16dp"/> + ---- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView xmlns:app="http://schemas.android.com/apk/res-auto" app:someCustomAttribute="16dp"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/RawDimenDetectorTest.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, `RawDimenDetector.appCustom`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RawDispatchersUse.md.html b/docs/checks/RawDispatchersUse.md.html index 1102ecb..08c1c7e 100644 --- a/docs/checks/RawDispatchersUse.md.html +++ b/docs/checks/RawDispatchersUse.md.html @@ -1,13 +1,13 @@ -(#) Use SlackDispatchers. +(#) Use SlackDispatchers -!!! ERROR: Use SlackDispatchers. +!!! ERROR: Use SlackDispatchers This is an error. Id : `RawDispatchersUse` Summary -: Use SlackDispatchers. +: Use SlackDispatchers Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/RawDispatchersUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/RawDispatchersUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/RawDispatchersUsageDetectorTest.kt) Copyright Year @@ -48,53 +48,31 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/test.kt:6:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers.IO -------------- - - src/test/pkg/test.kt:7:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers.Default ------------------- - - src/test/pkg/test.kt:8:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers.Unconfined ---------------------- - - src/test/pkg/test.kt:9:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers.Main ---------------- - - src/test/pkg/test.kt:11:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers::IO --------------- - - src/test/pkg/test.kt:12:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers::Default -------------------- - - src/test/pkg/test.kt:13:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers::Unconfined ----------------------- - - src/test/pkg/test.kt:14:Error: Use SlackDispatchers. [RawDispatchersUse] - Dispatchers::Main ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Recycle.md.html b/docs/checks/Recycle.md.html index 8dc580f..9ac573d 100644 --- a/docs/checks/Recycle.md.html +++ b/docs/checks/Recycle.md.html @@ -39,63 +39,38 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/RecycleTest.java:56:Warning: This TypedArray should be recycled after use with #recycle() [Recycle] - final TypedArray a = getContext().obtainStyledAttributes(attrs, ---------------------- - - src/test/pkg/RecycleTest.java:63:Warning: This TypedArray should be recycled after use with #recycle() [Recycle] - final TypedArray a = getContext().obtainStyledAttributes(new int[0]); ---------------------- - - src/test/pkg/RecycleTest.java:79:Warning: This VelocityTracker should be recycled after use with #recycle() [Recycle] - VelocityTracker tracker = VelocityTracker.obtain(); ------ - - src/test/pkg/RecycleTest.java:92:Warning: This MotionEvent should be recycled after use with #recycle() [Recycle] - MotionEvent event1 = MotionEvent.obtain(null); ------ - - src/test/pkg/RecycleTest.java:93:Warning: This MotionEvent should be recycled after use with #recycle() [Recycle] - MotionEvent event2 = MotionEvent.obtainNoHistory(null); --------------- - - src/test/pkg/RecycleTest.java:98:Warning: This MotionEvent should be recycled after use with #recycle() [Recycle] - MotionEvent event2 = MotionEvent.obtainNoHistory(null); // Not recycled --------------- - - src/test/pkg/RecycleTest.java:103:Warning: This MotionEvent should be recycled after use with #recycle() [Recycle] - MotionEvent event1 = MotionEvent.obtain(null); // Not recycled ------ - - src/test/pkg/RecycleTest.java:129:Warning: This Parcel should be recycled after use with #recycle() [Recycle] - Parcel myparcel = Parcel.obtain(); ------ - - src/test/pkg/RecycleTest.java:190:Warning: This TypedArray should be recycled after use with #recycle() [Recycle] - final TypedArray a = getContext().obtainStyledAttributes(attrs, // Not recycled ---------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RecyclerView.md.html b/docs/checks/RecyclerView.md.html index 655a48a..6c44b55 100644 --- a/docs/checks/RecyclerView.md.html +++ b/docs/checks/RecyclerView.md.html @@ -48,31 +48,21 @@ src/test/pkg/RecyclerViewTest.java:69:Error: Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later [RecyclerView] - public void onBindViewHolder(ViewHolder holder, int position) { ------------ - - src/test/pkg/RecyclerViewTest.java:82:Error: Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later [RecyclerView] - public void onBindViewHolder(ViewHolder holder, final int position) { ------------------ - - src/test/pkg/RecyclerViewTest.java:102:Error: Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later [RecyclerView] - public void onBindViewHolder(ViewHolder holder, final int position) { ------------------ - - src/test/pkg/RecyclerViewTest.java:111:Error: Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later [RecyclerView] - public void onBindViewHolder(ViewHolder holder, final int position, List<Object> payloads) { ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RedactedInJavaUsage.md.html b/docs/checks/RedactedInJavaUsage.md.html index dedfae3..9d564b3 100644 --- a/docs/checks/RedactedInJavaUsage.md.html +++ b/docs/checks/RedactedInJavaUsage.md.html @@ -1,13 +1,13 @@ -(#) @Redacted is only supported in Kotlin classes! +(#) @Redacted is only supported in Kotlin classes -!!! ERROR: @Redacted is only supported in Kotlin classes! +!!! ERROR: @Redacted is only supported in Kotlin classes This is an error. Id : `RedactedInJavaUsage` Summary -: @Redacted is only supported in Kotlin classes! +: @Redacted is only supported in Kotlin classes Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/RedactedUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/RedactedUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/RedactedUsageDetectorTest.kt) Copyright Year @@ -48,26 +48,33 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/RedactedClass.java:6:Error: @Redacted is only supported in Kotlin classes! [RedactedInJavaUsage] - @Redacted --------- - - src/test/pkg/RedactedClass.java:8:Error: @Redacted is only supported in Kotlin classes! [RedactedInJavaUsage] - @Redacted --------- - - src/test/pkg/RedactedClass.java:13:Error: @Redacted is only supported in Kotlin classes! [RedactedInJavaUsage] - @Redacted --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/RedactedClass.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import slack.annotations.Redacted +import slack.annotations.AnotherRedacted +import slack.annotations.AnotherAnnotation + +@Redacted +data class RedactedClass(val value: String) + +data class RedactedProps(@Redacted val value: String) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/RedactedClass.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -100,6 +107,25 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/AnotherRedactedClass.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import slack.annotations.Redacted; +import slack.annotations.AnotherRedacted; + +@AnotherRedacted +class AnotherRedactedClass { + @AnotherRedacted + int value; + + @AnotherRedacted + public int getValue() { + return value; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/RedactedUsageDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/RedundantBinds.md.html b/docs/checks/RedundantBinds.md.html index 4dff5b5..683a563 100644 --- a/docs/checks/RedundantBinds.md.html +++ b/docs/checks/RedundantBinds.md.html @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/DaggerIssuesDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/DaggerIssuesDetectorTest.kt) Copyright Year @@ -49,14 +49,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/MyQualifier.kt:13:Error: @Binds functions should return a different type [RedundantBinds] - @Binds fun invalidBind(real: Long): Long ---------------------------------------- - - src/foo/MyQualifier.kt:14:Error: @Binds functions should return a different type [RedundantBinds] - @Binds fun invalidBind(real: Long): Long ---------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RedundantLabel.md.html b/docs/checks/RedundantLabel.md.html index b804326..83a8403 100644 --- a/docs/checks/RedundantLabel.md.html +++ b/docs/checks/RedundantLabel.md.html @@ -39,7 +39,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:7:Warning: Redundant label can be removed [RedundantLabel] - <activity android:name=".MainActivity" android:label="@string/app_name"> -------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RedundantNamespace.md.html b/docs/checks/RedundantNamespace.md.html index 0519e6e..c4d5f49 100644 --- a/docs/checks/RedundantNamespace.md.html +++ b/docs/checks/RedundantNamespace.md.html @@ -43,7 +43,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/customview2.xml:8:Warning: This namespace declaration is redundant [RedundantNamespace] - xmlns:android="http://schemas.android.com/apk/res/android" ---------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ReferenceType.md.html b/docs/checks/ReferenceType.md.html index dc4368d..34ace87 100644 --- a/docs/checks/ReferenceType.md.html +++ b/docs/checks/ReferenceType.md.html @@ -43,28 +43,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/refs.xml:3:Error: Unexpected resource reference type; expected value of type @string/ [ReferenceType] - <item name="invalid1" type="string">@layout/other</item> ------------- - - res/values/refs.xml:5:Error: Unexpected resource reference type; expected value of type @drawable/ [ReferenceType] - @layout/other ------------- - - res/values/refs.xml:10:Error: Unexpected resource reference type; expected value of type @string/ [ReferenceType] - <string name="invalid4">@layout/indirect</string> ---------------- - - res/values/refs.xml:15:Error: Unexpected resource reference type; expected value of type @color/ [ReferenceType] - <item name="drawableAsColor" type="color">@drawable/my_drawable</item> --------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Registered.md.html b/docs/checks/Registered.md.html index f0e4a61..a767d84 100644 --- a/docs/checks/Registered.md.html +++ b/docs/checks/Registered.md.html @@ -40,6 +40,52 @@ If your activity is simply a parent class intended to be subclassed by other "real" activities, make it an abstract class. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/test/pkg/MyActivity2.java:5:Warning: The +test.pkg.MyActivity2 is not registered in the manifest [Registered] +public class MyActivity2 extends Activity { + ----------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`src/test/pkg/MyActivity1.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; + +public class MyActivity1 extends Activity { +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/MyActivity2.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.app.Activity; + +public class MyActivity2 extends Activity { +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="test.pkg"> + <application> + <activity android:name=".MyActivity1" /> + </application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/RegistrationDetectorTest.java) +for the unit tests for this check to see additional scenarios. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/RelativeOverlap.md.html b/docs/checks/RelativeOverlap.md.html index d1559fc..d4168fc 100644 --- a/docs/checks/RelativeOverlap.md.html +++ b/docs/checks/RelativeOverlap.md.html @@ -40,7 +40,6 @@ res/layout/relative_overlap.xml:16:Warning: @id/label2 can overlap @id/label1 if @string/label1_text, @string/label2_text grow due to localized text expansion [RelativeOverlap] - <TextView -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RememberReturnType.md.html b/docs/checks/RememberReturnType.md.html index c8f3e0b..5422532 100644 --- a/docs/checks/RememberReturnType.md.html +++ b/docs/checks/RememberReturnType.md.html @@ -53,140 +53,82 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/androidx/compose/runtime/foo/FooState.kt:14:Error: remember calls must not return Unit [RememberReturnType] - remember { -------- - - src/androidx/compose/runtime/foo/FooState.kt:17:Error: remember calls must not return Unit [RememberReturnType] - val unit = remember { -------- - - src/androidx/compose/runtime/foo/FooState.kt:21:Error: remember calls must not return Unit [RememberReturnType] - remember(unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:22:Error: remember calls must not return Unit [RememberReturnType] - val unit2 = remember(unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:28:Error: remember calls must not return Unit [RememberReturnType] - remember(number) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:31:Error: remember calls must not return Unit [RememberReturnType] - val unit = remember(number) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:35:Error: remember calls must not return Unit [RememberReturnType] - remember(number, unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:36:Error: remember calls must not return Unit [RememberReturnType] - val unit2 = remember(number, unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:42:Error: remember calls must not return Unit [RememberReturnType] - remember(number1, number2) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:46:Error: remember calls must not return Unit [RememberReturnType] - val unit = remember(number1, number2) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:51:Error: remember calls must not return Unit [RememberReturnType] - remember(number1, number2, unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:52:Error: remember calls must not return Unit [RememberReturnType] - val unit2 = remember(number1, number2, unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:58:Error: remember calls must not return Unit [RememberReturnType] - remember(number1, number2, number3) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:63:Error: remember calls must not return Unit [RememberReturnType] - val unit = remember(number1, number2, number3) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:69:Error: remember calls must not return Unit [RememberReturnType] - remember(number1, number2, number3, unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:70:Error: remember calls must not return Unit [RememberReturnType] - val unit2 = remember(number1, number2, number3, unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:76:Error: remember calls must not return Unit [RememberReturnType] - remember(number1, number2, number3, flag) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:81:Error: remember calls must not return Unit [RememberReturnType] - val unit = remember(number1, number2, number3, flag) { -------- - - src/androidx/compose/runtime/foo/FooState.kt:87:Error: remember calls must not return Unit [RememberReturnType] - remember(number1, number2, number3, flag, calculation = unitLambda) -------- - - src/androidx/compose/runtime/foo/FooState.kt:88:Error: remember calls must not return Unit [RememberReturnType] - val unit2 = remember(number1, number2, number3, flag, calculation = unitLambda) -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -302,17 +244,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -320,7 +262,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/RememberSaveableSaverParameter.md.html b/docs/checks/RememberSaveableSaverParameter.md.html index f19a6eb..140de45 100644 --- a/docs/checks/RememberSaveableSaverParameter.md.html +++ b/docs/checks/RememberSaveableSaverParameter.md.html @@ -53,56 +53,34 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/Foo.kt:15:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val foo = rememberSaveable(FooSaver) { Foo() } -------- - - src/test/Foo.kt:16:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val mutableStateFoo = rememberSaveable(FooSaver) { mutableStateOf(Foo()) } -------- - - src/test/Foo.kt:17:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val foo2 = rememberSaveable(FooSaver2()) { Foo() } ----------- - - src/test/Foo.kt:18:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val mutableStateFoo2 = rememberSaveable(FooSaver2()) { mutableStateOf(Foo()) } ----------- - - src/test/Foo.kt:19:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val foo3 = rememberSaveable(fooSaver3) { Foo() } --------- - - src/test/Foo.kt:20:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val mutableStateFoo3 = rememberSaveable(fooSaver3) { mutableStateOf(Foo()) } --------- - - src/test/Foo.kt:21:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val foo4 = rememberSaveable(fooSaver4) { Foo() } --------- - - src/test/Foo.kt:22:Error: Passing Saver instance to vararg inputs [RememberSaveableSaverParameter] - val mutableStateFoo4 = rememberSaveable(fooSaver4) { mutableStateOf(Foo()) } --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -152,17 +130,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-saveable-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-saveable-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-saveable-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-saveable-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-saveable-android) # libs.versions.toml [versions] -runtime-saveable-android = "1.7.0-beta04" +runtime-saveable-android = "1.7.0-beta05" [libraries] runtime-saveable-android = { module = "androidx.compose.runtime:runtime-saveable-android", @@ -170,7 +148,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-saveable-android](androidx_compose_runtime_runtime-saveable-android.md.html). diff --git a/docs/checks/RemoteViewLayout.md.html b/docs/checks/RemoteViewLayout.md.html index aaf3ada..28674f8 100644 --- a/docs/checks/RemoteViewLayout.md.html +++ b/docs/checks/RemoteViewLayout.md.html @@ -40,7 +40,6 @@ src/test/pkg/test.kt:5:Error: @layout/test includes views not allowed in a RemoteView: CheckBox, DatePicker, RadioButton, RadioGroup, Switch, androidx.appcompat.widget.AppCompatTextView [RemoteViewLayout] - val remoteView = RemoteViews(packageName, R.layout.test) --------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -88,7 +87,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `test.pkg`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linenumbers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers @layout/test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RemoveWorkManagerInitializer.md.html b/docs/checks/RemoveWorkManagerInitializer.md.html index e52c4c0..cb4a36d 100644 --- a/docs/checks/RemoveWorkManagerInitializer.md.html +++ b/docs/checks/RemoveWorkManagerInitializer.md.html @@ -1,7 +1,7 @@ -(#) Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization. +(#) Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization -!!! ERROR: Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization. +!!! ERROR: Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization This is an error, and is also enforced at build time when supported by the build system. For Android this means it will run during release builds. @@ -9,7 +9,7 @@ Id : `RemoveWorkManagerInitializer` Summary -: Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization. +: Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization Severity : Fatal Category @@ -53,12 +53,11 @@ AndroidManifest.xml:4:Error: Remove androidx.work.WorkManagerInitializer from your AndroidManifest.xml when using on-demand initialization. [RemoveWorkManagerInitializer] - <application /> --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -69,6 +68,22 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`com/example/App.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import android.app.Application +import androidx.work.Configuration + +class App: Application(), Configuration.Provider { + override fun onCreate() { + + } + + override fun getWorkManagerConfiguration(): Configuration = TODO() +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/work-lint/src/test/java/androidx/work/lint/RemoveWorkManagerInitializerDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/RepeatOnLifecycleWrongUsage-2.md.html b/docs/checks/RepeatOnLifecycleWrongUsage-2.md.html index 73ae136..4cd7d45 100644 --- a/docs/checks/RepeatOnLifecycleWrongUsage-2.md.html +++ b/docs/checks/RepeatOnLifecycleWrongUsage-2.md.html @@ -1,13 +1,13 @@ -(#) Wrong usage of repeatOnLifecycle. +(#) Wrong usage of repeatOnLifecycle -!!! ERROR: Wrong usage of repeatOnLifecycle. +!!! ERROR: Wrong usage of repeatOnLifecycle This is an error. Id : `RepeatOnLifecycleWrongUsage` Summary -: Wrong usage of repeatOnLifecycle. +: Wrong usage of repeatOnLifecycle Severity : Error Category @@ -32,9 +32,9 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-ktx-lint/src/main/java/androidx/lifecycle/lint/RepeatOnLifecycleDetector.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-lint/src/main/java/androidx/lifecycle/lint/RepeatOnLifecycleDetector.kt) Tests -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-ktx-lint/src/test/java/androidx/lifecycle/runtime/lint/RepeatOnLifecycleDetectorTest.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-lint/src/test/java/androidx/lifecycle/runtime/lint/RepeatOnLifecycleDetectorTest.kt) Copyright Year : 2021 @@ -47,7 +47,7 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* RepeatOnLifecycleWrongUsage: Wrong usage of repeatOnLifecycle. (this issue) +* RepeatOnLifecycleWrongUsage: Wrong usage of repeatOnLifecycle (this issue) * [RepeatOnLifecycleWrongUsage from androidx.lifecycle:lifecycle-runtime-android:2.8.3](RepeatOnLifecycleWrongUsage.md.html) * [RepeatOnLifecycleWrongUsage from androidx.lifecycle:lifecycle-runtime-ktx:2.8.0-alpha01](RepeatOnLifecycleWrongUsage-2.md.html) diff --git a/docs/checks/RepeatOnLifecycleWrongUsage.md.html b/docs/checks/RepeatOnLifecycleWrongUsage.md.html index ae2d8e7..4a6250e 100644 --- a/docs/checks/RepeatOnLifecycleWrongUsage.md.html +++ b/docs/checks/RepeatOnLifecycleWrongUsage.md.html @@ -1,13 +1,13 @@ -(#) Wrong usage of repeatOnLifecycle. +(#) Wrong usage of repeatOnLifecycle -!!! ERROR: Wrong usage of repeatOnLifecycle. +!!! ERROR: Wrong usage of repeatOnLifecycle This is an error. Id : `RepeatOnLifecycleWrongUsage` Summary -: Wrong usage of repeatOnLifecycle. +: Wrong usage of repeatOnLifecycle Severity : Error Category @@ -32,9 +32,9 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-ktx-lint/src/main/java/androidx/lifecycle/lint/RepeatOnLifecycleDetector.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-lint/src/main/java/androidx/lifecycle/lint/RepeatOnLifecycleDetector.kt) Tests -: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-ktx-lint/src/test/java/androidx/lifecycle/runtime/lint/RepeatOnLifecycleDetectorTest.kt) +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-lint/src/test/java/androidx/lifecycle/runtime/lint/RepeatOnLifecycleDetectorTest.kt) Copyright Year : 2021 @@ -47,7 +47,7 @@ This lint check appears to have been packaged in other artifacts as well. Issue id's must be unique, so you cannot combine these libraries. Also defined in: -* RepeatOnLifecycleWrongUsage: Wrong usage of repeatOnLifecycle. (this issue) +* RepeatOnLifecycleWrongUsage: Wrong usage of repeatOnLifecycle (this issue) * [RepeatOnLifecycleWrongUsage from androidx.lifecycle:lifecycle-runtime-android:2.8.3](RepeatOnLifecycleWrongUsage.md.html) * [RepeatOnLifecycleWrongUsage from androidx.lifecycle:lifecycle-runtime-ktx:2.8.0-alpha01](RepeatOnLifecycleWrongUsage-2.md.html) diff --git a/docs/checks/ReportShortcutUsage.md.html b/docs/checks/ReportShortcutUsage.md.html index 259b9a7..a3887a2 100644 --- a/docs/checks/ReportShortcutUsage.md.html +++ b/docs/checks/ReportShortcutUsage.md.html @@ -46,7 +46,6 @@ based on activation history. Please see https://developer.android.com/develop/ui/views/launch/shortcuts/managing-shortcuts#track-usage [ReportShortcutUsage] - ShortcutManagerCompat.setDynamicShortcuts(context, shortcuts); ------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RequiredSize.md.html b/docs/checks/RequiredSize.md.html index 8d44b2c..670f324 100644 --- a/docs/checks/RequiredSize.md.html +++ b/docs/checks/RequiredSize.md.html @@ -44,21 +44,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/size.xml:13:Error: The required layout_height attribute is missing [RequiredSize] - <RadioButton ----------- - - res/layout/size.xml:18:Error: The required layout_width attribute is missing [RequiredSize] - <EditText -------- - - res/layout/size.xml:23:Error: The required layout_width and layout_height attributes are missing [RequiredSize] - <EditText -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RequiresFeature.md.html b/docs/checks/RequiresFeature.md.html index 0522441..30a5ffd 100644 --- a/docs/checks/RequiresFeature.md.html +++ b/docs/checks/RequiresFeature.md.html @@ -39,76 +39,51 @@ src/test/pkg/CheckFeatures.java:10:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 1 - ERROR ---------------- - - src/test/pkg/CheckFeatures.java:12:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 2 - ERROR ---------------- - - src/test/pkg/CheckFeatures.java:33:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 6 - ERROR - wrong name ---------------- - - src/test/pkg/CheckFeatures.java:39:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 7 - ERROR - inverted logic ---------------- - - src/test/pkg/CheckFeatures.java:52:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - return FeatureChecker.hasFeature("wrong.name") && api.someMethod(); // 10 - ERROR ---------------- - - src/test/pkg/CheckFeatures.java:56:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - return FeatureChecker.hasFeature("wrong.name") || api.someMethod(); // 11 - ERROR ---------------- - - src/test/pkg/CheckFeatures.java:70:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 13 - ERROR: inverted logic in earl exit ---------------- - - src/test/pkg/CheckFeatures.java:92:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 16 - ERROR ---------------- - - src/test/pkg/CheckFeatures.java:99:Warning: someMethod should only be called if the feature some.name is present; to check call test.framework.pkg.FeatureChecker#hasFeature [RequiresFeature] - api.someMethod(); // 17 - ERROR ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/CheckFeatures.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -216,6 +191,72 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/test/pkg/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package test.pkg + +import test.framework.pkg.FeatureChecker + +fun testLambdas() { + val api = SomeApi() + api.applyIfHasFeatureX { + someMethod() // OK - checked in lambda + } + api.applyIfHasFeatureY { + someMethod() // ERROR - not checked in lambda + } +} + +inline fun T.applyIfHasFeatureX(block: T.() -> Unit): T { + if (FeatureChecker.hasFeature("some.name")) { + block() + } + return this +} + +inline fun T.applyIfHasFeatureY(block: T.() -> Unit): T { + if (FeatureChecker.hasFeature("some.other.feature")) { + block() + } + return this +} + +fun testPropertySyntax() { + val api = SomeOtherApi() + if (api.supportsFeatureX) { + SomeApi().someMethod() // OK - checked via utility method accessed via property syntax + } +} + +class SomeOtherApi { + val supportsFeatureX get() = FeatureChecker.hasFeature("some.name") +} + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/framework/pkg/FeatureChecker.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.framework.pkg; + +@SuppressWarnings({"ClassNameDiffersFromFileName", "MethodMayBeStatic"}) +public class FeatureChecker { + public static boolean hasFeature(String name) { return true; } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/test/pkg/SomeApi.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import androidx.annotation.RequiresFeature; + +@SuppressWarnings({"ClassNameDiffersFromFileName", "MethodMayBeStatic"}) +public class SomeApi { + @RequiresFeature(name = "some.name", enforcement = "test.framework.pkg.FeatureChecker#hasFeature") + public boolean someMethod() { return true; } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/RequiresFeatureDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ResAuto.md.html b/docs/checks/ResAuto.md.html index 1922737..7974bc0 100644 --- a/docs/checks/ResAuto.md.html +++ b/docs/checks/ResAuto.md.html @@ -48,7 +48,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/customview.xml:5:Error: In Gradle projects, always use http://schemas.android.com/apk/res-auto for custom attributes [ResAuto] - xmlns:foo="http://schemas.android.com/apk/res/foo" -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ReservedSystemPermission.md.html b/docs/checks/ReservedSystemPermission.md.html index a3f42cc..a25764a 100644 --- a/docs/checks/ReservedSystemPermission.md.html +++ b/docs/checks/ReservedSystemPermission.md.html @@ -44,14 +44,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:4:Error: android.permission.BIND_APPWIDGET is a reserved permission [ReservedSystemPermission] - <permission android:name="android.permission.BIND_APPWIDGET" /> --------------------------------- - - AndroidManifest.xml:5:Error: android.permission.FOOBAR is using the reserved system prefix android. [ReservedSystemPermission] - <permission android:name="android.permission.FOOBAR" /> ------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ResourceAsColor.md.html b/docs/checks/ResourceAsColor.md.html index 97a7a60..956cf21 100644 --- a/docs/checks/ResourceAsColor.md.html +++ b/docs/checks/ResourceAsColor.md.html @@ -44,44 +44,31 @@ src/test/pkg/WrongColor.java:9:Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.blue) [ResourceAsColor] - paint2.setColor(R.color.blue); ------------ - - src/test/pkg/WrongColor.java:11:Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.red) [ResourceAsColor] - textView.setTextColor(R.color.red); ----------- - - src/test/pkg/WrongColor.java:12:Error: Should pass resolved color instead of resource id here: getResources().getColor(android.R.color.black) [ResourceAsColor] - textView.setTextColor(android.R.color.black); --------------------- - - src/test/pkg/WrongColor.java:13:Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.green) [ResourceAsColor] - textView.setTextColor(foo > 0 ? R.color.green : R.color.blue); ------------- - - src/test/pkg/WrongColor.java:21:Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.blue) [ResourceAsColor] - foo2(R.color.blue); ------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/WrongColor.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -116,6 +103,11 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`test.pkg`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers +@color/blue +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/ResourceTypeDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/ResourceCycle.md.html b/docs/checks/ResourceCycle.md.html index 5593681..8d34b83 100644 --- a/docs/checks/ResourceCycle.md.html +++ b/docs/checks/ResourceCycle.md.html @@ -40,7 +40,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/styles.xml:9:Error: Style DetailsPage_EditorialBuyButton should not extend itself [ResourceCycle] - <style name="DetailsPage_EditorialBuyButton" parent="@style/DetailsPage_EditorialBuyButton" /> ---------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ResourceName.md.html b/docs/checks/ResourceName.md.html index 6804bbb..fa50010 100644 --- a/docs/checks/ResourceName.md.html +++ b/docs/checks/ResourceName.md.html @@ -36,6 +36,53 @@ don't accidentally combine resources from different libraries, since they all end up in the same shared app namespace. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/main/res/layout/activity_main.xml:2:Error: Resource named +'activity_main' does not start with the project's resource prefix +'unit_test_prefix_'; rename to 'unit_test_prefix_activity_main' ? +[ResourceName] +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + ------------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here are the relevant source files: + +`build.gradle`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers +apply plugin: 'com.android.library' + +android { + resourcePrefix 'unit_test_prefix_' +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/main/res/layout/activity_main.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`src/main/res/layout/unit_test_prefix_ok.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/ResourcePrefixDetectorTest.java) +for the unit tests for this check to see additional scenarios. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/ResourceType.md.html b/docs/checks/ResourceType.md.html index fa3c29a..be1f9bb 100644 --- a/docs/checks/ResourceType.md.html +++ b/docs/checks/ResourceType.md.html @@ -37,7 +37,6 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test.kt:9:Error: Expected resource of type string [ResourceType] - setLabels(iconId) // bug: should have passed descId. Both are ints but of wrong type. ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ResourcesGetColorCall.md.html b/docs/checks/ResourcesGetColorCall.md.html index 2428c0a..11d44eb 100644 --- a/docs/checks/ResourcesGetColorCall.md.html +++ b/docs/checks/ResourcesGetColorCall.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of deprecated getColor() on Resources. +(#) Marks usage of deprecated getColor() on Resources -!!! WARNING: Marks usage of deprecated getColor() on Resources. +!!! WARNING: Marks usage of deprecated getColor() on Resources This is a warning. Id : `ResourcesGetColorCall` Summary -: Marks usage of deprecated getColor() on Resources. +: Marks usage of deprecated getColor() on Resources Severity : Warning Category @@ -29,10 +29,47 @@ : 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/kotlin/com/vanniktech/lintrules/android/AndroidDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AndroidDetectorTest.kt) Instead of getColor(), ContextCompat or the method with the Theme Overload should be used instead. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:6:Warning: Calling deprecated getColor +[ResourcesGetColorCall] + resources.getColor(0); + -------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; +import android.content.res.Resources; +class Example { + public void foo() { + Resources resources = null; + resources.getColor(0); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AndroidDetectorTest.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, `AndroidDetector.callingGetColor`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/ResourcesGetColorStateListCall.md.html b/docs/checks/ResourcesGetColorStateListCall.md.html index 64c5ce3..c688564 100644 --- a/docs/checks/ResourcesGetColorStateListCall.md.html +++ b/docs/checks/ResourcesGetColorStateListCall.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of deprecated getColorStateList() on Resources. +(#) Marks usage of deprecated getColorStateList() on Resources -!!! WARNING: Marks usage of deprecated getColorStateList() on Resources. +!!! WARNING: Marks usage of deprecated getColorStateList() on Resources This is a warning. Id : `ResourcesGetColorStateListCall` Summary -: Marks usage of deprecated getColorStateList() on Resources. +: Marks usage of deprecated getColorStateList() on Resources Severity : Warning Category @@ -29,10 +29,47 @@ : 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/kotlin/com/vanniktech/lintrules/android/AndroidDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AndroidDetectorTest.kt) Instead of getColorStateList(), ContextCompat or the method with the Theme Overload should be used instead. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:6:Warning: Calling deprecated getColorStateList +[ResourcesGetColorStateListCall] + resources.getColorStateList(0); + ----------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; +import android.content.res.Resources; +class Example { + public void foo() { + Resources resources = null; + resources.getColorStateList(0); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AndroidDetectorTest.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, `AndroidDetector.callingGetColorStateList`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/ResourcesGetDrawableCall.md.html b/docs/checks/ResourcesGetDrawableCall.md.html index a9c822d..6368437 100644 --- a/docs/checks/ResourcesGetDrawableCall.md.html +++ b/docs/checks/ResourcesGetDrawableCall.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of deprecated getDrawable() on Resources. +(#) Marks usage of deprecated getDrawable() on Resources -!!! WARNING: Marks usage of deprecated getDrawable() on Resources. +!!! WARNING: Marks usage of deprecated getDrawable() on Resources This is a warning. Id : `ResourcesGetDrawableCall` Summary -: Marks usage of deprecated getDrawable() on Resources. +: Marks usage of deprecated getDrawable() on Resources Severity : Warning Category @@ -29,10 +29,47 @@ : 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/kotlin/com/vanniktech/lintrules/android/AndroidDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AndroidDetectorTest.kt) Instead of getDrawable(), ContextCompat or the method with the Theme Overload should be used instead. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:6:Warning: Calling deprecated getDrawable +[ResourcesGetDrawableCall] + resources.getDrawable(0); + ----------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; +import android.content.res.Resources; +class Example { + public void foo() { + Resources resources = null; + resources.getDrawable(0); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AndroidDetectorTest.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, `AndroidDetector.callingGetDrawable`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RestrictCallsTo.md.html b/docs/checks/RestrictCallsTo.md.html index 0e22805..767dcd0 100644 --- a/docs/checks/RestrictCallsTo.md.html +++ b/docs/checks/RestrictCallsTo.md.html @@ -1,13 +1,13 @@ -(#) Methods annotated with @RestrictedCallsTo should only be called from the specified scope. +(#) Methods annotated with @RestrictedCallsTo should only be called from the specified scope -!!! ERROR: Methods annotated with @RestrictedCallsTo should only be called from the specified scope. +!!! ERROR: Methods annotated with @RestrictedCallsTo should only be called from the specified scope This is an error. Id : `RestrictCallsTo` Summary -: Methods annotated with @RestrictedCallsTo should only be called from the specified scope. +: Methods annotated with @RestrictedCallsTo should only be called from the specified scope Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/RestrictCallsToDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/RestrictCallsToDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/RestrictCallsToDetectorTest.kt) Copyright Year @@ -51,28 +51,55 @@ src/foo/DifferentFile.kt:8:Error: Methods annotated with @RestrictedCallsTo should only be called from the specified scope. [RestrictCallsTo] - api.annotatedExample() ---------------------- - - src/foo/DifferentFile.kt:15:Error: Methods annotated with @RestrictedCallsTo should only be called from the specified scope. [RestrictCallsTo] - annotatedExample() ------------------ - - src/foo/DifferentFile.kt:26:Error: Methods annotated with @RestrictedCallsTo should only be called from the specified scope. [RestrictCallsTo] - MyApiImpl().annotatedExample() ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/foo/MyApi.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo + +import slack.lint.annotations.RestrictCallsTo +import slack.lint.annotations.RestrictCallsTo.Companion.FILE + +interface MyApi { + fun example() + + @RestrictCallsTo(FILE) + fun annotatedExample() +} + +class SameFile { + fun doStuffWith(api: MyApi) { + // This is ok + api.example() + api.annotatedExample() + } +} + +class MyApiImpl : MyApi { + override fun example() { + annotatedExample() + } + + // Note this is not annotated, ensures we check up the hierarchy + override fun annotatedExample() { + println("Hello") + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/foo/DifferentFile.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers diff --git a/docs/checks/RestrictedApi.md.html b/docs/checks/RestrictedApi.md.html index 7537793..cf9c772 100644 --- a/docs/checks/RestrictedApi.md.html +++ b/docs/checks/RestrictedApi.md.html @@ -46,14 +46,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/RestrictToSubclassTest.java:26:Error: Class1.onSomething can only be called from subclasses [RestrictedApi] - cls.onSomething(); // ERROR: Not from subclass ----------- - - src/test/pkg/RestrictToSubclassTest.java:27:Error: Class1.counter can only be accessed from subclasses [RestrictedApi] - int counter = cls.counter; // ERROR: Not from subclass ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RetrofitUsage.md.html b/docs/checks/RetrofitUsage.md.html index b54e2d3..942faee 100644 --- a/docs/checks/RetrofitUsage.md.html +++ b/docs/checks/RetrofitUsage.md.html @@ -1,13 +1,13 @@ -(#) This is replaced by the caller. +(#) This is replaced by the caller -!!! ERROR: This is replaced by the caller. +!!! ERROR: This is replaced by the caller This is an error. Id : `RetrofitUsage` Summary -: This is replaced by the caller. +: This is replaced by the caller Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/retrofit/RetrofitUsageDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/retrofit/RetrofitUsageDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/retrofit/RetrofitUsageDetectorTest.kt) Copyright Year @@ -51,21 +51,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/Example.kt:11:Error: @FormUrlEncoded requires @PUT, @POST, or @PATCH. [RetrofitUsage] - fun wrongMethod(): String ----------- - - src/test/Example.kt:14:Error: @FormUrlEncoded but has no @Field(Map) parameters. [RetrofitUsage] - @FormUrlEncoded --------------- - - src/test/Example.kt:18:Error: @Field(Map) param requires @FormUrlEncoded. [RetrofitUsage] - fun missingAnnotation(@Field("hi") input: String): String ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ReturnFromAwaitPointerEventScope.md.html b/docs/checks/ReturnFromAwaitPointerEventScope.md.html index d791e68..4703bf6 100644 --- a/docs/checks/ReturnFromAwaitPointerEventScope.md.html +++ b/docs/checks/ReturnFromAwaitPointerEventScope.md.html @@ -52,17 +52,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -70,7 +70,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/ReturnThis.md.html b/docs/checks/ReturnThis.md.html index 287555d..f37f3ea 100644 --- a/docs/checks/ReturnThis.md.html +++ b/docs/checks/ReturnThis.md.html @@ -38,7 +38,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/Builder.kt:18:Error: This method should return this (because it has been annotated with @ReturnThis) [ReturnThis] - return MyClass() ---------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RiskyLibrary.md.html b/docs/checks/RiskyLibrary.md.html index c60c5ac..e4f47ec 100644 --- a/docs/checks/RiskyLibrary.md.html +++ b/docs/checks/RiskyLibrary.md.html @@ -56,7 +56,6 @@ log4j:log4j version 1.2.13 has been reported as problematic by its author and will block publishing of your app to Play Console [RiskyLibrary] - compile 'log4j:log4j:1.2.13' // Critical BLOCKING -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RtlCompat.md.html b/docs/checks/RtlCompat.md.html index 7d0eeb2..29b423b 100644 --- a/docs/checks/RtlCompat.md.html +++ b/docs/checks/RtlCompat.md.html @@ -44,71 +44,46 @@ res/layout/relative.xml:10:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_alignParentLeft="true" [RtlCompat] - android:layout_alignParentStart="true" ------------------------------- - - res/layout/relative.xml:13:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_marginLeft="40dip" [RtlCompat] - android:layout_marginStart="40dip" -------------------------- - - res/layout/relative.xml:24:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_marginLeft="40dip" [RtlCompat] - android:layout_marginStart="40dip" -------------------------- - - res/layout/relative.xml:26:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_toRightOf="@id/loading_progress" [RtlCompat] - android:layout_toEndOf="@id/loading_progress" ---------------------- - - res/layout/relative.xml:29:Error: To support older versions than API 17 (project specifies 5) you should also add android:paddingRight="120dip" [RtlCompat] - android:paddingEnd="120dip" ------------------ - - res/layout/relative.xml:37:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_alignParentLeft="true" [RtlCompat] - android:layout_alignParentStart="true" ------------------------------- - - res/layout/relative.xml:38:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_alignRight="@id/text" [RtlCompat] - android:layout_alignEnd="@id/text" ----------------------- - - res/layout/relative.xml:47:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_alignLeft="@id/cancel" [RtlCompat] - android:layout_alignStart="@id/cancel" ------------------------- - - res/layout/relative.xml:48:Error: To support older versions than API 17 (project specifies 5) you should also add android:layout_alignRight="@id/cancel" [RtlCompat] - android:layout_alignEnd="@id/cancel" ----------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RtlEnabled.md.html b/docs/checks/RtlEnabled.md.html index e5aca1e..017da0b 100644 --- a/docs/checks/RtlEnabled.md.html +++ b/docs/checks/RtlEnabled.md.html @@ -44,11 +44,10 @@ AndroidManifest.xml:Warning: The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest [RtlEnabled] - 0 errors, 4 warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `AndroidManifest.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers @@ -58,6 +57,76 @@ </manifest> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/layout/rtl.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + tools:ignore="HardcodedText" > + + <!-- Warn: Use start instead of left --> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="left" + android:text="Button" /> + + <!-- Warn: Use end instead of right with layout_gravity --> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:text="Button" /> + + <!-- Warn: Use end instead of right with gravity --> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="right" + android:text="TextView" /> + + <!-- OK: No warning --> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="start" + android:text="Button" /> + + <!-- OK: No warning --> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:text="Button" /> + + <!-- OK: No warning --> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="end" + android:text="TextView" /> + + <!-- OK: Suppressed --> + + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:text="Button" + tools:ignore="RtlHardcoded" /> + +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/RtlDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/RtlHardcoded.md.html b/docs/checks/RtlHardcoded.md.html index 7fdaa0e..f037f08 100644 --- a/docs/checks/RtlHardcoded.md.html +++ b/docs/checks/RtlHardcoded.md.html @@ -57,26 +57,27 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/rtl.xml:14:Warning: Use "start" instead of "left" to ensure correct behavior in right-to-left locales [RtlHardcoded] - android:layout_gravity="left" ---- - - res/layout/rtl.xml:22:Warning: Use "end" instead of "right" to ensure correct behavior in right-to-left locales [RtlHardcoded] - android:layout_gravity="right" ----- - - res/layout/rtl.xml:30:Warning: Use "end" instead of "right" to ensure correct behavior in right-to-left locales [RtlHardcoded] - android:gravity="right" ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="test.rtl"> + <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="17" /> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `res/layout/rtl.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers diff --git a/docs/checks/RtlSymmetry.md.html b/docs/checks/RtlSymmetry.md.html index 64b56a6..9e0e296 100644 --- a/docs/checks/RtlSymmetry.md.html +++ b/docs/checks/RtlSymmetry.md.html @@ -40,7 +40,6 @@ res/layout/relative.xml:29:Warning: When you define paddingRight you should probably also define paddingLeft for right-to-left symmetry [RtlSymmetry] - android:paddingRight="120dip" -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/RxJava2DefaultScheduler.md.html b/docs/checks/RxJava2DefaultScheduler.md.html index a4e6131..965eae9 100644 --- a/docs/checks/RxJava2DefaultScheduler.md.html +++ b/docs/checks/RxJava2DefaultScheduler.md.html @@ -1,13 +1,13 @@ -(#) Pass a scheduler instead of relying on the default Scheduler. +(#) Pass a scheduler instead of relying on the default Scheduler -!!! WARNING: Pass a scheduler instead of relying on the default Scheduler. +!!! WARNING: Pass a scheduler instead of relying on the default Scheduler This is a warning. Id : `RxJava2DefaultScheduler` Summary -: Pass a scheduler instead of relying on the default Scheduler. +: Pass a scheduler instead of relying on the default Scheduler Severity : Warning Category @@ -29,11 +29,50 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DefaultSchedulerDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DefaultSchedulerDetectorTest.kt) Calling this method will rely on a default scheduler. This is not necessary the best default. Being explicit and taking the overload for passing one is preferred. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:8:Warning: interval() is using its default +scheduler [RxJava2DefaultScheduler] + Observable.interval(5, TimeUnit.SECONDS); + -------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import java.util.concurrent.TimeUnit; +import io.reactivex.Observable; + +class Example { + public void foo() { + Observable.interval(5, TimeUnit.SECONDS); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DefaultSchedulerDetectorTest.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, `RxJava2DefaultSchedulerDetector.schedulerSupportComputation`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RxJava2DisposableAddAllCall.md.html b/docs/checks/RxJava2DisposableAddAllCall.md.html index 99360ec..f691389 100644 --- a/docs/checks/RxJava2DisposableAddAllCall.md.html +++ b/docs/checks/RxJava2DisposableAddAllCall.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of addAll() on CompositeDisposable. +(#) Marks usage of addAll() on CompositeDisposable -!!! WARNING: Marks usage of addAll() on CompositeDisposable. +!!! WARNING: Marks usage of addAll() on CompositeDisposable This is a warning. Id : `RxJava2DisposableAddAllCall` Summary -: Marks usage of addAll() on CompositeDisposable. +: Marks usage of addAll() on CompositeDisposable Severity : Warning Category @@ -29,10 +29,47 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DisposableAddAllCallDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DisposableAddAllCallDetectorTest.kt) Instead of using addAll(), add() should be used separately for each Disposable. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:6:Warning: Calling addAll instead of add separately +[RxJava2DisposableAddAllCall] + cd.addAll(); + ------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; +import io.reactivex.disposables.CompositeDisposable; +class Example { + public void foo() { + CompositeDisposable cd = null; + cd.addAll(); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DisposableAddAllCallDetectorTest.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, `RxJava2DisposableAddAllCallDetector.callingCompositeDisposableAddAll`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RxJava2DisposableDisposeCall.md.html b/docs/checks/RxJava2DisposableDisposeCall.md.html index 3471f98..b09ef2b 100644 --- a/docs/checks/RxJava2DisposableDisposeCall.md.html +++ b/docs/checks/RxJava2DisposableDisposeCall.md.html @@ -1,13 +1,13 @@ -(#) Marks usage of dispose() on CompositeDisposable. +(#) Marks usage of dispose() on CompositeDisposable -!!! WARNING: Marks usage of dispose() on CompositeDisposable. +!!! WARNING: Marks usage of dispose() on CompositeDisposable This is a warning. Id : `RxJava2DisposableDisposeCall` Summary -: Marks usage of dispose() on CompositeDisposable. +: Marks usage of dispose() on CompositeDisposable Severity : Warning Category @@ -29,11 +29,53 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DisposableDisposeCallDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DisposableDisposeCallDetectorTest.kt) Instead of using dispose(), clear() should be used. Calling clear will result in a CompositeDisposable that can be used further to add more Disposables. When using dispose() this is not the case. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:8:Warning: Calling dispose instead of clear +[RxJava2DisposableDisposeCall] + cd.dispose(); + ------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import io.reactivex.disposables.CompositeDisposable; + +class Example { + public void foo() { + CompositeDisposable cd = null; + cd.dispose(); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2DisposableDisposeCallDetectorTest.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, `RxJava2DisposableDisposeCallDetector.callingCompositeDisposableDispose`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RxJava2MethodMissingCheckReturnValue.md.html b/docs/checks/RxJava2MethodMissingCheckReturnValue.md.html index eab05eb..780f9b3 100644 --- a/docs/checks/RxJava2MethodMissingCheckReturnValue.md.html +++ b/docs/checks/RxJava2MethodMissingCheckReturnValue.md.html @@ -1,13 +1,13 @@ -(#) Method is missing the @CheckReturnValue annotation. +(#) Method is missing the @CheckReturnValue annotation -!!! WARNING: Method is missing the @CheckReturnValue annotation. +!!! WARNING: Method is missing the @CheckReturnValue annotation This is a warning. Id : `RxJava2MethodMissingCheckReturnValue` Summary -: Method is missing the @CheckReturnValue annotation. +: Method is missing the @CheckReturnValue annotation Severity : Warning Category @@ -29,6 +29,10 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2MethodMissingCheckReturnValueDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2MethodMissingCheckReturnValueDetectorTest.kt) Methods returning RxJava Reactive Types should be annotated with the @CheckReturnValue annotation. Static analyze tools such as Lint or @@ -36,6 +40,132 @@ This is usually an indication of a bug. If this is done on purpose (e.g. fire & forget) it should be stated explicitly. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:15:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + private Observable<Object> observable() { + ---------- +src/foo/Example.java:19:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + protected Flowable<Object> flowable() { + -------- +src/foo/Example.java:23:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + protected Single<Object> single() { + ------ +src/foo/Example.java:27:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + protected Maybe<Object> single() { + ------ +src/foo/Example.java:31:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + public Completable completable() { + ----------- +src/foo/Example.java:35:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + public Disposable disposable() { + ---------- +src/foo/Example.java:39:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + public CompositeDisposable compositeDisposable() { + ------------------- +src/foo/Example.java:43:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + public TestObserver testObserver() { + ------------ +src/foo/Example.java:47:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + public TestSubscriber testSubscriber() { + -------------- +src/foo/Example.java:51:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + public Scheduler scheduler() { + --------- +src/foo/Example.java:55:Warning: Method should have @CheckReturnValue +annotation [RxJava2MethodMissingCheckReturnValue] + private Observable<List<Object>> observableList() { + -------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import io.reactivex.Observable; +import io.reactivex.Flowable; +import io.reactivex.Single; +import io.reactivex.Maybe; +import io.reactivex.Completable; +import io.reactivex.disposables.Disposable; +import io.reactivex.disposables.CompositeDisposable; +import io.reactivex.observers.TestObserver; +import io.reactivex.subscribers.TestSubscriber; +import io.reactivex.Scheduler; + +class Example { + private Observable observable() { + return null; + } + + protected Flowable flowable() { + return null; + } + + protected Single single() { + return null; + } + + protected Maybe single() { + return null; + } + + public Completable completable() { + return null; + } + + public Disposable disposable() { + return null; + } + + public CompositeDisposable compositeDisposable() { + return null; + } + + public TestObserver testObserver() { + return null; + } + + public TestSubscriber testSubscriber() { + return null; + } + + public Scheduler scheduler() { + return null; + } + + private Observable> observableList() { + return null; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2MethodMissingCheckReturnValueDetectorTest.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, `RxJava2MethodMissingCheckReturnValueDetector.methodMissingCheckReturnValue`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RxJava2MissingCompositeDisposableClear.md.html b/docs/checks/RxJava2MissingCompositeDisposableClear.md.html index 92377d0..e6977e5 100644 --- a/docs/checks/RxJava2MissingCompositeDisposableClear.md.html +++ b/docs/checks/RxJava2MissingCompositeDisposableClear.md.html @@ -1,13 +1,13 @@ -(#) Marks CompositeDisposables that are not being cleared. +(#) Marks CompositeDisposables that are not being cleared -!!! ERROR: Marks CompositeDisposables that are not being cleared. +!!! ERROR: Marks CompositeDisposables that are not being cleared This is an error. Id : `RxJava2MissingCompositeDisposableClear` Summary -: Marks CompositeDisposables that are not being cleared. +: Marks CompositeDisposables that are not being cleared Severity : Error Category @@ -29,12 +29,48 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2MissingCompositeDisposableClearDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2MissingCompositeDisposableClearDetectorTest.kt) A class is using CompositeDisposable and not calling clear(). This can leave operations running and even cause memory leaks. It's best to always call clear() once you're done. e.g. in onDestroy() for Activitys. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:6:Error: clear() is not called +[RxJava2MissingCompositeDisposableClear] + CompositeDisposable cd; + ----------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import io.reactivex.disposables.CompositeDisposable; + +class Example { + CompositeDisposable cd; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2MissingCompositeDisposableClearDetectorTest.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, `RxJava2MissingCompositeDisposableClearDetector.compositeDisposableMissingClear`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RxJava2SchedulersFactoryCall.md.html b/docs/checks/RxJava2SchedulersFactoryCall.md.html index 0ea85f7..66a0926 100644 --- a/docs/checks/RxJava2SchedulersFactoryCall.md.html +++ b/docs/checks/RxJava2SchedulersFactoryCall.md.html @@ -1,13 +1,13 @@ -(#) Instead of calling the Schedulers factory methods directly inject the Schedulers. +(#) Instead of calling the Schedulers factory methods directly inject the Schedulers -!!! WARNING: Instead of calling the Schedulers factory methods directly inject the Schedulers. +!!! WARNING: Instead of calling the Schedulers factory methods directly inject the Schedulers This is a warning. Id : `RxJava2SchedulersFactoryCall` Summary -: Instead of calling the Schedulers factory methods directly inject the Schedulers. +: Instead of calling the Schedulers factory methods directly inject the Schedulers Severity : Warning Category @@ -29,12 +29,52 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2SchedulersFactoryCallDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2SchedulersFactoryCallDetectorTest.kt) Injecting the Schedulers instead of accessing them via the factory methods has the benefit that unit testing is way easier. Instead of overriding them via the Plugin mechanism we can just pass a custom Scheduler. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:9:Warning: Inject this Scheduler instead of calling +it directly [RxJava2SchedulersFactoryCall] + return Schedulers.io(); + -- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import io.reactivex.annotations.CheckReturnValue; +import io.reactivex.Scheduler; +import io.reactivex.schedulers.Schedulers; + +class Example { + @CheckReturnValue Scheduler provideSchedulerIo() { + return Schedulers.io(); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2SchedulersFactoryCallDetectorTest.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, `RxJava2SchedulersFactoryCallDetector.ioCallInsideCheckReturnValueMethod`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/RxJava2SubscribeMissingOnError.md.html b/docs/checks/RxJava2SubscribeMissingOnError.md.html index a5938d0..a516dc9 100644 --- a/docs/checks/RxJava2SubscribeMissingOnError.md.html +++ b/docs/checks/RxJava2SubscribeMissingOnError.md.html @@ -1,13 +1,13 @@ -(#) Flags a version of the subscribe() method without an error Consumer. +(#) Flags a version of the subscribe() method without an error Consumer -!!! ERROR: Flags a version of the subscribe() method without an error Consumer. +!!! ERROR: Flags a version of the subscribe() method without an error Consumer This is an error. Id : `RxJava2SubscribeMissingOnError` Summary -: Flags a version of the subscribe() method without an error Consumer. +: Flags a version of the subscribe() method without an error Consumer Severity : Error Category @@ -29,11 +29,50 @@ : 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-rxjava2-lint/src/main/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2SubscribeMissingOnErrorDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2SubscribeMissingOnErrorDetectorTest.kt) When calling the subscribe() method an error Consumer should always be used. Otherwise errors might be thrown and may crash the application or get forwarded to the Plugin Error handler. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:8:Error: Using a version of subscribe() without an +error Consumer [RxJava2SubscribeMissingOnError] + o.subscribe(); + --------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; + +import io.reactivex.Observable; + +class Example { + public void foo() { + Observable o = null; + o.subscribe(); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-rxjava2-lint/src/test/kotlin/com/vanniktech/lintrules/rxjava2/RxJava2SubscribeMissingOnErrorDetectorTest.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, `RxJava2SubscribeMissingOnErrorDetector.callingObservableSubscribe`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/SQLiteString.md.html b/docs/checks/SQLiteString.md.html index 51ef003..0366954 100644 --- a/docs/checks/SQLiteString.md.html +++ b/docs/checks/SQLiteString.md.html @@ -59,21 +59,48 @@ you mean to use TEXT? (STRING is a numeric type and its value can be adjusted; for example, strings that look like integers can drop leading zeroes. See issue explanation for details.) [SQLiteString] - db.execSQL("CREATE TABLE " + name + "(" + Tables.AppKeys.SCHEMA + ");"); // ERROR ----------------------------------------------------------------------- - - src/test/pkg/SQLiteTest.java:30:Warning: Using column type STRING; did you mean to use TEXT? (STRING is a numeric type and its value can be adjusted; for example, strings that look like integers can drop leading zeroes. See issue explanation for details.) [SQLiteString] - db.execSQL(TracksColumns.CREATE_TABLE); // ERROR -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/test/pkg/TracksColumns.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package test.pkg; + +import android.provider.BaseColumns; + +public interface TracksColumns extends BaseColumns { + + String TABLE_NAME = "tracks"; + + String NAME = "name"; + String CATEGORY = "category"; + String STARTTIME = "starttime"; + String MAXGRADE = "maxgrade"; + String MAPID = "mapid"; + String TABLEID = "tableid"; + String ICON = "icon"; + + String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + NAME + " STRING, " + + CATEGORY + " STRING, " + + STARTTIME + " INTEGER, " + + MAXGRADE + " FLOAT, " + + MAPID + " STRING, " + + TABLEID + " STRING, " + + ICON + " STRING" + + ");"; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/SQLiteTest.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/SSLCertificateSocketFactoryCreateSocket.md.html b/docs/checks/SSLCertificateSocketFactoryCreateSocket.md.html index b594820..c1ef236 100644 --- a/docs/checks/SSLCertificateSocketFactoryCreateSocket.md.html +++ b/docs/checks/SSLCertificateSocketFactoryCreateSocket.md.html @@ -49,57 +49,41 @@ can cause insecure network traffic due to trusting arbitrary hostnames in TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryCreateSocket] - sf.createSocket(inet, 80); ------------------------- - - src/test/pkg/SSLCertificateSocketFactoryTest.java:22:Warning: Use of SSLCertificateSocketFactory.createSocket() with an InetAddress parameter can cause insecure network traffic due to trusting arbitrary hostnames in TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryCreateSocket] - sf.createSocket(inet4, 80); -------------------------- - - src/test/pkg/SSLCertificateSocketFactoryTest.java:23:Warning: Use of SSLCertificateSocketFactory.createSocket() with an InetAddress parameter can cause insecure network traffic due to trusting arbitrary hostnames in TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryCreateSocket] - sf.createSocket(inet6, 80); -------------------------- - - src/test/pkg/SSLCertificateSocketFactoryTest.java:24:Warning: Use of SSLCertificateSocketFactory.createSocket() with an InetAddress parameter can cause insecure network traffic due to trusting arbitrary hostnames in TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryCreateSocket] - sf.createSocket(inet, 80, inet, 2000); ------------------------------------- - - src/test/pkg/SSLCertificateSocketFactoryTest.java:25:Warning: Use of SSLCertificateSocketFactory.createSocket() with an InetAddress parameter can cause insecure network traffic due to trusting arbitrary hostnames in TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryCreateSocket] - sf.createSocket(inet4, 80, inet, 2000); -------------------------------------- - - src/test/pkg/SSLCertificateSocketFactoryTest.java:26:Warning: Use of SSLCertificateSocketFactory.createSocket() with an InetAddress parameter can cause insecure network traffic due to trusting arbitrary hostnames in TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryCreateSocket] - sf.createSocket(inet6, 80, inet, 2000); -------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SSLCertificateSocketFactoryGetInsecure.md.html b/docs/checks/SSLCertificateSocketFactoryGetInsecure.md.html index 3f86cd7..942ed01 100644 --- a/docs/checks/SSLCertificateSocketFactoryGetInsecure.md.html +++ b/docs/checks/SSLCertificateSocketFactoryGetInsecure.md.html @@ -46,7 +46,6 @@ SSLCertificateSocketFactory.getInsecure() can cause insecure network traffic due to trusting arbitrary TLS/SSL certificates presented by peers [SSLCertificateSocketFactoryGetInsecure] - SSLCertificateSocketFactory.getInsecure(-1,null)); ------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ScheduleExactAlarm.md.html b/docs/checks/ScheduleExactAlarm.md.html index 80379da..a8a1a17 100644 --- a/docs/checks/ScheduleExactAlarm.md.html +++ b/docs/checks/ScheduleExactAlarm.md.html @@ -46,12 +46,19 @@ src/test/pkg/AlarmTest.kt:7:Error: When scheduling exact alarms, apps should explicitly call AlarmManager#canScheduleExactAlarms or handle `SecurityException`s [ScheduleExactAlarm] - alarmManager.setExact(AlarmManager.ELAPSED_REALTIME, 5000, null) ---------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> + <uses-sdk android:targetSdkVersion="33" /> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/test/pkg/AlarmTest.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -83,6 +90,21 @@ You can suppress false positives using one of the following mechanisms: +* Adding the suppression attribute `tools:ignore="ScheduleExactAlarm"` + 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <uses-permission tools:ignore="ScheduleExactAlarm" .../> + ... + </manifest> + ``` + * Using a suppression annotation like this on the enclosing element: @@ -111,21 +133,6 @@ problematicStatement() ``` -* Adding the suppression attribute `tools:ignore="ScheduleExactAlarm"` - 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 - <?xml version="1.0" encoding="UTF-8"?> - <manifest xmlns:tools="http://schemas.android.com/tools"> - ... - <uses-permission tools:ignore="ScheduleExactAlarm" .../> - ... - </manifest> - ``` - * 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: diff --git a/docs/checks/ScopedStorage.md.html b/docs/checks/ScopedStorage.md.html index df6f151..cfb9033 100644 --- a/docs/checks/ScopedStorage.md.html +++ b/docs/checks/ScopedStorage.md.html @@ -65,7 +65,6 @@ AndroidManifest.xml:4:Warning: WRITE_EXTERNAL_STORAGE no longer provides write access when targeting Android 10, unless you use requestLegacyExternalStorage [ScopedStorage] - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><!-- ERROR --> ----------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ScrollViewCount.md.html b/docs/checks/ScrollViewCount.md.html index 4b5a15e..571c0e0 100644 --- a/docs/checks/ScrollViewCount.md.html +++ b/docs/checks/ScrollViewCount.md.html @@ -38,7 +38,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/has_children.xml:1:Warning: A scroll view can have only one child [ScrollViewCount] - <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ScrollViewSize.md.html b/docs/checks/ScrollViewSize.md.html index 1ff0919..1b8cc9a 100644 --- a/docs/checks/ScrollViewSize.md.html +++ b/docs/checks/ScrollViewSize.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/wrong_dimension.xml:8:Warning: This LinearLayout should use android:layout_width="wrap_content" [ScrollViewSize] - android:layout_width="match_parent" ----------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SdCardPath.md.html b/docs/checks/SdCardPath.md.html index 3d5a8ca..7e8e414 100644 --- a/docs/checks/SdCardPath.md.html +++ b/docs/checks/SdCardPath.md.html @@ -45,101 +45,64 @@ src/test/pkg/SdCardTest.java:13:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - private static final String SDCARD_TEST_HTML = "/sdcard/test.html"; ------------------- - - src/test/pkg/SdCardTest.java:14:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - public static final String SDCARD_ROOT = "/sdcard"; --------- - - src/test/pkg/SdCardTest.java:15:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - public static final String PACKAGES_PATH = "/sdcard/o/packages/"; --------------------- - - src/test/pkg/SdCardTest.java:16:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - File deviceDir = new File("/sdcard/vr"); ------------ - - src/test/pkg/SdCardTest.java:20:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - android.os.Debug.startMethodTracing("/sdcard/launcher"); ------------------ - - src/test/pkg/SdCardTest.java:22:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - if (new File("/sdcard").exists()) { --------- - - src/test/pkg/SdCardTest.java:24:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - String FilePath = "/sdcard/" + new File("test"); ---------- - - src/test/pkg/SdCardTest.java:29:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - intent.setDataAndType(Uri.parse("file://sdcard/foo.json"), "application/bar-json"); ------------------------ - - src/test/pkg/SdCardTest.java:30:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - intent.putExtra("path-filter", "/sdcard(/.+)*"); --------------- - - src/test/pkg/SdCardTest.java:31:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - intent.putExtra("start-dir", "/sdcard"); --------- - - src/test/pkg/SdCardTest.java:32:Warning: Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead [SdCardPath] - String mypath = "/data/data/foo"; ---------------- - - src/test/pkg/SdCardTest.java:33:Warning: Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead [SdCardPath] - String base = "/data/data/foo.bar/test-profiling"; ----------------------------------- - - src/test/pkg/SdCardTest.java:34:Warning: Do not hardcode "/sdcard/"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath] - String s = "file://sdcard/foo"; ------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SecretInSource.md.html b/docs/checks/SecretInSource.md.html index 8cfb136..c65aed2 100644 --- a/docs/checks/SecretInSource.md.html +++ b/docs/checks/SecretInSource.md.html @@ -42,15 +42,11 @@ src/com/pkg/keydemo/test.kt:8:Warning: This argument looks like an API key that has come from source code; API keys should not be included in source code [SecretInSource] - val model1 = GenerativeModel("name", KEY) --- - - src/com/pkg/keydemo/test.kt:9:Warning: This argument looks like an API key that has come from source code; API keys should not be included in source code [SecretInSource] - val model2 = GenerativeModel("name", "AIzadGhpcyBpcyBhbm90aGVy_IHQ-akd==") ------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SecureRandom.md.html b/docs/checks/SecureRandom.md.html index 1409a3e..3d7c768 100644 --- a/docs/checks/SecureRandom.md.html +++ b/docs/checks/SecureRandom.md.html @@ -44,87 +44,56 @@ src/test/pkg/SecureRandomTest.java:12:Warning: It is dangerous to seed SecureRandom with the current time because that value is more predictable to an attacker than the default seed [SecureRandom] - random1.setSeed(System.currentTimeMillis()); // Wrong ------------------------------------------- - - src/test/pkg/SecureRandomTest.java:13:Warning: It is dangerous to seed SecureRandom with the current time because that value is more predictable to an attacker than the default seed [SecureRandom] - random1.setSeed(System.nanoTime()); // Wrong ---------------------------------- - - src/test/pkg/SecureRandomTest.java:15:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random1.setSeed(0); // Wrong ------------------ - - src/test/pkg/SecureRandomTest.java:16:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random1.setSeed(1); // Wrong ------------------ - - src/test/pkg/SecureRandomTest.java:17:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random1.setSeed((int)1023); // Wrong -------------------------- - - src/test/pkg/SecureRandomTest.java:18:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random1.setSeed(1023L); // Wrong ---------------------- - - src/test/pkg/SecureRandomTest.java:19:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random1.setSeed(FIXED_SEED); // Wrong --------------------------- - - src/test/pkg/SecureRandomTest.java:29:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random3.setSeed(0); // Wrong: owner is java/util/Random, but applied to SecureRandom object ------------------ - - src/test/pkg/SecureRandomTest.java:41:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random2.setSeed(seed); // Wrong --------------------- - - src/test/pkg/SecureRandomTest.java:47:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random2.setSeed(seedBytes); // Wrong -------------------------- - - src/test/pkg/SecureRandomTest.java:55:Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom] - random2.setSeed(fixedSeed); // Wrong -------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SelectableText.md.html b/docs/checks/SelectableText.md.html index a990ac7..6a97454 100644 --- a/docs/checks/SelectableText.md.html +++ b/docs/checks/SelectableText.md.html @@ -48,7 +48,6 @@ res/layout/edit_textview.xml:83:Warning: Consider making the text value selectable by specifying android:textIsSelectable="true" [SelectableText] - <TextView -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SelectedPhotoAccess.md.html b/docs/checks/SelectedPhotoAccess.md.html index 0f655e4..9d1b686 100644 --- a/docs/checks/SelectedPhotoAccess.md.html +++ b/docs/checks/SelectedPhotoAccess.md.html @@ -45,14 +45,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:11:Warning: Your app is currently not handling Selected Photos Access introduced in Android 14+ [SelectedPhotoAccess] - <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" android:minSdkVersion="33" /> ------------------------------------ - - AndroidManifest.xml:13:Warning: Your app is currently not handling Selected Photos Access introduced in Android 14+ [SelectedPhotoAccess] - <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" android:minSdkVersion="33"/> ----------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SensitiveExternalPath.md.html b/docs/checks/SensitiveExternalPath.md.html new file mode 100644 index 0000000..d0a1e56 --- /dev/null +++ b/docs/checks/SensitiveExternalPath.md.html @@ -0,0 +1,136 @@ + +(#) Application may expose sensitive info like PII by storing it in external storage + +!!! WARNING: Application may expose sensitive info like PII by storing it in external storage + This is a warning. + +Id +: `SensitiveExternalPath` +Summary +: Application may expose sensitive info like PII by storing it in external storage +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Resource files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/SensitiveExternalPath +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/MisconfiguredFileProviderDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MisconfiguredFileProviderDetectorTest.kt) +Copyright Year +: 2023 + +Sensitive information like PII should not be stored outside of the +application container or system credential storage facilities. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/xml/file_paths.xml:5:Warning: Sensitive info like PII should not be +stored or shared via [SensitiveExternalPath] + <external-path name="external_path" path="sdcard/"/> + ---------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/xml/file_paths.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> + <paths xmlns:android="http://schemas.android.com/apk/res/android"> + <files-path name="my_images" path="images/"/> + <files-path name="my_docs" path="docs/"/> + <external-path name="external_path" path="sdcard/"/> + </paths> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/MisconfiguredFileProviderDetectorTest.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, `MisconfiguredFileProviderDetector.testWhenExternalPathUsedInConfig_showsWarningAndQuickFix`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="SensitiveExternalPath"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <lint> + <issue id="SensitiveExternalPath" 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 'SensitiveExternalPath' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore SensitiveExternalPath ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/SerializableUsage.md.html b/docs/checks/SerializableUsage.md.html index 5027441..6f03b34 100644 --- a/docs/checks/SerializableUsage.md.html +++ b/docs/checks/SerializableUsage.md.html @@ -1,13 +1,13 @@ -(#) Don't use Serializable. +(#) Don't use Serializable -!!! ERROR: Don't use Serializable. +!!! ERROR: Don't use Serializable This is an error. Id : `SerializableUsage` Summary -: Don't use Serializable. +: Don't use Serializable Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/SerializableDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/SerializableDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/SerializableDetectorTest.kt) Copyright Year @@ -51,7 +51,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/slack/ImplementsExplicitly.kt:6:Error: Don't use Serializable. [SerializableUsage] - class ImplementsExplicitly : RuntimeException, Serializable -------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ServiceCast.md.html b/docs/checks/ServiceCast.md.html index fcf0bbb..bd2a1a4 100644 --- a/docs/checks/ServiceCast.md.html +++ b/docs/checks/ServiceCast.md.html @@ -40,23 +40,16 @@ src/test/pkg/SystemServiceTest.java:13:Error: Suspicious cast to DisplayManager for a DEVICE_POLICY_SERVICE: expected DevicePolicyManager [ServiceCast] - DisplayManager displayServiceWrong = (DisplayManager) getSystemService( ^ - - src/test/pkg/SystemServiceTest.java:16:Error: Suspicious cast to WallpaperService for a WALLPAPER_SERVICE: expected WallpaperManager [ServiceCast] - WallpaperService wallPaperWrong = (WallpaperService) getSystemService(WALLPAPER_SERVICE); ------------------------------------------------------ - - src/test/pkg/SystemServiceTest.java:22:Error: Suspicious cast to DisplayManager for a DEVICE_POLICY_SERVICE: expected DevicePolicyManager [ServiceCast] - DisplayManager displayServiceWrong = (DisplayManager) context ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SetAndClearCommunicationDevice.md.html b/docs/checks/SetAndClearCommunicationDevice.md.html index 8ce296b..c14f32c 100644 --- a/docs/checks/SetAndClearCommunicationDevice.md.html +++ b/docs/checks/SetAndClearCommunicationDevice.md.html @@ -42,12 +42,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/Test.kt:9:Warning: Must call clearCommunicationDevice() after setCommunicationDevice() [SetAndClearCommunicationDevice] - manager.setCommunicationDevice(AudioDeviceInfo()) ------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here are the relevant source files: +Here is the source file referenced above: `src/test/pkg/Test.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -64,22 +63,6 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`src/AudioManager.java`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -package android.media; - -public class AudioManager { - public boolean setCommunicationDevice(@NonNull AudioDeviceInfo device) {} - public void clearCommunicationDevice() {} -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -`src/AudioDeviceInfo.java`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -package android.media; -public class AudioDeviceInfo {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 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/CommunicationDeviceDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/SetJavaScriptEnabled.md.html b/docs/checks/SetJavaScriptEnabled.md.html index 13ac6e1..af773e3 100644 --- a/docs/checks/SetJavaScriptEnabled.md.html +++ b/docs/checks/SetJavaScriptEnabled.md.html @@ -43,7 +43,6 @@ src/test/pkg/SetJavaScriptEnabled.java:14:Warning: Using setJavaScriptEnabled can introduce XSS vulnerabilities into your application, review carefully [SetJavaScriptEnabled] - webView.getSettings().setJavaScriptEnabled(true); // bad ------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SetTextI18n.md.html b/docs/checks/SetTextI18n.md.html index c9544d2..feb244f 100644 --- a/docs/checks/SetTextI18n.md.html +++ b/docs/checks/SetTextI18n.md.html @@ -49,29 +49,19 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/CustomScreen.java:13:Warning: String literal in setText can not be translated. Use Android resources instead. [SetTextI18n] - view.setText("Hardcoded"); ----------- - - src/test/pkg/CustomScreen.java:17:Warning: Number formatting does not take into account locale settings. Consider using String.format instead. [SetTextI18n] - view.setText(Integer.toString(50) + "%"); -------------------- - - src/test/pkg/CustomScreen.java:18:Warning: String literal in setText can not be translated. Use Android resources instead. [SetTextI18n] - view.setText(Double.toString(12.5) + " miles"); -------- - - src/test/pkg/CustomScreen.java:21:Warning: String literal in setText can not be translated. Use Android resources instead. [SetTextI18n] - btn.setText("User " + getUserName()); ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SetWorldReadable.md.html b/docs/checks/SetWorldReadable.md.html index 7789091..f1811bf 100644 --- a/docs/checks/SetWorldReadable.md.html +++ b/docs/checks/SetWorldReadable.md.html @@ -43,7 +43,6 @@ src/test/pkg/WorldWriteableFile.java:41:Warning: Setting file permissions to world-readable can be risky, review carefully [SetWorldReadable] - mFile.setReadable(true, false); ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SetWorldWritable.md.html b/docs/checks/SetWorldWritable.md.html index b333375..c18bba6 100644 --- a/docs/checks/SetWorldWritable.md.html +++ b/docs/checks/SetWorldWritable.md.html @@ -43,7 +43,6 @@ src/test/pkg/WorldWriteableFile.java:48:Warning: Setting file permissions to world-writable can be risky, review carefully [SetWorldWritable] - mFile.setWritable(true, false); ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ShiftFlags.md.html b/docs/checks/ShiftFlags.md.html index 080cdbf..e7d49e7 100644 --- a/docs/checks/ShiftFlags.md.html +++ b/docs/checks/ShiftFlags.md.html @@ -42,28 +42,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/IntDefTest.java:13:Warning: Consider declaring this constant using 1 << 44 instead [ShiftFlags] - public static final long FLAG5 = 0x100000000000L; --------------- - - src/test/pkg/IntDefTest.java:14:Warning: Consider declaring this constant using 1 << 49 instead [ShiftFlags] - public static final long FLAG6 = 0x0002000000000000L; ------------------- - - src/test/pkg/IntDefTest.java:15:Warning: Consider declaring this constant using 1 << 3 instead [ShiftFlags] - public static final long FLAG7 = 8L; -- - - src/test/pkg/IntDefTest.java:20:Warning: Consider declaring this constant using 1 << 4 instead [ShiftFlags] - public static final int FLAG12 = 0x10; ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ShortAlarm.md.html b/docs/checks/ShortAlarm.md.html index c34a674..fb71f52 100644 --- a/docs/checks/ShortAlarm.md.html +++ b/docs/checks/ShortAlarm.md.html @@ -43,21 +43,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/AlarmTest.java:9:Warning: Value will be forced up to 60000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] - alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR -- - - src/test/pkg/AlarmTest.java:11:Warning: Value will be forced up to 60000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] - OtherClass.MY_INTERVAL, null); // ERROR ---------------------- - - src/test/pkg/AlarmTest.java:16:Warning: Value will be forced up to 60000 as of Android 5.1; don't rely on this to be exact [ShortAlarm] - alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, interval2, null); // ERROR --------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/ShouldUseStaticImport.md.html b/docs/checks/ShouldUseStaticImport.md.html index 0e3afe2..5938343 100644 --- a/docs/checks/ShouldUseStaticImport.md.html +++ b/docs/checks/ShouldUseStaticImport.md.html @@ -1,13 +1,13 @@ -(#) Flags declarations that should be statically imported. +(#) Flags declarations that should be statically imported -!!! WARNING: Flags declarations that should be statically imported. +!!! WARNING: Flags declarations that should be statically imported This is a warning. Id : `ShouldUseStaticImport` Summary -: Flags declarations that should be statically imported. +: Flags declarations that should be statically imported Severity : Warning Category @@ -29,10 +29,46 @@ : 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/kotlin/com/vanniktech/lintrules/android/ShouldUseStaticImportDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ShouldUseStaticImportDetectorTest.kt) Certain declarations like TimeUnit.SECONDS should be statically imported to increase the readability. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/foo/Example.java:5:Warning: Should statically import SECONDS +[ShouldUseStaticImport] + TimeUnit.SECONDS.toDays(1); + ------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/foo/Example.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package foo; +import java.util.concurrent.TimeUnit; +class Example { + public void foo() { + TimeUnit.SECONDS.toDays(1); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/ShouldUseStaticImportDetectorTest.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, `ShouldUseStaticImportDetector.timeUnitSeconds`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/ShowToast.md.html b/docs/checks/ShowToast.md.html index 3659f0d..7f7ce4f 100644 --- a/docs/checks/ShowToast.md.html +++ b/docs/checks/ShowToast.md.html @@ -42,28 +42,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/ToastTest.java:32:Warning: Toast created but not shown: did you forget to call show()? [ShowToast] - Toast.makeText(context, "foo", Toast.LENGTH_LONG); -------------- - - src/test/pkg/ToastTest.java:33:Warning: Toast created but not shown: did you forget to call show()? [ShowToast] - Toast toast = Toast.makeText(context, R.string.app_name, 5000); -------------- - - src/test/pkg/ToastTest.java:39:Warning: Toast created but not shown: did you forget to call show()? [ShowToast] - Toast.makeText(context, "foo", Toast.LENGTH_LONG); -------------- - - src/test/pkg/ToastTest.java:54:Warning: Toast created but not shown: did you forget to call show()? [ShowToast] - Toast toast2 = Toast.makeText(context, "foo", Toast.LENGTH_LONG); // not shown -------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SignatureOrSystemPermissions.md.html b/docs/checks/SignatureOrSystemPermissions.md.html index 21b309f..f60f114 100644 --- a/docs/checks/SignatureOrSystemPermissions.md.html +++ b/docs/checks/SignatureOrSystemPermissions.md.html @@ -44,7 +44,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:13:Warning: protectionLevel should probably not be set to signatureOrSystem [SignatureOrSystemPermissions] - android:protectionLevel="signatureOrSystem"/> ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SimilarGradleDependency.md.html b/docs/checks/SimilarGradleDependency.md.html index f312d89..6ac8380 100644 --- a/docs/checks/SimilarGradleDependency.md.html +++ b/docs/checks/SimilarGradleDependency.md.html @@ -35,6 +35,45 @@ such approach. However, you may simply not be aware that this situation happens, and that is what this lint check helps find. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +../gradle/libs.versions.toml:6:Information: There are multiple +dependencies joda-time:joda-time but with different version +[SimilarGradleDependency] +joda_library = { module = "joda-time:joda-time", version.ref = "jodaVersion"} + ------------------------------------------------------------- +../gradle/libs.versions.toml:7:Information: There are multiple +dependencies joda-time:joda-time but with different version +[SimilarGradleDependency] +joda_library2 = { module = "joda-time:joda-time", version = "2.0"} + ------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`../gradle/libs.versions.toml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~toml linenumbers +[versions] +jodaVersion = "2.1" +dagger="1.2.0" + +[libraries] +joda_library = { module = "joda-time:joda-time", version.ref = "jodaVersion"} +joda_library2 = { module = "joda-time:joda-time", version = "2.0"} +dagger-lib = { group = "com.squareup.dagger", name ="dagger", version.ref = "dagger" } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +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/GradleDetectorTest.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, `GradleDetector.testVersionCatalogWithSimilarLibraryDependencies`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=192708. + (##) Suppressing You can suppress false positives using one of the following mechanisms: diff --git a/docs/checks/SimpleDateFormat.md.html b/docs/checks/SimpleDateFormat.md.html index d8b4446..5833ec8 100644 --- a/docs/checks/SimpleDateFormat.md.html +++ b/docs/checks/SimpleDateFormat.md.html @@ -52,25 +52,18 @@ getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat] - new SimpleDateFormat(); // WRONG ---------------------- - - src/test/pkg/LocaleTest.java:33:Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat] - new SimpleDateFormat("yyyy-MM-dd"); // WRONG ---------------------------------- - - src/test/pkg/LocaleTest.java:34:Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat] - new SimpleDateFormat("yyyy-MM-dd", DateFormatSymbols.getInstance()); // WRONG ------------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Slices.md.html b/docs/checks/Slices.md.html index eea0bbb..b6acbb3 100644 --- a/docs/checks/Slices.md.html +++ b/docs/checks/Slices.md.html @@ -38,14 +38,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/SliceTest.java:33:Warning: A slice should have at least one row added to it [Slices] - Slice slice = new ListBuilder(context, uri, ttl).build(); ---------------------------------- - - src/test/pkg/SliceTest.java:39:Warning: A slice should have at least one row added to it [Slices] - ListBuilder lb2 = new ListBuilder(context, uri, ttl); // missing on this one ---------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SmallSp.md.html b/docs/checks/SmallSp.md.html index eb75590..22b6c65 100644 --- a/docs/checks/SmallSp.md.html +++ b/docs/checks/SmallSp.md.html @@ -37,14 +37,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/textsize.xml:33:Warning: Avoid using sizes smaller than 11sp: 10sp [SmallSp] - android:textSize="10sp" /> ----------------------- - - res/layout/textsize.xml:37:Warning: Avoid using sizes smaller than 11sp: 6.5sp [SmallSp] - android:layout_height="6.5sp" /> ----------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SoonBlockedPrivateApi.md.html b/docs/checks/SoonBlockedPrivateApi.md.html index c5dbd73..d5d24bd 100644 --- a/docs/checks/SoonBlockedPrivateApi.md.html +++ b/docs/checks/SoonBlockedPrivateApi.md.html @@ -43,7 +43,6 @@ src/test/pkg/TestReflection.java:16:Error: Reflective access to OTASP_NEEDED will throw an exception when targeting API 28 and above [SoonBlockedPrivateApi] - Field maybeField = TelephonyManager.class.getDeclaredField("OTASP_NEEDED"); // ERROR 2 ------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SourceLockedOrientationActivity.md.html b/docs/checks/SourceLockedOrientationActivity.md.html index 4eb5984..b1c37d2 100644 --- a/docs/checks/SourceLockedOrientationActivity.md.html +++ b/docs/checks/SourceLockedOrientationActivity.md.html @@ -51,7 +51,6 @@ orientation of your activities, so that you can support a good user experience for any device or orientation [SourceLockedOrientationActivity] - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ----------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SpUsage.md.html b/docs/checks/SpUsage.md.html index bff859f..c5d208a 100644 --- a/docs/checks/SpUsage.md.html +++ b/docs/checks/SpUsage.md.html @@ -52,14 +52,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/textsize.xml:11:Warning: Should use "sp" instead of "dp" for text sizes [SpUsage] - android:textSize="14dp" /> ----------------------- - - res/layout/textsize.xml:16:Warning: Should use "sp" instead of "dp" for text sizes [SpUsage] - android:textSize="14dip" /> ------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SpanMarkPointMissingMask.md.html b/docs/checks/SpanMarkPointMissingMask.md.html index f54cc14..d44e69c 100644 --- a/docs/checks/SpanMarkPointMissingMask.md.html +++ b/docs/checks/SpanMarkPointMissingMask.md.html @@ -1,13 +1,13 @@ -(#) Check that Span flags use the bitwise mask SPAN_POINT_MARK_MASK when being compared to. +(#) Check that Span flags use the bitwise mask SPAN_POINT_MARK_MASK when being compared to -!!! ERROR: Check that Span flags use the bitwise mask SPAN_POINT_MARK_MASK when being compared to. +!!! ERROR: Check that Span flags use the bitwise mask SPAN_POINT_MARK_MASK when being compared to This is an error. Id : `SpanMarkPointMissingMask` Summary -: Check that Span flags use the bitwise mask SPAN_POINT_MARK_MASK when being compared to. +: Check that Span flags use the bitwise mask SPAN_POINT_MARK_MASK when being compared to Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/text/SpanMarkPointMissingMaskDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/text/SpanMarkPointMissingMaskDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/text/SpanMarkPointMissingMaskDetectorTest.kt) Copyright Year @@ -54,7 +54,6 @@ src/slack/text/MyClass.kt:7:Error: Do not check against directly. Instead mask flag with Spanned.SPAN_POINT_MARK_MASK to only check MARK_POINT flags. [SpanMarkPointMissingMask] - return spanned.getSpanFlags(Object()) == || Spanned.x() ------------------------------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SpecifyForegroundServiceType.md.html b/docs/checks/SpecifyForegroundServiceType.md.html index 25c52df..0ee78a7 100644 --- a/docs/checks/SpecifyForegroundServiceType.md.html +++ b/docs/checks/SpecifyForegroundServiceType.md.html @@ -44,6 +44,42 @@ entry for `SystemForegroundService` to include the foreground service type in the `AndroidManifest.xml` file. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/App.kt:9:Error: Missing dataSync foregroundServiceType in +the AndroidManifest.xml [SpecifyForegroundServiceType] + val info = ForegroundInfo(0, notification, 1) + ---------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`com/example/App.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import android.app.Notification +import androidx.work.ForegroundInfo + +class App { + fun onCreate() { + val notification = Notification() + val info = ForegroundInfo(0, notification, 1) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/work-lint/src/test/java/androidx/work/lint/SpecifyForegroundServiceTypeIssueDetectorTest.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, `SpecifyForegroundServiceTypeIssueDetector.failWhenServiceTypeIsNotSpecified`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=409906. + (##) Including !!! diff --git a/docs/checks/SpecifyJobSchedulerIdRange.md.html b/docs/checks/SpecifyJobSchedulerIdRange.md.html index b03c163..c0f0086 100644 --- a/docs/checks/SpecifyJobSchedulerIdRange.md.html +++ b/docs/checks/SpecifyJobSchedulerIdRange.md.html @@ -45,6 +45,36 @@ `androidx.work.Configuration.Builder.setJobSchedulerJobIdRange(int, int)`. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +com/example/TestJobService.kt:5:Warning: Specify a valid range of job +id's for WorkManager to use. [SpecifyJobSchedulerIdRange] +class TestJobService: JobService() + -------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`com/example/TestJobService.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package com.example + +import android.app.job.JobService + +class TestJobService: JobService() +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/work/work-lint/src/test/java/androidx/work/lint/SpecifyJobSchedulerIdRangeIssueDetectorTest.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, `SpecifyJobSchedulerIdRangeIssueDetector.failWhenUsingCustomJobServiceAndIdsAreNotSpecified`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=409906. + (##) Including !!! diff --git a/docs/checks/SquareAndRoundTilePreviews.md.html b/docs/checks/SquareAndRoundTilePreviews.md.html index d887dd4..b722ffa 100644 --- a/docs/checks/SquareAndRoundTilePreviews.md.html +++ b/docs/checks/SquareAndRoundTilePreviews.md.html @@ -42,7 +42,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:8:Warning: Tiles need preview assets [SquareAndRoundTilePreviews] - <service ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StartActivityAndCollapseDeprecated.md.html b/docs/checks/StartActivityAndCollapseDeprecated.md.html index 9a865e8..50e7bcc 100644 --- a/docs/checks/StartActivityAndCollapseDeprecated.md.html +++ b/docs/checks/StartActivityAndCollapseDeprecated.md.html @@ -41,7 +41,6 @@ src/test.kt:6:Error: TileService#startActivityAndCollapse(Intent) is deprecated. Use TileService#startActivityAndCollapse(PendingIntent) instead. [StartActivityAndCollapseDeprecated] - tileService.startActivityAndCollapse(intent) // ERROR ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StateFlowValueCalledInComposition.md.html b/docs/checks/StateFlowValueCalledInComposition.md.html index aecd1a9..7ddab33 100644 --- a/docs/checks/StateFlowValueCalledInComposition.md.html +++ b/docs/checks/StateFlowValueCalledInComposition.md.html @@ -47,18 +47,76 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text - -src/androidx/compose/runtime/foo/TestFlow.kt:19:Error: StateFlow.value +src/androidx/compose/runtime/foo/TestFlow.kt:20:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:24:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + stateFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:25:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:29:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + stateFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:30:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:39:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + stateFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:40:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:43:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + stateFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:44:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:50:Error: StateFlow.value should not be called within composition [StateFlowValueCalledInComposition] - stateFlow.value ----- +src/androidx/compose/runtime/foo/TestFlow.kt:51:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:55:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + stateFlow.value + ----- +src/androidx/compose/runtime/foo/TestFlow.kt:56:Error: StateFlow.value +should not be called within composition +[StateFlowValueCalledInComposition] + testFlow.value + ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: -` src/androidx/compose/runtime/foo/TestFlow.kt`: +`src/androidx/compose/runtime/foo/TestFlow.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers package androidx.compose.runtime.foo @@ -136,17 +194,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.runtime:runtime-android:1.7.0-beta04") +implementation("androidx.compose.runtime:runtime-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta04' +implementation 'androidx.compose.runtime:runtime-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.runtime-android) # libs.versions.toml [versions] -runtime-android = "1.7.0-beta04" +runtime-android = "1.7.0-beta05" [libraries] runtime-android = { module = "androidx.compose.runtime:runtime-android", @@ -154,7 +212,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.runtime:runtime-android](androidx_compose_runtime_runtime-android.md.html). diff --git a/docs/checks/StateListReachable.md.html b/docs/checks/StateListReachable.md.html index b237f8d..9743d14 100644 --- a/docs/checks/StateListReachable.md.html +++ b/docs/checks/StateListReachable.md.html @@ -40,7 +40,6 @@ res/drawable/states.xml:3:Warning: This item is unreachable because a previous item (item #1) is a more general match than this one [StateListReachable] - <item android:state_pressed="true" ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StaticFieldLeak.md.html b/docs/checks/StaticFieldLeak.md.html index 134d499..38e453d 100644 --- a/docs/checks/StaticFieldLeak.md.html +++ b/docs/checks/StaticFieldLeak.md.html @@ -49,37 +49,24 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/LeakTest.java:18:Warning: Do not place Android context classes in static fields; this is a memory leak [StaticFieldLeak] - private static Activity sField7; // LEAK! ------ - - src/test/pkg/LeakTest.java:19:Warning: Do not place Android context classes in static fields; this is a memory leak [StaticFieldLeak] - private static Fragment sField8; // LEAK! ------ - - src/test/pkg/LeakTest.java:20:Warning: Do not place Android context classes in static fields; this is a memory leak [StaticFieldLeak] - private static Button sField9; // LEAK! ------ - - src/test/pkg/LeakTest.java:21:Warning: Do not place Android context classes in static fields (static reference to MyObject which has field mActivity pointing to Activity); this is a memory leak [StaticFieldLeak] - private static MyObject sField10; ------ - - src/test/pkg/LeakTest.java:30:Warning: Do not place Android context classes in static fields; this is a memory leak [StaticFieldLeak] - private static Activity sAppContext1; // LEAK ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StopShip.md.html b/docs/checks/StopShip.md.html index 82a0a10..4345067 100644 --- a/docs/checks/StopShip.md.html +++ b/docs/checks/StopShip.md.html @@ -53,14 +53,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/Hidden.java:11:Error: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip] - // STOPSHIP -------- - - src/test/pkg/Hidden.java:12:Error: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip] - /* We must STOPSHIP! */ -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StrandhoggVulnerable.md.html b/docs/checks/StrandhoggVulnerable.md.html new file mode 100644 index 0000000..7579831 --- /dev/null +++ b/docs/checks/StrandhoggVulnerable.md.html @@ -0,0 +1,146 @@ + +(#) Application vulnerable to Strandhogg attacks + +!!! WARNING: Application vulnerable to Strandhogg attacks + This is a warning. + +Id +: `StrandhoggVulnerable` +Summary +: Application vulnerable to Strandhogg attacks +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Manifest files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/StrandhoggVulnerable +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/StrandhoggDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/StrandhoggDetectorTest.kt) +Copyright Year +: 2023 + +Apps targeting SDK versions earlier than 28 are susceptible to +Strandhogg / Task Affinity attacks. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +AndroidManifest.xml:2:Warning: Update your application's target SDK +version to 28 and above to protect it from Strandhogg attacks +[StrandhoggVulnerable] +<uses-sdk android:targetSdkVersion='27'/> + -- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`AndroidManifest.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='test.pkg'> +<uses-sdk android:targetSdkVersion='27'/> +<application android:debuggable='false'> + <activity android:name='com.example.MainActivity'></activity> +</application> +</manifest> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/StrandhoggDetectorTest.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, `StrandhoggDetector.testWhenTargetSdkBelowStrandhoggPatch_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="StrandhoggVulnerable"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <manifest xmlns:tools="http://schemas.android.com/tools"> + ... + <uses-sdk tools:ignore="StrandhoggVulnerable" .../> + ... + </manifest> + ``` + +* 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="StrandhoggVulnerable" 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 'StrandhoggVulnerable' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore StrandhoggVulnerable ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/StringEscaping.md.html b/docs/checks/StringEscaping.md.html index 5623b6e..bcbeb6c 100644 --- a/docs/checks/StringEscaping.md.html +++ b/docs/checks/StringEscaping.md.html @@ -41,35 +41,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/strings.xml:3:Error: Apostrophe not preceded by \ [StringEscaping] - <string name="some_string">'ERROR'</string> ^ - - res/values/strings.xml:5:Error: Apostrophe not preceded by \ [StringEscaping] - <string name="some_string3">What's New</string> ^ - - res/values/strings.xml:12:Error: Bad character in \u unicode escape sequence [StringEscaping] - <string name="some_string10">Unicode\u12.</string> ^ - - res/values/strings.xml:19:Error: Apostrophe not preceded by \ [StringEscaping] - <item>It's incorrect</item> ^ - - res/values/strings.xml:23:Error: Apostrophe not preceded by \ [StringEscaping] - <item quantity="few">%d piose'nki.</item> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StringFormatCount.md.html b/docs/checks/StringFormatCount.md.html index 6b07d1c..c6ad2fa 100644 --- a/docs/checks/StringFormatCount.md.html +++ b/docs/checks/StringFormatCount.md.html @@ -44,7 +44,6 @@ res/values-es/formatstrings.xml:2:Warning: Inconsistent number of arguments in formatting string hello; found both 3 here and 2 in values/formatstrings.xml [StringFormatCount] - <string name="hello">%3$d: %1$s, %2$s?</string> ----------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StringFormatInTimber.md.html b/docs/checks/StringFormatInTimber.md.html index 6528bee..5b082dc 100644 --- a/docs/checks/StringFormatInTimber.md.html +++ b/docs/checks/StringFormatInTimber.md.html @@ -45,12 +45,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/foo/Example.java:5:Warning: Using 'String#format' inside of 'Timber' [StringFormatInTimber] - Timber.d(String.format("%s", "arg1")); --------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/foo/Example.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -63,6 +62,17 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`src/foo/Example.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package foo +import timber.log.Timber +class Example { + fun log() { + Timber.d(String.format("%s", "arg1")) + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also visit the [source code](https://github.com/JakeWharton/timber/tree/trunk/timber-lint/src/test/java/timber/lint/WrongTimberUsageDetectorTest.kt) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/StringFormatInvalid.md.html b/docs/checks/StringFormatInvalid.md.html index cc473de..5db2597 100644 --- a/docs/checks/StringFormatInvalid.md.html +++ b/docs/checks/StringFormatInvalid.md.html @@ -55,7 +55,6 @@ src/StringFormatInvalid.java:3:Error: Format string 'no_args' is not a valid format string so it should not be passed to String.format [StringFormatInvalid] - context.getString(R.string.no_args, "first"); // ERROR -------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StringFormatMatches.md.html b/docs/checks/StringFormatMatches.md.html index d3a227a..557daf0 100644 --- a/docs/checks/StringFormatMatches.md.html +++ b/docs/checks/StringFormatMatches.md.html @@ -44,7 +44,6 @@ argument '#1' in score: conversion is 'd', received boolean (argument #2 in method call) (Did you mean formatting character b?) [StringFormatMatches] - String output4 = String.format(score, true); // wrong ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/StringFormatTrivial.md.html b/docs/checks/StringFormatTrivial.md.html index c0f82b0..f9d57b9 100644 --- a/docs/checks/StringFormatTrivial.md.html +++ b/docs/checks/StringFormatTrivial.md.html @@ -44,28 +44,21 @@ src/test/pkg/Trivial.java:10:Warning: This formatting string is trivial. Rather than using String.format to create your String, it will be more performant to concatenate your arguments with +. [StringFormatTrivial] - String output1a = String.format("%s", "Hello world"); ---- - - src/test/pkg/Trivial.java:11:Warning: This formatting string is trivial. Rather than using String.format to create your String, it will be more performant to concatenate your arguments with +. [StringFormatTrivial] - String output2a = String.format("%s %c", "Hello world", '!'); ------- - - src/test/pkg/Trivial.java:12:Warning: This formatting string is trivial. Rather than using String.format to create your String, it will be more performant to concatenate your arguments with +. [StringFormatTrivial] - String output3a = String.format("%s %c %b", "Hello world", '!', true); ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: `src/test/pkg/Trivial.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers @@ -96,6 +89,17 @@ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="trivial1">%s</string> + <string name="trivial2">%s %c</string> + <string name="trivial3">%s %c %b</string> +</resources> + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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/StringFormatDetectorTest.java) for the unit tests for this check to see additional scenarios. diff --git a/docs/checks/StringNotCapitalized.md.html b/docs/checks/StringNotCapitalized.md.html index feac8b5..54a3f2c 100644 --- a/docs/checks/StringNotCapitalized.md.html +++ b/docs/checks/StringNotCapitalized.md.html @@ -1,13 +1,13 @@ -(#) Marks strings which are not capitalized. +(#) Marks strings which are not capitalized -!!! WARNING: Marks strings which are not capitalized. +!!! WARNING: Marks strings which are not capitalized This is a warning. Id : `StringNotCapitalized` Summary -: Marks strings which are not capitalized. +: Marks strings which are not capitalized Severity : Warning Category @@ -29,9 +29,44 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/StringNotCapitalizedDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/StringNotCapitalizedDetectorTest.kt) Every string should be capitalized. If not, it is flagged. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/values/strings.xml:2:Warning: String is not capitalized +[StringNotCapitalized] + <string name="my_string">my string</string> + ^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/values/strings.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<resources> + <string name="my_string">my string</string> +</resources> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/StringNotCapitalizedDetectorTest.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, `StringNotCapitalizedDetector.lowercase`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/StringShouldBeInt.md.html b/docs/checks/StringShouldBeInt.md.html index 15af4f6..678b631 100644 --- a/docs/checks/StringShouldBeInt.md.html +++ b/docs/checks/StringShouldBeInt.md.html @@ -47,28 +47,18 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:4:Error: Use an integer rather than a string here (replace '19' with just 19) [StringShouldBeInt] - compileSdkVersion '19' ---------------------- - - build.gradle:7:Error: Use an integer rather than a string here (replace '8' with just 8) [StringShouldBeInt] - minSdkVersion '8' ----------------- - - build.gradle:8:Error: Use an integer rather than a string here (replace "16" with just 16) [StringShouldBeInt] - targetSdkVersion "16" --------------------- - - build.gradle:10:Error: Use an integer rather than a string here (replace '19' with just 19) [StringShouldBeInt] - compileSdk '19' --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SubscribeOnMain.md.html b/docs/checks/SubscribeOnMain.md.html index c57f400..7a3ae4f 100644 --- a/docs/checks/SubscribeOnMain.md.html +++ b/docs/checks/SubscribeOnMain.md.html @@ -1,13 +1,13 @@ -(#) subscribeOn called with the main thread scheduler. +(#) subscribeOn called with the main thread scheduler -!!! ERROR: subscribeOn called with the main thread scheduler. +!!! ERROR: subscribeOn called with the main thread scheduler This is an error. Id : `SubscribeOnMain` Summary -: subscribeOn called with the main thread scheduler. +: subscribeOn called with the main thread scheduler Severity : Error Category @@ -34,7 +34,7 @@ Editing : This check runs on the fly in the IDE editor Implementation -: [Source Code](https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/rx/RxSubscribeOnMainDetector.kt) +: [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/main/java/slack/lint/rx/RxSubscribeOnMainDetector.kt) Tests : [Source Code](https://github.com/slackhq/slack-lints/tree/main/slack-lint-checks/src/test/java/slack/lint/rx/RxSubscribeOnMainDetectorTest.kt) Copyright Year @@ -59,12 +59,24 @@ initial subscription (above this line) run on the main thread. You probably want observeOn(AndroidSchedulers.mainThread()). [SubscribeOnMain] - obs.subscribeOn(AndroidSchedulers.mainThread()); ------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here is the source file referenced above: +Here are the relevant source files: + +`src/io/reactivex/rxjava3/android/schedulers/AndroidSchedulers.java`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers +package io.reactivex.rxjava3.android.schedulers; + +import io.reactivex.rxjava3.core.Scheduler; + +public final class AndroidSchedulers { + public static Scheduler mainThread() { + return null; + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `src/com/slack/lint/Foo.java`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers diff --git a/docs/checks/SuperfluousMarginDeclaration.md.html b/docs/checks/SuperfluousMarginDeclaration.md.html index 3840293..80789b9 100644 --- a/docs/checks/SuperfluousMarginDeclaration.md.html +++ b/docs/checks/SuperfluousMarginDeclaration.md.html @@ -1,13 +1,13 @@ -(#) Flags margin declarations that can be simplified. +(#) Flags margin declarations that can be simplified -!!! WARNING: Flags margin declarations that can be simplified. +!!! WARNING: Flags margin declarations that can be simplified This is a warning. Id : `SuperfluousMarginDeclaration` Summary -: Flags margin declarations that can be simplified. +: Flags margin declarations that can be simplified Severity : Warning Category @@ -29,10 +29,48 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/SuperfluousMarginDeclarationDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/SuperfluousMarginDeclarationDetectorTest.kt) Instead of using start-, end-, bottom- and top margins, layout_margin can be used. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:1:Warning: Should be using layout_margin instead. +[SuperfluousMarginDeclaration] +<TextView +^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/SuperfluousMarginDeclarationDetectorTest.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, `SuperfluousMarginDeclarationDetector.androidMarginSame`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/SuperfluousNameSpace.md.html b/docs/checks/SuperfluousNameSpace.md.html index 4507b37..0f813a6 100644 --- a/docs/checks/SuperfluousNameSpace.md.html +++ b/docs/checks/SuperfluousNameSpace.md.html @@ -1,13 +1,13 @@ -(#) Flags namespaces that are already declared. +(#) Flags namespaces that are already declared -!!! WARNING: Flags namespaces that are already declared. +!!! WARNING: Flags namespaces that are already declared This is a warning. Id : `SuperfluousNameSpace` Summary -: Flags namespaces that are already declared. +: Flags namespaces that are already declared Severity : Warning Category @@ -29,9 +29,46 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/SuperfluousNameSpaceDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/SuperfluousNameSpaceDetectorTest.kt) Re-declaring a namespace is unnecessary and hence can be just removed. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/activity_home.xml:3:Warning: This name space is already +declared and hence not needed [SuperfluousNameSpace] + xmlns:android="http://schemas.android.com/apk/res/android" + ---------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/activity_home.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> + <TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content"/> +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/SuperfluousNameSpaceDetectorTest.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, `SuperfluousNameSpaceDetector.androidNamespaceOnChild`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/SuperfluousPaddingDeclaration.md.html b/docs/checks/SuperfluousPaddingDeclaration.md.html index 2cfa5d8..b768dc2 100644 --- a/docs/checks/SuperfluousPaddingDeclaration.md.html +++ b/docs/checks/SuperfluousPaddingDeclaration.md.html @@ -1,13 +1,13 @@ -(#) Flags padding declarations that can be simplified. +(#) Flags padding declarations that can be simplified -!!! WARNING: Flags padding declarations that can be simplified. +!!! WARNING: Flags padding declarations that can be simplified This is a warning. Id : `SuperfluousPaddingDeclaration` Summary -: Flags padding declarations that can be simplified. +: Flags padding declarations that can be simplified Severity : Warning Category @@ -29,10 +29,48 @@ : Resource 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/kotlin/com/vanniktech/lintrules/android/SuperfluousPaddingDeclarationDetector.kt) +Tests +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/SuperfluousPaddingDeclarationDetectorTest.kt) Instead of using start-, end-, bottom- and top paddings, padding can be used. +!!! Tip + This lint check has an associated quickfix available in the IDE. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/layout/ids.xml:1:Warning: Should be using padding instead. +[SuperfluousPaddingDeclaration] +<TextView +^ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/layout/ids.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp"/> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/SuperfluousPaddingDeclarationDetectorTest.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, `SuperfluousPaddingDeclarationDetector.androidPaddingSame`. +To report a problem with this extracted sample, visit +https://github.com/vanniktech/lint-rules/issues. + (##) Including !!! diff --git a/docs/checks/SupportAnnotationUsage.md.html b/docs/checks/SupportAnnotationUsage.md.html index 55a0a09..18e42df 100644 --- a/docs/checks/SupportAnnotationUsage.md.html +++ b/docs/checks/SupportAnnotationUsage.md.html @@ -42,15 +42,11 @@ @java.lang.annotation.Target here; these targets will be ignored from Kotlin and the annotation will not be allowed on any element types from Java [SupportAnnotationUsage] - @java.lang.annotation.Target(ElementType.PARAMETER) // ERROR 1 ------ - - src/test/pkg/Annotation1.kt:19:Error: Do not use @java.lang.annotation.Target here; it will cause the annotation to not be allowed on any element types from Java [SupportAnnotationUsage] - @java.lang.annotation.Target(ElementType.PARAMETER) // ERROR 2 ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/Suspicious0dp.md.html b/docs/checks/Suspicious0dp.md.html index 00ff84e..e951224 100644 --- a/docs/checks/Suspicious0dp.md.html +++ b/docs/checks/Suspicious0dp.md.html @@ -43,35 +43,22 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/wrong0dp.xml:19:Error: Suspicious size: this will make the view invisible, should be used with layout_weight [Suspicious0dp] - android:layout_width="0dp" -------------------------- - - res/layout/wrong0dp.xml:25:Error: Suspicious size: this will make the view invisible, should be used with layout_weight [Suspicious0dp] - android:layout_height="0dp" --------------------------- - - res/layout/wrong0dp.xml:34:Error: Suspicious size: this will make the view invisible, probably intended for layout_height [Suspicious0dp] - android:layout_width="0dp" -------------------------- - - res/layout/wrong0dp.xml:67:Error: Suspicious size: this will make the view invisible, probably intended for layout_width [Suspicious0dp] - android:layout_height="0dp" --------------------------- - - res/layout/wrong0dp.xml:90:Error: Suspicious size: this will make the view invisible, probably intended for layout_width [Suspicious0dp] - android:layout_height="0dp" --------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SuspiciousCompositionLocalModifierRead.md.html b/docs/checks/SuspiciousCompositionLocalModifierRead.md.html index f6cf679..469539c 100644 --- a/docs/checks/SuspiciousCompositionLocalModifierRead.md.html +++ b/docs/checks/SuspiciousCompositionLocalModifierRead.md.html @@ -61,17 +61,13 @@ To be notified of the latest value of the CompositionLocal, read the value in one of the modifier's other callbacks. [SuspiciousCompositionLocalModifierRead] - val readValue = currentValueOf(localInt) ------------------------ - - src/test/NodeUnderTest.kt:20:Error: Reading staticLocalInt in onDetach will only access the CompositionLocal's value when the modifier is detached. To be notified of the latest value of the CompositionLocal, read the value in one of the modifier's other callbacks. [SuspiciousCompositionLocalModifierRead] - val readValue = currentValueOf(staticLocalInt) ------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -120,17 +116,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -138,7 +134,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/SuspiciousImport.md.html b/docs/checks/SuspiciousImport.md.html index 902741d..ff7be57 100644 --- a/docs/checks/SuspiciousImport.md.html +++ b/docs/checks/SuspiciousImport.md.html @@ -43,7 +43,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/BadImport.java:5:Warning: Don't include android.R here; use a fully qualified name for each usage instead [SuspiciousImport] - import android.R; ----------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SuspiciousIndentation.md.html b/docs/checks/SuspiciousIndentation.md.html index f8e5ab9..025f6a4 100644 --- a/docs/checks/SuspiciousIndentation.md.html +++ b/docs/checks/SuspiciousIndentation.md.html @@ -67,105 +67,19 @@ Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text -src/Java.java:4:Error: Suspicious indentation: This is conditionally -executed; expected it to be indented [SuspiciousIndentation] - - System.out.println("test"); // WARN 1 - -------------------------- - - -src/Java.java:7:Error: Suspicious indentation: This is indented but is -not nested under the previous expression (if (context == null)...) -[SuspiciousIndentation] - - System.out.println("test"); // WARN 2 - -------------------------- - - src/Kotlin.kt:8:Error: Suspicious indentation: This is indented but is not nested under the previous expression (if (this[i] == '\n')...) [SuspiciousIndentation] - - line++ // WARN 3 + line++ // WARN1 ------ - - src/Kotlin.kt:15:Error: Suspicious indentation: This is indented but is not continuing the previous expression (var s = "The price i...) [SuspiciousIndentation] - - price.toString() + // WARN 4 - ---------------------------- - - -src/Kotlin.kt:23:Error: Suspicious indentation: This is indented but is -not continuing the previous expression (s += "The price...) -[SuspiciousIndentation] - - price.toString() + // WARN 5 - ---------------------------- - - -src/Kotlin.kt:32:Error: Suspicious indentation: This is indented but is -not continuing the previous expression (s = "The price was...) -[SuspiciousIndentation] - - price.toString() + // WARN 6 + price.toString() + // WARN 2 ---------------------------- - - -src/Kotlin.kt:42:Error: Suspicious indentation: This is indented but is -not nested under the previous expression (for (i in 0 until 10...) -[SuspiciousIndentation] - - y++ // WARN 7 - --- - - -src/Kotlin.kt:48:Error: Suspicious indentation: This is indented but is -not nested under the previous expression (while (x > 0) ...) -[SuspiciousIndentation] - - y++ // WARN 8 - --- - - -src/Kotlin.kt:55:Error: Suspicious indentation: This is conditionally -executed; expected it to be indented [SuspiciousIndentation] - - println("hello") // WARN 9 - ---------------- - - -src/Kotlin.kt:62:Error: Suspicious indentation: This is conditionally -executed; expected it to be indented [SuspiciousIndentation] - - println("hello") // WARN 10 - ---------------- - - -src/Kotlin.kt:73:Error: Suspicious indentation: This is indented but is -not nested under the previous expression (if (this[i] != '\n')...) -[SuspiciousIndentation] - - line++ // WARN 11 - ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here are the relevant source files: - -`src/Java.java`: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers -class Java { - public void test(Object context) { - if (context == null) - System.out.println("test"); // WARN 1 - if (context == null) - System.out.println("test"); // OK - System.out.println("test"); // WARN 2 - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Here is the source file referenced above: `src/Kotlin.kt`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers @@ -176,75 +90,16 @@ column++ if (this[i] == '\n') column = 0 - line++ // WARN 3 + line++ // WARN1 } return Pair(line, column) } -fun getFooter1(price: Int) { - var s = "The price is: " // missing + - price.toString() + // WARN 4 +fun getPriceString(price: Int) { + var s = "The price is: " + price.toString() + // WARN 2 "." } - -fun getFooter2(price: Int) { - var s = "" - if (price > 100) { - s += "The price " // missing + - price.toString() + // WARN 5 - " is high." - } -} - -fun getFooter3(price: Int) { - var s = "" - if (price < 1000) { - s = "The price was " // missing + - price.toString() + // WARN 6 - "." - } -} - -fun loops1() { - var x = 0 - var y = 0 - for (i in 0 until 100) - x++ - y++ // WARN 7 -} - -fun loops2() { - while (x > 0) - x-- - y++ // WARN 8 -} - -fun expectedIndent1(x: Int) { - if (x > 10) - println("hello") // OK - if (x < 10) - println("hello") // WARN 9 -} - -fun expectedIndent2(x: Int) { - if (x < 10) - println("hello") - else - println("hello") // WARN 10 -} - -fun String.getLineAndColumn2(offset: Int): Pair { - var line = 1 - var column = 1 - for (i in 0 until offset) { - column++ - if (this[i] != '\n') { - } else - column = 0 - line++ // WARN 11 - } - return Pair(line, column) -} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the diff --git a/docs/checks/SuspiciousModifierThen.md.html b/docs/checks/SuspiciousModifierThen.md.html index cff228a..d41e0e7 100644 --- a/docs/checks/SuspiciousModifierThen.md.html +++ b/docs/checks/SuspiciousModifierThen.md.html @@ -58,21 +58,14 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/TestModifier.kt:10:Error: Using Modifier.then with a Modifier factory function with an implicit receiver [SuspiciousModifierThen] - fun Modifier.test2() = this.then(test()) ---- - - src/test/TestModifier.kt:12:Error: Using Modifier.then with a Modifier factory function with an implicit receiver [SuspiciousModifierThen] - fun Modifier.test3() = this.then(with(1) { test() }) ---- - - src/test/TestModifier.kt:14:Error: Using Modifier.then with a Modifier factory function with an implicit receiver [SuspiciousModifierThen] - fun Modifier.test4() = this.then(if (true) test() else TestModifier) ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -113,17 +106,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-android:1.7.0-beta04") +implementation("androidx.compose.ui:ui-android:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-android:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-android:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-android) # libs.versions.toml [versions] -ui-android = "1.7.0-beta04" +ui-android = "1.7.0-beta05" [libraries] ui-android = { module = "androidx.compose.ui:ui-android", @@ -131,7 +124,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-android](androidx_compose_ui_ui-android.md.html). diff --git a/docs/checks/SwitchIntDef.md.html b/docs/checks/SwitchIntDef.md.html index 8e0f1ad..74e4299 100644 --- a/docs/checks/SwitchIntDef.md.html +++ b/docs/checks/SwitchIntDef.md.html @@ -41,50 +41,31 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/X.java:40:Warning: Don't use a constant here; expected one of: LENGTH_INDEFINITE, LENGTH_LONG, LENGTH_SHORT [SwitchIntDef] - case 5: - - - src/test/pkg/X.java:47:Warning: Switch statement on an int with known associated constant missing case LENGTH_LONG [SwitchIntDef] - switch (duration) { ------ - - src/test/pkg/X.java:56:Warning: Switch statement on an int with known associated constant missing case LENGTH_INDEFINITE, LENGTH_LONG, LENGTH_SHORT [SwitchIntDef] - switch (duration) { ------ - - src/test/pkg/X.java:66:Warning: Switch statement on an int with known associated constant missing case LENGTH_SHORT [SwitchIntDef] - switch (duration) { ------ - - src/test/pkg/X.java:75:Warning: Switch statement on an int with known associated constant missing case LENGTH_SHORT [SwitchIntDef] - switch ((int)getDuration()) { ------ - - src/test/pkg/X.java:85:Warning: Switch statement on an int with known associated constant missing case LENGTH_SHORT [SwitchIntDef] - switch (true ? getDuration() : 0) { ------ - - src/test/pkg/X.java:95:Warning: Switch statement on an int with known associated constant missing case X.LENGTH_SHORT [SwitchIntDef] - switch (X.getDuration()) { ------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SyntheticAccessor.md.html b/docs/checks/SyntheticAccessor.md.html index 614b998..fad060a 100644 --- a/docs/checks/SyntheticAccessor.md.html +++ b/docs/checks/SyntheticAccessor.md.html @@ -52,58 +52,36 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text src/test/pkg/AccessTest.java:33:Warning: Access to private constructor of class AccessTest requires synthetic accessor [SyntheticAccessor] - new AccessTest(); // ERROR ---------------- - - src/test/pkg/AccessTest.java:36:Warning: Access to private field field1 of class AccessTest requires synthetic accessor [SyntheticAccessor] - int f1 = field1; // ERROR ------ - - src/test/pkg/AccessTest.java:40:Warning: Access to private field field5 of class AccessTest requires synthetic accessor [SyntheticAccessor] - Inner[] f5 = field5; // ERROR ------ - - src/test/pkg/AccessTest.java:42:Warning: Access to private method method1 of class AccessTest requires synthetic accessor [SyntheticAccessor] - method1(); // ERROR ------- - - src/test/pkg/AccessTest.java:66:Warning: Access to private constructor of class AccessTest requires synthetic accessor [SyntheticAccessor] - new AccessTest(); // ERROR ---------------- - - src/test/pkg/AccessTest.java:69:Warning: Access to private field field1 of class AccessTest requires synthetic accessor [SyntheticAccessor] - int f1 = field1; // ERROR ------ - - src/test/pkg/AccessTest.java:73:Warning: Access to private field field5 of class AccessTest requires synthetic accessor [SyntheticAccessor] - Inner[] f5 = field5; // ERROR ------ - - src/test/pkg/AccessTest.java:75:Warning: Access to private method method1 of class AccessTest requires synthetic accessor [SyntheticAccessor] - method1(); // ERROR ------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/SystemPermissionTypo.md.html b/docs/checks/SystemPermissionTypo.md.html index b2bcc49..f0af31a 100644 --- a/docs/checks/SystemPermissionTypo.md.html +++ b/docs/checks/SystemPermissionTypo.md.html @@ -41,49 +41,30 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text AndroidManifest.xml:5:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <uses-permission android:name="android.permission.BIND_NCF_SERVICE" /> ----------------------------------- - - AndroidManifest.xml:6:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <application android:name="App" android:permission="android.permission.BIND_NCF_SERVICE"> ----------------------------------- - - AndroidManifest.xml:9:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <activity android:permission="android.permission.BIND_NCF_SERVICE" /> ----------------------------------- - - AndroidManifest.xml:10:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <activity-alias android:permission="android.permission.BIND_NCF_SERVICE" /> ----------------------------------- - - AndroidManifest.xml:11:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <receiver android:permission="android.permission.BIND_NCF_SERVICE" /> ----------------------------------- - - AndroidManifest.xml:12:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <service android:permission="android.permission.BIND_NCF_SERVICE" /> ----------------------------------- - - AndroidManifest.xml:13:Warning: Did you mean android.permission.BIND_NFC_SERVICE? [SystemPermissionTypo] - <provider android:permission="android.permission.BIND_NCF_SERVICE" /> ----------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/TapjackingVulnerable.md.html b/docs/checks/TapjackingVulnerable.md.html new file mode 100644 index 0000000..e048b81 --- /dev/null +++ b/docs/checks/TapjackingVulnerable.md.html @@ -0,0 +1,146 @@ + +(#) Application's UI is vulnerable to tapjacking attacks + +!!! WARNING: Application's UI is vulnerable to tapjacking attacks + This is a warning. + +Id +: `TapjackingVulnerable` +Summary +: Application's UI is vulnerable to tapjacking attacks +Severity +: Warning +Category +: Security +Platform +: Android +Vendor +: Google - Android 3P Vulnerability Research +Contact +: https://github.com/google/android-security-lints +Feedback +: https://github.com/google/android-security-lints/issues +Min +: Lint 4.1 +Compiled +: Lint 8.0 and 8.1 +Artifact +: [google.android-security-lints](google_android-security-lints.md.html) + +Affects +: Resource files +Editing +: This check runs on the fly in the IDE editor +See +: http://goo.gle/TapjackingVulnerable +Implementation +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/main/java/com/example/lint/checks/TapjackingDetector.kt) +Tests +: [Source Code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/TapjackingDetectorTest.kt) +Copyright Year +: 2023 + +Apps with sensitive UI elements should add the +`filterTouchesWithObscured` attribute to protect it from tapjacking / +overlay attacks. + +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +res/xml/switch.xml:3:Warning: Add the android:filterTouchesWhenObscured +attribute to protect this UI element from tapjacking / overlay attacks +[TapjackingVulnerable] + <Switch android:id='enable_setting'> + ------ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`res/xml/switch.xml`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> + <Switch android:id='enable_setting'> + </Switch> +</LinearLayout> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://github.com/google/android-security-lints/tree/main/checks/src/test/java/com/example/lint/checks/TapjackingDetectorTest.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, `TapjackingDetector.testWhenNamedEnableUiElement_showsWarning`. +To report a problem with this extracted sample, visit +https://github.com/google/android-security-lints/issues. + +(##) Including + +!!! + This is not a built-in check. To include it, add the below dependency + to your project. This lint check is included in the lint documentation, + but the Android team may or may not agree with its recommendations. + +!!! WARN + This library has not been published. Its documentation was + extracted by installing the project sources locally. Consult + the project's documentation on how to configure it with your + own projects: [](https://github.com/google/android-security-lints) + + +[Additional details about google.android-security-lints](google_android-security-lints.md.html). +(##) Suppressing + +You can suppress false positives using one of the following mechanisms: + +* Adding the suppression attribute + `tools:ignore="TapjackingVulnerable"` 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 + <?xml version="1.0" encoding="UTF-8"?> + <resources xmlns:tools="http://schemas.android.com/tools"> + ... + <ToggleButton tools:ignore="TapjackingVulnerable" .../> + ... + </resources> + ``` + +* 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="TapjackingVulnerable" 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 'TapjackingVulnerable' + } + ``` + In Android projects this should be nested inside an `android { }` + block. + +* For manual invocations of `lint`, using the `--ignore` flag: + ``` + $ lint --ignore TapjackingVulnerable ...` + ``` + +* Last, but not least, using baselines, as discussed + [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html). + + \ No newline at end of file diff --git a/docs/checks/TestAppLink.md.html b/docs/checks/TestAppLink.md.html index 3f64765..e046e69 100644 --- a/docs/checks/TestAppLink.md.html +++ b/docs/checks/TestAppLink.md.html @@ -42,7 +42,6 @@ AndroidManifest.xml:15:Error: Validation nodes should be in the tools: namespace to ensure they are removed from the manifest at build time [TestAppLink] - <validation /> ---------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/TestLifecycleOwnerInCoroutine.md.html b/docs/checks/TestLifecycleOwnerInCoroutine.md.html index 9ad01ec..d943129 100644 --- a/docs/checks/TestLifecycleOwnerInCoroutine.md.html +++ b/docs/checks/TestLifecycleOwnerInCoroutine.md.html @@ -1,13 +1,13 @@ -(#) Use the suspending function setCurrentState(), rather than directly accessing the currentState property. +(#) Use the suspending function setCurrentState(), rather than directly accessing the currentState property -!!! ERROR: Use the suspending function setCurrentState(), rather than directly accessing the currentState property. +!!! ERROR: Use the suspending function setCurrentState(), rather than directly accessing the currentState property This is an error. Id : `TestLifecycleOwnerInCoroutine` Summary -: Use the suspending function setCurrentState(), rather than directly accessing the currentState property. +: Use the suspending function setCurrentState(), rather than directly accessing the currentState property Severity : Error Category @@ -33,6 +33,8 @@ : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-testing-lint/src/main/java/androidx/lifecycle/testing/lint/TestLifecycleOwnerInCoroutineDetector.kt) +Tests +: [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-testing-lint/src/test/java/androidx/lifecycle/runtime/testing/lint/TestLifecycleOwnerInCoroutineDetectorTest.kt) Copyright Year : 2021 @@ -43,6 +45,52 @@ runTest), this will cause the setter to hang, since coroutines should remain asynchronous. +(##) Example + +Here is an example of lint warnings produced by this check: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text +src/example/foo/test.kt:8:Error: Incorrect use of currentState property +inside of Coroutine, please use the suspending setCurrentState() +function. [TestLifecycleOwnerInCoroutine] + fun testSetCurrentStateInRunTest() = runTest { + ------- +src/example/foo/test.kt:13:Error: Incorrect use of currentState property +inside of Coroutine, please use the suspending setCurrentState() +function. [TestLifecycleOwnerInCoroutine] + fun testSetCurrentStateInRunTestWithTimeOut() = runTest(timeout = 5000) { + ------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is the source file referenced above: + +`src/example/foo/test.kt`: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers +package example.foo + +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.testing.TestLifecycleOwner +import kotlinx.coroutines.test.runTest + +fun testSetCurrentStateInRunTest() = runTest { + val owner = TestLifecycleOwner() + owner.currentState = Lifecycle.State.RESUMED +} + +fun testSetCurrentStateInRunTestWithTimeOut() = runTest(timeout = 5000) { + val owner = TestLifecycleOwner() + owner.currentState = Lifecycle.State.RESUMED +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also visit the +[source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-runtime-testing-lint/src/test/java/androidx/lifecycle/runtime/testing/lint/TestLifecycleOwnerInCoroutineDetectorTest.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, `TestLifecycleOwnerInCoroutineDetector.errors`. +To report a problem with this extracted sample, visit +https://issuetracker.google.com/issues/new?component=413132. + (##) Including !!! diff --git a/docs/checks/TestManifestGradleConfiguration.md.html b/docs/checks/TestManifestGradleConfiguration.md.html index 1c5216d..eaa9f74 100644 --- a/docs/checks/TestManifestGradleConfiguration.md.html +++ b/docs/checks/TestManifestGradleConfiguration.md.html @@ -1,13 +1,13 @@ -(#) The ui-test-manifest library should be included using the debugImplementation configuration. +(#) The ui-test-manifest library should be included using the debugImplementation configuration -!!! WARNING: The ui-test-manifest library should be included using the debugImplementation configuration. +!!! WARNING: The ui-test-manifest library should be included using the debugImplementation configuration This is a warning. Id : `TestManifestGradleConfiguration` Summary -: The ui-test-manifest library should be included using the debugImplementation configuration. +: The ui-test-manifest library should be included using the debugImplementation configuration Severity : Warning Category @@ -51,49 +51,30 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:2:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - implementation("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") ------------------------------------------------------------------- - - build.gradle:3:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - api("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") -------------------------------------------------------- - - build.gradle:4:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - compileOnly("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") ---------------------------------------------------------------- - - build.gradle:5:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - runtimeOnly("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") ---------------------------------------------------------------- - - build.gradle:6:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - annotationProcessor("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") ------------------------------------------------------------------------ - - build.gradle:7:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - lintChecks("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") --------------------------------------------------------------- - - build.gradle:8:Warning: Please use debugImplementation. [TestManifestGradleConfiguration] - lintPublish("androidx.compose.ui:ui-test-manifest:1.2.0-beta02") ---------------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -130,17 +111,17 @@ ``` // build.gradle.kts -implementation("androidx.compose.ui:ui-test-manifest:1.7.0-beta04") +implementation("androidx.compose.ui:ui-test-manifest:1.7.0-beta05") // build.gradle -implementation 'androidx.compose.ui:ui-test-manifest:1.7.0-beta04' +implementation 'androidx.compose.ui:ui-test-manifest:1.7.0-beta05' // build.gradle.kts with version catalogs: implementation(libs.ui-test-manifest) # libs.versions.toml [versions] -ui-test-manifest = "1.7.0-beta04" +ui-test-manifest = "1.7.0-beta05" [libraries] ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", @@ -148,7 +129,7 @@ } ``` -1.7.0-beta04 is the version this documentation was generated from; +1.7.0-beta05 is the version this documentation was generated from; there may be newer versions available. [Additional details about androidx.compose.ui:ui-test-manifest](androidx_compose_ui_ui-test-manifest.md.html). diff --git a/docs/checks/TextFields.md.html b/docs/checks/TextFields.md.html index 62a3dd0..063bdd0 100644 --- a/docs/checks/TextFields.md.html +++ b/docs/checks/TextFields.md.html @@ -51,14 +51,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/layout/note_edit.xml:43:Warning: This text field does not specify an inputType [TextFields] - <EditText -------- - - res/layout/note_edit.xml:50:Warning: This text field does not specify an inputType [TextFields] - <EditText -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/checks/TextViewEdits.md.html b/docs/checks/TextViewEdits.md.html index 1a0f7d7..3955a0a 100644 --- a/docs/checks/TextViewEdits.md.html +++ b/docs/checks/TextViewEdits.md.html @@ -47,167 +47,106 @@ res/layout/edit_textview.xml:13:Warning: Attribute android:autoText should not be used with : Change element type to ? [TextViewEdits] - android:autoText="true" ----------------------- - - res/layout/edit_textview.xml:14:Warning: Attribute android:bufferType should not be used with : Change element type to ? [TextViewEdits] - android:bufferType="editable" ----------------------------- - - res/layout/edit_textview.xml:15:Warning: Attribute android:capitalize should not be used with : Change element type to ? [TextViewEdits] - android:capitalize="words" -------------------------- - - res/layout/edit_textview.xml:16:Warning: Attribute android:cursorVisible should not be used with : Change element type to ? [TextViewEdits] - android:cursorVisible="true" ---------------------------- - - res/layout/edit_textview.xml:17:Warning: Attribute android:digits should not be used with : Change element type to ? [TextViewEdits] - android:digits="" ----------------- - - res/layout/edit_textview.xml:18:Warning: Attribute android:editable should not be used with : Change element type to ? [TextViewEdits] - android:editable="true" ----------------------- - - res/layout/edit_textview.xml:19:Warning: Attribute android:editorExtras should not be used with : Change element type to ? [TextViewEdits] - android:editorExtras="@+id/foobar" ---------------------------------- - - res/layout/edit_textview.xml:22:Warning: Attribute android:imeActionId should not be used with : Change element type to ? [TextViewEdits] - android:imeActionId="@+id/foo" ------------------------------ - - res/layout/edit_textview.xml:23:Warning: Attribute android:imeActionLabel should not be used with : Change element type to ? [TextViewEdits] - android:imeActionLabel="" ------------------------- - - res/layout/edit_textview.xml:24:Warning: Attribute android:imeOptions should not be used with : Change element type to ? [TextViewEdits] - android:imeOptions="" --------------------- - - res/layout/edit_textview.xml:25:Warning: Attribute android:inputMethod should not be used with : Change element type to ? [TextViewEdits] - android:inputMethod="" ---------------------- - - res/layout/edit_textview.xml:26:Warning: Attribute android:inputType should not be used with : Change element type to ? [TextViewEdits] - android:inputType="text" ------------------------ - - res/layout/edit_textview.xml:27:Warning: Attribute android:numeric should not be used with : Change element type to ? [TextViewEdits] - android:numeric="" ------------------ - - res/layout/edit_textview.xml:28:Warning: Attribute android:password should not be used with : Change element type to ? [TextViewEdits] - android:password="true" ----------------------- - - res/layout/edit_textview.xml:29:Warning: Attribute android:phoneNumber should not be used with : Change element type to ? [TextViewEdits] - android:phoneNumber="true" -------------------------- - - res/layout/edit_textview.xml:30:Warning: Attribute android:privateImeOptions should not be used with : Change element type to ? [TextViewEdits] - android:privateImeOptions="" /> ---------------------------- - - res/layout/edit_textview.xml:38:Warning: Attribute android:cursorVisible should not be used with