From bfd7cf1fd3abe8eb2961567e22b261d3da6d7bb0 Mon Sep 17 00:00:00 2001 From: ghm Date: Tue, 24 Oct 2023 07:55:04 -0700 Subject: [PATCH] Add more Guava types to ModifiedButNotUsed. PiperOrigin-RevId: 576139694 --- .../bugpatterns/ModifiedButNotUsed.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/ModifiedButNotUsed.java b/core/src/main/java/com/google/errorprone/bugpatterns/ModifiedButNotUsed.java index 979dc093d368..0a9911ff109b 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/ModifiedButNotUsed.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/ModifiedButNotUsed.java @@ -81,11 +81,24 @@ public class ModifiedButNotUsed extends BugChecker implements ExpressionStatementTreeMatcher, VariableTreeMatcher { + // Note: we're only using the Builders of these, and there's a subtype relationship, so, for + // example, ImmutableSet.Builder (extends ImmutableCollection.Builder) doesn't need to be + // specified. private static final ImmutableSet GUAVA_IMMUTABLES = ImmutableSet.of( + // keep-sorted start + "com.google.common.collect.ImmutableClassToInstanceMap", "com.google.common.collect.ImmutableCollection", "com.google.common.collect.ImmutableMap", - "com.google.common.collect.ImmutableMultimap"); + "com.google.common.collect.ImmutableMultimap", + "com.google.common.collect.ImmutableMultiset", + "com.google.common.collect.ImmutableRangeMap", + "com.google.common.collect.ImmutableRangeSet", + "com.google.common.collect.ImmutableSortedMap", + "com.google.common.collect.ImmutableSortedSet", + "com.google.common.collect.ImmutableTable" + // keep-sorted end + ); private static final ImmutableSet COLLECTIONS = concat(