summaryrefslogtreecommitdiff
path: root/android-lint/src
diff options
context:
space:
mode:
authorIsaac Chai <ichai@google.com>2021-10-08 16:43:27 -0700
committerTreeHugger Robot <treehugger-gerrit@google.com>2021-10-18 21:33:53 +0000
commitbd074ca0350c8b3fdc7128c370f1e72133b7ca7e (patch)
treeaaea328d7a72537732a1b2ded32a70418e781e6e /android-lint/src
parent4220b614b5b076ef5f3e944e27f2740fc246a6bb (diff)
downloadidea-bd074ca0350c8b3fdc7128c370f1e72133b7ca7e.tar.gz
Add lint to detect if motion layout is missing an id
Bug: 157735162 Test: Manual test + unit test Change-Id: Iaa9d048bad286ca0d9b6464ba6689c28c28e72b1
Diffstat (limited to 'android-lint/src')
-rw-r--r--android-lint/src/META-INF/android-lint-plugin.xml1
-rw-r--r--android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutInvalidSceneFileReferenceInspection.kt2
-rw-r--r--android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutMissingIdInspection.kt24
3 files changed, 27 insertions, 0 deletions
diff --git a/android-lint/src/META-INF/android-lint-plugin.xml b/android-lint/src/META-INF/android-lint-plugin.xml
index 187c6736ba8..7b39172b59b 100644
--- a/android-lint/src/META-INF/android-lint-plugin.xml
+++ b/android-lint/src/META-INF/android-lint-plugin.xml
@@ -193,6 +193,7 @@
<globalInspection hasStaticDescription="true" shortName="AndroidLintMissingVersion" displayName="Missing application name/version" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="WARNING" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMissingVersionInspection"/>
<globalInspection hasStaticDescription="true" shortName="AndroidLintMockLocation" displayName="Using mock location provider in production" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="ERROR" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMockLocationInspection"/>
<globalInspection hasStaticDescription="true" shortName="AndroidLintMotionLayoutInvalidSceneFileReference" displayName="layoutDescription must specify a scene file" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="ERROR" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMotionLayoutInvalidSceneFileReferenceInspection"/>
+ <globalInspection hasStaticDescription="true" shortName="AndroidLintMotionLayoutMissingId" displayName="Views inside MotionLayout require an id" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="ERROR" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMotionLayoutMissingIdInspection"/>
<globalInspection hasStaticDescription="true" shortName="AndroidLintMotionSceneFileValidationError" displayName="Validation errors in MotionScene files" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="ERROR" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMotionSceneFileValidationErrorInspection"/>
<globalInspection hasStaticDescription="true" shortName="AndroidLintMultipleUsesSdk" displayName="Multiple &lt;uses-sdk> elements in the manifest" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="ERROR" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMultipleUsesSdkInspection"/>
<globalInspection hasStaticDescription="true" shortName="AndroidLintMutatingSharedPrefs" displayName="Mutating an Immutable SharedPrefs Set" bundle="messages.AndroidLintBundle" enabledByDefault="true" level="WARNING" implementationClass="com.android.tools.idea.lint.inspections.AndroidLintMutatingSharedPrefsInspection"/>
diff --git a/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutInvalidSceneFileReferenceInspection.kt b/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutInvalidSceneFileReferenceInspection.kt
index 73573bf56d4..fa41e5996a0 100644
--- a/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutInvalidSceneFileReferenceInspection.kt
+++ b/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutInvalidSceneFileReferenceInspection.kt
@@ -41,3 +41,5 @@ class AndroidLintMotionLayoutInvalidSceneFileReferenceInspection : AndroidLintIn
return arrayOf(GenerateMotionSceneFix(url))
}
}
+
+
diff --git a/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutMissingIdInspection.kt b/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutMissingIdInspection.kt
new file mode 100644
index 00000000000..b73094a5c37
--- /dev/null
+++ b/android-lint/src/com/android/tools/idea/lint/inspections/AndroidLintMotionLayoutMissingIdInspection.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+package com.android.tools.idea.lint.inspections
+
+import com.android.tools.idea.lint.common.AndroidLintInspectionBase
+import com.android.tools.lint.checks.MotionLayoutIdDetector
+import com.android.tools.idea.lint.AndroidLintBundle.Companion.message
+
+class AndroidLintMotionLayoutMissingIdInspection : AndroidLintInspectionBase(
+ message("android.lint.inspections.motion.layout.missing.id"), MotionLayoutIdDetector.MISSING_ID
+)