From 88dd20e6d4b1e5ebde4c106bd8075ea583bf4d1a Mon Sep 17 00:00:00 2001 From: Kevin Jeon Date: Tue, 24 Aug 2021 16:39:11 +0000 Subject: [PATCH] Revert "[lint] treat non-user getter calls as lint errors with baselines to exempt existing failures" This reverts commit ddea459a65fa27cfd5715680729746b54bfb1159. Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_master&target=errorprone&lkgb=7670042&lkbb=7670063&fkbb=7670063, bug 197639027 Change-Id: Ic45c5a1a5415570000c1c1de7868f005613281c2 --- services/backup/lint-baseline.xml | 15 ---------- services/companion/lint-baseline.xml | 15 ---------- services/usb/lint-baseline.xml | 15 ---------- ...ingSettingsNonUserGetterMethodsDetector.kt | 5 ++-- ...gsNonUserGetterMethodsIssueDetectorTest.kt | 28 +++++++++---------- 5 files changed, 16 insertions(+), 62 deletions(-) delete mode 100644 services/backup/lint-baseline.xml delete mode 100644 services/companion/lint-baseline.xml delete mode 100644 services/usb/lint-baseline.xml diff --git a/services/backup/lint-baseline.xml b/services/backup/lint-baseline.xml deleted file mode 100644 index 28bb937cfd9c7..0000000000000 --- a/services/backup/lint-baseline.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/services/companion/lint-baseline.xml b/services/companion/lint-baseline.xml deleted file mode 100644 index 03eae3901e51e..0000000000000 --- a/services/companion/lint-baseline.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/services/usb/lint-baseline.xml b/services/usb/lint-baseline.xml deleted file mode 100644 index c2c0a350d5ada..0000000000000 --- a/services/usb/lint-baseline.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt b/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt index fe567da7c017f..641f337ab9870 100644 --- a/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt +++ b/tools/lint/checks/src/main/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsDetector.kt @@ -45,8 +45,7 @@ class CallingSettingsNonUserGetterMethodsDetector : Detector(), SourceCodeScanne evaluator.isMemberInClass(method, "android.provider.Settings.System") ) { val message = getIncidentMessageNonUserGetterMethods(getMethodSignature(method)) - context.report(ISSUE_NON_USER_GETTER_CALLED, node, context.getNameLocation(node), - message) + context.report(ISSUE_NON_USER_GETTER_CALLED, node, context.getLocation(node), message) } } @@ -69,7 +68,7 @@ class CallingSettingsNonUserGetterMethodsDetector : Detector(), SourceCodeScanne """, category = Category.CORRECTNESS, priority = 6, - severity = Severity.ERROR, + severity = Severity.WARNING, implementation = Implementation( CallingSettingsNonUserGetterMethodsDetector::class.java, Scope.JAVA_FILE_SCOPE diff --git a/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt b/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt index e72f384163102..1034029f6e9d8 100644 --- a/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt +++ b/tools/lint/checks/src/test/java/com/google/android/lint/CallingSettingsNonUserGetterMethodsIssueDetectorTest.kt @@ -71,13 +71,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest() .run() .expect( """ - src/test/pkg/TestClass1.java:5: Error: \ + src/test/pkg/TestClass1.java:5: Warning: \ android.provider.Settings.Secure#getInt() called from system process. \ Please call android.provider.Settings.Secure#getIntForUser() instead. \ [NonUserGetterCalled] final int value = Secure.getInt(context.getContentResolver(), - ~~~~~~ - 1 errors, 0 warnings + ^ + 0 errors, 1 warnings """.addLineContinuation() ) } @@ -100,13 +100,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest() .run() .expect( """ - src/test/pkg/TestClass1.java:5: Error: \ + src/test/pkg/TestClass1.java:5: Warning: \ android.provider.Settings.System#getFloat() called from system process. \ Please call android.provider.Settings.System#getFloatForUser() instead. \ [NonUserGetterCalled] final float value = System.getFloat(context.getContentResolver(), - ~~~~~~~~ - 1 errors, 0 warnings + ^ + 0 errors, 1 warnings """.addLineContinuation() ) } @@ -130,13 +130,13 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest() .run() .expect( """ - src/test/pkg/TestClass1.java:5: Error: \ + src/test/pkg/TestClass1.java:5: Warning: \ android.provider.Settings.System#getFloat() called from system process. \ Please call android.provider.Settings.System#getFloatForUser() instead. \ [NonUserGetterCalled] float value = Settings.System.getFloat(context.getContentResolver(), - ~~~~~~~~ - 1 errors, 0 warnings + ^ + 0 errors, 1 warnings """.addLineContinuation() ) } @@ -163,19 +163,19 @@ class CallingSettingsNonUserGetterMethodsIssueDetectorTest : LintDetectorTest() .run() .expect( """ - src/test/pkg/TestClass1.java:6: Error: \ + src/test/pkg/TestClass1.java:6: Warning: \ android.provider.Settings.Secure#getLong() called from system process. \ Please call android.provider.Settings.Secure#getLongForUser() instead. \ [NonUserGetterCalled] final long value1 = Secure.getLong(context.getContentResolver(), - ~~~~~~~ - src/test/pkg/TestClass1.java:8: Error: \ + ^ + src/test/pkg/TestClass1.java:8: Warning: \ android.provider.Settings.System#getString() called from system process. \ Please call android.provider.Settings.System#getStringForUser() instead. \ [NonUserGetterCalled] final String value2 = System.getString(context.getContentResolver(), - ~~~~~~~~~ - 2 errors, 0 warnings + ^ + 0 errors, 2 warnings """.addLineContinuation() ) }