diff options
author | 2022-10-15 21:33:27 -0700 | |
---|---|---|
committer | 2022-10-15 21:33:27 -0700 | |
commit | 27db4326e4d0c62547c1b4c2c5544e220273148c (patch) | |
tree | a313f3b80f1ce2c0ddbe99b27fecf104db55983e | |
parent | 5d9c4ebe8eada295fff5758e9d25fd8894e09748 (diff) |
Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:
BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower
See https://errorprone.info/bugpatterns for more
information on the checks.
Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I46d5386474ff6fbd94568c10fdf11dff7016e2bd
6 files changed, 17 insertions, 24 deletions
diff --git a/src/com/android/documentsui/archives/Archive.java b/src/com/android/documentsui/archives/Archive.java index cf7ba2d49..7c0f47147 100644 --- a/src/com/android/documentsui/archives/Archive.java +++ b/src/com/android/documentsui/archives/Archive.java @@ -327,4 +327,4 @@ public abstract class Archive implements Closeable { checkArgumentEquals(expected.toString(), actual.toString(), message); } } -}; +} diff --git a/src/com/android/documentsui/archives/ArchiveId.java b/src/com/android/documentsui/archives/ArchiveId.java index 1ce0ede3e..f067807a4 100644 --- a/src/com/android/documentsui/archives/ArchiveId.java +++ b/src/com/android/documentsui/archives/ArchiveId.java @@ -54,4 +54,4 @@ public class ArchiveId { public String toDocumentId() { return mArchiveUri.toString() + DELIMITER + mAccessMode + DELIMITER + mPath; } -}; +} diff --git a/src/com/android/documentsui/base/Providers.java b/src/com/android/documentsui/base/Providers.java index e05730790..b0aa91d00 100644 --- a/src/com/android/documentsui/base/Providers.java +++ b/src/com/android/documentsui/base/Providers.java @@ -45,12 +45,11 @@ public final class Providers { public static final String AUTHORITY_BUGREPORT = "com.android.shell.documents"; private static final String DOCSUI_PACKAGE = "com.android.documentsui"; - private static final Set<String> SYSTEM_AUTHORITIES = new HashSet<String>() {{ - add(AUTHORITY_STORAGE); - add(AUTHORITY_DOWNLOADS); - add(AUTHORITY_MEDIA); - add(AUTHORITY_MTP); - }}; + private static final Set<String> SYSTEM_AUTHORITIES = Set.of( + AUTHORITY_STORAGE, + AUTHORITY_DOWNLOADS, + AUTHORITY_MEDIA, + AUTHORITY_MTP); public static boolean isArchiveUri(Uri uri) { return uri != null && ArchivesProvider.AUTHORITY.equals(uri.getAuthority()); diff --git a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java index 626710e52..f0c874d97 100644 --- a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java +++ b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java @@ -106,7 +106,7 @@ class DirectoryItemAnimator extends DefaultItemAnimator { class ItemInfo extends DefaultItemAnimator.ItemHolderInfo { boolean isActivated; - }; + } /** * Animates changes in background color. @@ -161,5 +161,5 @@ class DirectoryItemAnimator extends DefaultItemAnimator { @Override public void onAnimationRepeat(Animator animation) {} - }; -}; + } +} diff --git a/src/com/android/documentsui/roots/ProvidersCache.java b/src/com/android/documentsui/roots/ProvidersCache.java index ebd54972e..e053b45a7 100644 --- a/src/com/android/documentsui/roots/ProvidersCache.java +++ b/src/com/android/documentsui/roots/ProvidersCache.java @@ -89,12 +89,11 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName { // Not all providers are equally well written. If a provider returns // empty results we don't cache them...unless they're in this magical list // of beloved providers. - private static final List<String> PERMIT_EMPTY_CACHE = new ArrayList<String>() {{ + private static final List<String> PERMIT_EMPTY_CACHE = List.of( // MTP provider commonly returns no roots (if no devices are attached). - add(Providers.AUTHORITY_MTP); + Providers.AUTHORITY_MTP, // ArchivesProvider doesn't support any roots. - add(ArchivesProvider.AUTHORITY); - }}; + ArchivesProvider.AUTHORITY); private static final int FIRST_LOAD_TIMEOUT_MS = 5000; private final Context mContext; diff --git a/tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java b/tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java index 1e0e95e1c..29ed8e431 100644 --- a/tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java +++ b/tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java @@ -137,15 +137,10 @@ public class ArchiveHandleTest { return list; } - private static final List<ArchiveEntryRecord> sExpectEntries = - new ArrayList<ArchiveEntryRecord>() { - { - add(new ArchiveEntryRecord("hello/hello.txt", 48, false)); - add(new ArchiveEntryRecord("hello/inside_folder/hello_insside.txt", - 14, false)); - add(new ArchiveEntryRecord("hello/hello2.txt", 48, false)); - } - }; + private static final List<ArchiveEntryRecord> sExpectEntries = List.of( + new ArchiveEntryRecord("hello/hello.txt", 48, false), + new ArchiveEntryRecord("hello/inside_folder/hello_insside.txt", 14, false), + new ArchiveEntryRecord("hello/hello2.txt", 48, false)); @Test |