diff --git a/android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java b/android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java index 65b8b4f13e90..4891e9a29474 100644 --- a/android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java +++ b/android/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java @@ -148,11 +148,9 @@ public ListenableScheduledFuture schedule( return new ImmediateScheduledFuture<>(delegateFuture); } - private static class ImmediateScheduledFuture extends SimpleForwardingListenableFuture + private static final class ImmediateScheduledFuture extends SimpleForwardingListenableFuture implements ListenableScheduledFuture { - private ExecutionException exception; - - protected ImmediateScheduledFuture(ListenableFuture future) { + ImmediateScheduledFuture(ListenableFuture future) { super(future); } diff --git a/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java b/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java index 3bae972b32c4..eaed49fad35e 100644 --- a/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java +++ b/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java @@ -44,28 +44,28 @@ public class GcFinalizationTest extends TestCase { public void testAwait_CountDownLatch() { final CountDownLatch latch = new CountDownLatch(1); - Object x = + Object unused = new Object() { @Override protected void finalize() { latch.countDown(); } }; - x = null; // Hint to the JIT that x is unreachable + unused = null; // Hint to the JIT that unused is unreachable GcFinalization.await(latch); assertEquals(0, latch.getCount()); } public void testAwaitDone_Future() { final SettableFuture<@Nullable Void> future = SettableFuture.create(); - Object x = + Object unused = new Object() { @Override protected void finalize() { future.set(null); } }; - x = null; // Hint to the JIT that x is unreachable + unused = null; // Hint to the JIT that unused is unreachable GcFinalization.awaitDone(future); assertTrue(future.isDone()); assertFalse(future.isCancelled()); @@ -73,14 +73,14 @@ protected void finalize() { public void testAwaitDone_Future_Cancel() { final SettableFuture<@Nullable Void> future = SettableFuture.create(); - Object x = + Object unused = new Object() { @Override protected void finalize() { future.cancel(false); } }; - x = null; // Hint to the JIT that x is unreachable + unused = null; // Hint to the JIT that unused is unreachable GcFinalization.awaitDone(future); assertTrue(future.isDone()); assertTrue(future.isCancelled()); diff --git a/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java index 73a9da53a466..f5667d89b27d 100644 --- a/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java @@ -78,7 +78,6 @@ void setUp() { if (size == Size.SMALL) { BitSet tmp = new BitSet(); matcher.setBits(tmp); - int matchedCharCount = tmp.cardinality(); this.matcher = SmallCharMatcher.from(tmp, ""); } this.string = checkString(length, percent, config.matchingChars, new Random(), forceSlow, web); diff --git a/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java index 935951994eb4..5c3ced36e8bc 100644 --- a/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java @@ -45,20 +45,24 @@ void setUp() { } @Benchmark - void charSplitter(int reps) { + int charSplitter(int reps) { int total = 0; for (int i = 0; i < reps; i++) { total += Iterables.size(CHAR_SPLITTER.split(input)); } + + return total; } @Benchmark - void stringSplitter(int reps) { + int stringSplitter(int reps) { int total = 0; for (int i = 0; i < reps; i++) { total += Iterables.size(STRING_SPLITTER.split(input)); } + + return total; } } diff --git a/android/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java b/android/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java index f8700a4357f2..d2d2f2ec6e5c 100644 --- a/android/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java @@ -48,7 +48,7 @@ void setUp() { int sizeRemaining = size; // TODO(kevinb): generate better test contents for multisets - for (int i = 0; sizeRemaining > 0; i++) { + while (sizeRemaining > 0) { // The JVM will return interned values for small ints. Integer value = random.nextInt(1000) + 128; int count = Math.min(random.nextInt(10) + 1, sizeRemaining); diff --git a/android/guava-tests/test/com/google/common/base/FunctionsTest.java b/android/guava-tests/test/com/google/common/base/FunctionsTest.java index 952f73e1b281..6e70ea710b6a 100644 --- a/android/guava-tests/test/com/google/common/base/FunctionsTest.java +++ b/android/guava-tests/test/com/google/common/base/FunctionsTest.java @@ -280,7 +280,7 @@ public void testCompositionWildcard() { Function numberToSpanish = Functions.constant("Yo no se"); - Function japaneseToSpanish = + Function unusedJapaneseToSpanish = Functions.compose(numberToSpanish, japaneseToInteger); } diff --git a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java index d58c048bf6f6..acecc0ec4ae6 100644 --- a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java +++ b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java @@ -1959,7 +1959,7 @@ public void testRemoveEntry() { table.set(0, entry); segment.count = 1; assertTrue(segment.removeEntry(entry, hash, RemovalCause.COLLECTED)); - assertNotificationEnqueued(map, key, value, hash); + assertNotificationEnqueued(map, key, value); assertTrue(map.removalNotificationQueue.isEmpty()); assertFalse(segment.accessQueue.contains(entry)); assertFalse(segment.writeQueue.contains(entry)); @@ -2068,8 +2068,7 @@ public void testRemoveComputingValue() { assertTrue(segment.removeLoadingValue(key, hash, valueRef)); } - private static void assertNotificationEnqueued( - LocalCache map, K key, V value, int hash) { + private static void assertNotificationEnqueued(LocalCache map, K key, V value) { RemovalNotification notification = map.removalNotificationQueue.poll(); assertSame(key, notification.getKey()); assertSame(value, notification.getValue()); @@ -2595,7 +2594,7 @@ public void testNullParameters() throws Exception { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods(makeLocalCache(createCacheBuilder())); CacheLoader loader = identityLoader(); - tester.testAllPublicInstanceMethods(makeLocalCache(createCacheBuilder())); + tester.testAllPublicInstanceMethods(makeLocalCache(createCacheBuilder(), loader)); } public void testSerializationProxyLoading() { diff --git a/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java b/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java index 3a7f416ea63f..a6b92d162d38 100644 --- a/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java +++ b/android/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java @@ -124,7 +124,6 @@ public void testStats() { assertEquals(3.0 / 4, stats.missRate()); assertEquals(3, stats.loadCount()); assertTrue(stats.totalLoadTime() >= totalLoadTime); - totalLoadTime = stats.totalLoadTime(); assertTrue(stats.averageLoadPenalty() >= 0.0); assertEquals(1, stats.evictionCount()); } diff --git a/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java b/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java index 5518190a5f00..8ebeeb16a540 100644 --- a/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java +++ b/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java @@ -55,7 +55,7 @@ public class PopulatedCachesTest extends TestCase { public void testSize_populated() { for (LoadingCache cache : caches()) { // don't let the entries get GCed - List> warmed = warmUp(cache); + List> unused = warmUp(cache); assertEquals(WARMUP_SIZE, cache.size()); assertMapSize(cache.asMap(), WARMUP_SIZE); checkValidState(cache); @@ -125,7 +125,7 @@ public void testPutIfAbsent_populated() { public void testPutAll_populated() { for (LoadingCache cache : caches()) { // don't let the entries get GCed - List> warmed = warmUp(cache); + List> unused = warmUp(cache); Object newKey = new Object(); Object newValue = new Object(); cache.asMap().putAll(ImmutableMap.of(newKey, newValue)); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java index b98aac9a572b..ff16280a9d02 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java @@ -409,11 +409,7 @@ public void testExhaustive() { } if (anyOverlaps) { - assertThrows( - IllegalArgumentException.class, - () -> { - RangeSet copy = ImmutableRangeSet.copyOf(subset); - }); + assertThrows(IllegalArgumentException.class, () -> ImmutableRangeSet.copyOf(subset)); } else { RangeSet copy = ImmutableRangeSet.copyOf(subset); assertEquals(mutable, copy); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java index 28ba8ebce315..15ba3856ec49 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java @@ -826,20 +826,20 @@ public int compareTo(SelfComparableExample o) { } public void testBuilderGenerics_SelfComparable() { - ImmutableSortedMap.Builder natural = + ImmutableSortedMap.Builder unusedNatural = ImmutableSortedMap.naturalOrder(); - ImmutableSortedMap.Builder reverse = + ImmutableSortedMap.Builder unusedReverse = ImmutableSortedMap.reverseOrder(); } private static class SuperComparableExample extends SelfComparableExample {} public void testBuilderGenerics_SuperComparable() { - ImmutableSortedMap.Builder natural = + ImmutableSortedMap.Builder unusedNatural = ImmutableSortedMap.naturalOrder(); - ImmutableSortedMap.Builder reverse = + ImmutableSortedMap.Builder unusedReverse = ImmutableSortedMap.reverseOrder(); } } diff --git a/android/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java b/android/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java index 9248b4c22ae5..034b3e3d1ae0 100644 --- a/android/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java +++ b/android/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java @@ -43,19 +43,20 @@ public class MultimapBuilderTest extends TestCase { @J2ktIncompatible @GwtIncompatible // doesn't build without explicit type parameters on build() methods public void testGenerics() { - ListMultimap a = MultimapBuilder.hashKeys().arrayListValues().build(); - SortedSetMultimap b = MultimapBuilder.linkedHashKeys().treeSetValues().build(); - SetMultimap c = + ListMultimap unusedA = MultimapBuilder.hashKeys().arrayListValues().build(); + SortedSetMultimap unusedB = + MultimapBuilder.linkedHashKeys().treeSetValues().build(); + SetMultimap unusedC = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build(); } public void testGenerics_gwtCompatible() { - ListMultimap a = + ListMultimap unusedA = MultimapBuilder.hashKeys().arrayListValues().build(); - SortedSetMultimap b = + SortedSetMultimap unusedB = rawtypeToWildcard(MultimapBuilder.linkedHashKeys().treeSetValues()) .build(); - SetMultimap c = + SetMultimap unusedC = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) .hashSetValues() .build(); diff --git a/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java b/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java index 6e7b530e3aa0..7a1ef2fa94d6 100644 --- a/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java +++ b/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java @@ -30,7 +30,6 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.base.Ascii; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.Maps.EntryTransformer; @@ -215,22 +214,6 @@ public List> create(Object... elements) { } } - private static final Predicate> FILTER_GET_PREDICATE = - new Predicate>() { - @Override - public boolean apply(Entry entry) { - return !"badvalue".equals(entry.getValue()) && 55556 != entry.getKey(); - } - }; - - private static final Predicate> FILTER_KEYSET_PREDICATE = - new Predicate>() { - @Override - public boolean apply(Entry entry) { - return !"badkey".equals(entry.getKey()) && 55556 != entry.getValue(); - } - }; - public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/OrderingTest.java b/android/guava-tests/test/com/google/common/collect/OrderingTest.java index 3a50b54e648f..c4d0f316500c 100644 --- a/android/guava-tests/test/com/google/common/collect/OrderingTest.java +++ b/android/guava-tests/test/com/google/common/collect/OrderingTest.java @@ -326,37 +326,37 @@ public void testCompound_instance_generics() { Ordering integers = Ordering.explicit(1); // Like by like equals like - Ordering a = numbers.compound(numbers); + Ordering unusedA = numbers.compound(numbers); // The compound takes the more specific type of the two, regardless of order - Ordering b = numbers.compound(objects); - Ordering c = objects.compound(numbers); + Ordering unusedB = numbers.compound(objects); + Ordering unusedC = objects.compound(numbers); - Ordering d = numbers.compound(integers); - Ordering e = integers.compound(numbers); + Ordering unusedD = numbers.compound(integers); + Ordering unusedE = integers.compound(numbers); // This works with three levels too (IDEA falsely reports errors as noted // below. Both javac and eclipse handle these cases correctly.) - Ordering f = numbers.compound(objects).compound(objects); // bad IDEA - Ordering g = objects.compound(numbers).compound(objects); - Ordering h = objects.compound(objects).compound(numbers); + Ordering unusedF = numbers.compound(objects).compound(objects); // bad IDEA + Ordering unusedG = objects.compound(numbers).compound(objects); + Ordering unusedH = objects.compound(objects).compound(numbers); - Ordering i = numbers.compound(objects.compound(objects)); - Ordering j = objects.compound(numbers.compound(objects)); // bad IDEA - Ordering k = objects.compound(objects.compound(numbers)); + Ordering unusedI = numbers.compound(objects.compound(objects)); + Ordering unusedJ = objects.compound(numbers.compound(objects)); // bad IDEA + Ordering unusedK = objects.compound(objects.compound(numbers)); // You can also arbitrarily assign a more restricted type - not an intended // feature, exactly, but unavoidable (I think) and harmless - Ordering l = objects.compound(numbers); + Ordering unusedL = objects.compound(numbers); // This correctly doesn't work: - // Ordering m = numbers.compound(objects); + // Ordering unusedM = numbers.compound(objects); // Sadly, the following works in javac 1.6, but at least it fails for // eclipse, and is *correctly* highlighted red in IDEA. - // Ordering n = objects.compound(numbers); + // Ordering unusedN = objects.compound(numbers); } public void testReverse() { diff --git a/android/guava-tests/test/com/google/common/collect/RangeTest.java b/android/guava-tests/test/com/google/common/collect/RangeTest.java index cfc191716ad7..7ea3b0bed73e 100644 --- a/android/guava-tests/test/com/google/common/collect/RangeTest.java +++ b/android/guava-tests/test/com/google/common/collect/RangeTest.java @@ -613,7 +613,7 @@ public void testEquals() { @GwtIncompatible // TODO(b/148207871): Restore once Eclipse compiler no longer flakes for this. public void testLegacyComparable() { - Range range = Range.closed(LegacyComparable.X, LegacyComparable.Y); + Range unused = Range.closed(LegacyComparable.X, LegacyComparable.Y); } private static final DiscreteDomain UNBOUNDED_DOMAIN = diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java index c5637038dafb..b96986111339 100644 --- a/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java @@ -79,7 +79,6 @@ protected BiMap create() { public static final class SynchronizedHashBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { - Object mutex = new Object(); BiMap result = HashBiMap.create(); for (Entry entry : entries) { checkArgument(!result.containsKey(entry.getKey())); diff --git a/android/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java b/android/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java index 539e1360788d..bb7de099b4bb 100644 --- a/android/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java +++ b/android/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java @@ -41,7 +41,7 @@ private static class DummySubscriber { private final EventBus eventBus = new EventBus(); @Subscribe - public void handle(@Nullable Object anything) {} + public void handle(@Nullable Object unused) {} Subscriber toSubscriber() throws Exception { return Subscriber.create(eventBus, this, subscriberMethod()); diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java index b1a69de2fb00..0079c1c46008 100644 --- a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java +++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java @@ -36,8 +36,7 @@ public void nodes_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set nodes = graph.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); } @@ -49,8 +48,7 @@ public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = graph.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); putEdge(N1, N2); assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -62,8 +60,7 @@ public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = graph.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); putEdge(N1, N2); assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -75,8 +72,7 @@ public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = graph.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); putEdge(N1, N2); assertThat(successors).containsExactlyElementsIn(graph.successors(N1)); } @@ -88,10 +84,8 @@ public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set> incidentEdges = graph.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows( - UnsupportedOperationException.class, - () -> incidentEdges.add(EndpointPair.ordered(N1, N2))); + assertThrows( + UnsupportedOperationException.class, () -> incidentEdges.add(EndpointPair.ordered(N1, N2))); putEdge(N1, N2); assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1)); } diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java index 1e6d22863b14..40f9a3a6948e 100644 --- a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java +++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java @@ -65,8 +65,7 @@ public void nodes_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set nodes = network.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(network.nodes()).containsExactlyElementsIn(nodes); } @@ -77,8 +76,7 @@ public void edges_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set edges = network.edges(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); addEdge(N1, N2, E12); assertThat(network.edges()).containsExactlyElementsIn(edges); } @@ -90,8 +88,7 @@ public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set incidentEdges = network.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges); } @@ -103,8 +100,7 @@ public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = network.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); addEdge(N1, N2, E12); assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -132,8 +128,7 @@ public void edgesConnecting_checkReturnedSetMutability() { addNode(N1); addNode(N2); Set edgesConnecting = network.edgesConnecting(N1, N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); + assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); addEdge(N1, N2, E12); assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting); } @@ -145,8 +140,7 @@ public void inEdges_checkReturnedSetMutability() { addNode(N2); Set inEdges = network.inEdges(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges); } @@ -158,8 +152,7 @@ public void outEdges_checkReturnedSetMutability() { addNode(N1); Set outEdges = network.outEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges); } @@ -171,8 +164,7 @@ public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = network.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); addEdge(N1, N2, E12); assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -184,8 +176,7 @@ public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = network.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); addEdge(N1, N2, E12); assertThat(successors).containsExactlyElementsIn(network.successors(N1)); } diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java index 0acc786a43d7..521bc72bd13f 100644 --- a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java +++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java @@ -47,8 +47,7 @@ public void nodes_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set nodes = graph.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); } @@ -60,8 +59,7 @@ public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = graph.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); putEdge(N1, N2); assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -73,8 +71,7 @@ public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = graph.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); putEdge(N1, N2); assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -86,8 +83,7 @@ public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = graph.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); putEdge(N1, N2); assertThat(graph.successors(N1)).containsExactlyElementsIn(successors); } @@ -99,10 +95,9 @@ public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set> incidentEdges = graph.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows( - UnsupportedOperationException.class, - () -> incidentEdges.add(EndpointPair.unordered(N1, N2))); + assertThrows( + UnsupportedOperationException.class, + () -> incidentEdges.add(EndpointPair.unordered(N1, N2))); putEdge(N1, N2); assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1)); } diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java index 52f65577a966..286956472bc9 100644 --- a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java +++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java @@ -60,8 +60,7 @@ public void validateUndirectedEdges() { @Test public void nodes_checkReturnedSetMutability() { Set nodes = network.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(network.nodes()).containsExactlyElementsIn(nodes); } @@ -70,8 +69,7 @@ public void nodes_checkReturnedSetMutability() { @Test public void edges_checkReturnedSetMutability() { Set edges = network.edges(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); addEdge(N1, N2, E12); assertThat(network.edges()).containsExactlyElementsIn(edges); } @@ -81,8 +79,7 @@ public void edges_checkReturnedSetMutability() { public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set incidentEdges = network.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges); } @@ -92,8 +89,7 @@ public void incidentEdges_checkReturnedSetMutability() { public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = network.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); addEdge(N1, N2, E12); assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -117,8 +113,7 @@ public void edgesConnecting_checkReturnedSetMutability() { addNode(N1); addNode(N2); Set edgesConnecting = network.edgesConnecting(N1, N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); + assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); addEdge(N1, N2, E12); assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting); } @@ -128,8 +123,7 @@ public void edgesConnecting_checkReturnedSetMutability() { public void inEdges_checkReturnedSetMutability() { addNode(N2); Set inEdges = network.inEdges(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges); } @@ -139,8 +133,7 @@ public void inEdges_checkReturnedSetMutability() { public void outEdges_checkReturnedSetMutability() { addNode(N1); Set outEdges = network.outEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges); } @@ -150,8 +143,7 @@ public void outEdges_checkReturnedSetMutability() { public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = network.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); addEdge(N1, N2, E12); assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -161,8 +153,7 @@ public void predecessors_checkReturnedSetMutability() { public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = network.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); addEdge(N1, N2, E12); assertThat(network.successors(N1)).containsExactlyElementsIn(successors); } diff --git a/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java b/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java index b773a36e6315..4f3cd6f9d56b 100644 --- a/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java +++ b/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java @@ -109,8 +109,7 @@ public void edgesConnecting_checkReturnedSetMutability() { network.addNode(N1); network.addNode(N2); Set edgesConnecting = network.edgesConnecting(N1, N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); + assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); network.addEdge(N1, N2, E12); assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting); } diff --git a/android/guava-tests/test/com/google/common/graph/GraphsTest.java b/android/guava-tests/test/com/google/common/graph/GraphsTest.java index b31121da4d4b..36ee07cb1f84 100644 --- a/android/guava-tests/test/com/google/common/graph/GraphsTest.java +++ b/android/guava-tests/test/com/google/common/graph/GraphsTest.java @@ -56,10 +56,6 @@ public class GraphsTest { // in one class (may be a utility class for error messages). private static final String ERROR_PARALLEL_EDGE = "connected by a different edge"; private static final String ERROR_NEGATIVE_COUNT = "is non-negative"; - private static final String ERROR_ADDED_PARALLEL_EDGE = - "Should not be allowed to add a parallel edge."; - private static final String ERROR_ADDED_SELF_LOOP = - "Should not be allowed to add a self-loop edge."; static final String ERROR_SELF_LOOP = "self-loops are not allowed"; @Test diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java index b3c606986484..556653b14b3b 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java @@ -616,9 +616,8 @@ public void testCustomSchedulerFailure() throws Exception { service.secondBarrier.await(); } Thread.sleep(1000); - IllegalStateException e = - assertThrows( - IllegalStateException.class, () -> service.stopAsync().awaitTerminated(100, SECONDS)); + assertThrows( + IllegalStateException.class, () -> service.stopAsync().awaitTerminated(100, SECONDS)); assertEquals(State.FAILED, service.state()); } diff --git a/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java b/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java index 65b8b4f13e90..4891e9a29474 100644 --- a/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java +++ b/guava-testlib/src/com/google/common/util/concurrent/testing/SameThreadScheduledExecutorService.java @@ -148,11 +148,9 @@ public ListenableScheduledFuture schedule( return new ImmediateScheduledFuture<>(delegateFuture); } - private static class ImmediateScheduledFuture extends SimpleForwardingListenableFuture + private static final class ImmediateScheduledFuture extends SimpleForwardingListenableFuture implements ListenableScheduledFuture { - private ExecutionException exception; - - protected ImmediateScheduledFuture(ListenableFuture future) { + ImmediateScheduledFuture(ListenableFuture future) { super(future); } diff --git a/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java b/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java index 3bae972b32c4..eaed49fad35e 100644 --- a/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java +++ b/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java @@ -44,28 +44,28 @@ public class GcFinalizationTest extends TestCase { public void testAwait_CountDownLatch() { final CountDownLatch latch = new CountDownLatch(1); - Object x = + Object unused = new Object() { @Override protected void finalize() { latch.countDown(); } }; - x = null; // Hint to the JIT that x is unreachable + unused = null; // Hint to the JIT that unused is unreachable GcFinalization.await(latch); assertEquals(0, latch.getCount()); } public void testAwaitDone_Future() { final SettableFuture<@Nullable Void> future = SettableFuture.create(); - Object x = + Object unused = new Object() { @Override protected void finalize() { future.set(null); } }; - x = null; // Hint to the JIT that x is unreachable + unused = null; // Hint to the JIT that unused is unreachable GcFinalization.awaitDone(future); assertTrue(future.isDone()); assertFalse(future.isCancelled()); @@ -73,14 +73,14 @@ protected void finalize() { public void testAwaitDone_Future_Cancel() { final SettableFuture<@Nullable Void> future = SettableFuture.create(); - Object x = + Object unused = new Object() { @Override protected void finalize() { future.cancel(false); } }; - x = null; // Hint to the JIT that x is unreachable + unused = null; // Hint to the JIT that unused is unreachable GcFinalization.awaitDone(future); assertTrue(future.isDone()); assertTrue(future.isCancelled()); diff --git a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java index 548baf6fbcf9..0bdb35b1df49 100644 --- a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java +++ b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java @@ -187,19 +187,19 @@ public static void christenPoodle(String name) { } private static class ThrowsUoe { - public static void christenPoodle(String name) { + public static void christenPoodle(String unused) { throw new UnsupportedOperationException(); } } private static class ThrowsSomethingElse { - public static void christenPoodle(String name) { + public static void christenPoodle(String unused) { throw new RuntimeException(); } } private interface InterfaceStaticMethodFailsToCheckNull { - static String create(String s) { + static String create(String unused) { return "I don't check"; } } @@ -215,7 +215,7 @@ static InterfaceDefaultMethodFailsToCheckNull create() { return new InterfaceDefaultMethodFailsToCheckNull() {}; } - default void doNotCheckNull(String s) {} + default void doNotCheckNull(String unused) {} } private interface InterfaceDefaultMethodChecksNull { @@ -852,7 +852,7 @@ public void testSubclassThatFailsToThrowForStatic() { private static class SubclassThatTriesToOverrideBadStaticMethod extends ClassThatFailsToThrowForStatic { - static void staticOneArg(@Nullable String s) {} + static void staticOneArg(String unused) {} } public void testSubclassThatTriesToOverrideBadStaticMethod() { @@ -860,7 +860,7 @@ public void testSubclassThatTriesToOverrideBadStaticMethod() { } private static final class HardToCreate { - private HardToCreate(HardToCreate x) {} + private HardToCreate(String unused) {} } @SuppressWarnings("unused") // used by reflection diff --git a/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java b/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java index 73a9da53a466..f5667d89b27d 100644 --- a/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java +++ b/guava-tests/benchmark/com/google/common/base/CharMatcherBenchmark.java @@ -78,7 +78,6 @@ void setUp() { if (size == Size.SMALL) { BitSet tmp = new BitSet(); matcher.setBits(tmp); - int matchedCharCount = tmp.cardinality(); this.matcher = SmallCharMatcher.from(tmp, ""); } this.string = checkString(length, percent, config.matchingChars, new Random(), forceSlow, web); diff --git a/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java b/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java index 935951994eb4..5c3ced36e8bc 100644 --- a/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java +++ b/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java @@ -45,20 +45,24 @@ void setUp() { } @Benchmark - void charSplitter(int reps) { + int charSplitter(int reps) { int total = 0; for (int i = 0; i < reps; i++) { total += Iterables.size(CHAR_SPLITTER.split(input)); } + + return total; } @Benchmark - void stringSplitter(int reps) { + int stringSplitter(int reps) { int total = 0; for (int i = 0; i < reps; i++) { total += Iterables.size(STRING_SPLITTER.split(input)); } + + return total; } } diff --git a/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java b/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java index f8700a4357f2..d2d2f2ec6e5c 100644 --- a/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java +++ b/guava-tests/benchmark/com/google/common/collect/MultisetIteratorBenchmark.java @@ -48,7 +48,7 @@ void setUp() { int sizeRemaining = size; // TODO(kevinb): generate better test contents for multisets - for (int i = 0; sizeRemaining > 0; i++) { + while (sizeRemaining > 0) { // The JVM will return interned values for small ints. Integer value = random.nextInt(1000) + 128; int count = Math.min(random.nextInt(10) + 1, sizeRemaining); diff --git a/guava-tests/test/com/google/common/base/FunctionsTest.java b/guava-tests/test/com/google/common/base/FunctionsTest.java index 952f73e1b281..6e70ea710b6a 100644 --- a/guava-tests/test/com/google/common/base/FunctionsTest.java +++ b/guava-tests/test/com/google/common/base/FunctionsTest.java @@ -280,7 +280,7 @@ public void testCompositionWildcard() { Function numberToSpanish = Functions.constant("Yo no se"); - Function japaneseToSpanish = + Function unusedJapaneseToSpanish = Functions.compose(numberToSpanish, japaneseToInteger); } diff --git a/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/guava-tests/test/com/google/common/cache/LocalCacheTest.java index b0ca5d38eac2..f0c3f08202e5 100644 --- a/guava-tests/test/com/google/common/cache/LocalCacheTest.java +++ b/guava-tests/test/com/google/common/cache/LocalCacheTest.java @@ -2011,7 +2011,7 @@ public void testRemoveEntry() { table.set(0, entry); segment.count = 1; assertTrue(segment.removeEntry(entry, hash, RemovalCause.COLLECTED)); - assertNotificationEnqueued(map, key, value, hash); + assertNotificationEnqueued(map, key, value); assertTrue(map.removalNotificationQueue.isEmpty()); assertFalse(segment.accessQueue.contains(entry)); assertFalse(segment.writeQueue.contains(entry)); @@ -2120,8 +2120,7 @@ public void testRemoveComputingValue() { assertTrue(segment.removeLoadingValue(key, hash, valueRef)); } - private static void assertNotificationEnqueued( - LocalCache map, K key, V value, int hash) { + private static void assertNotificationEnqueued(LocalCache map, K key, V value) { RemovalNotification notification = map.removalNotificationQueue.poll(); assertSame(key, notification.getKey()); assertSame(value, notification.getValue()); @@ -2647,7 +2646,7 @@ public void testNullParameters() throws Exception { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods(makeLocalCache(createCacheBuilder())); CacheLoader loader = identityLoader(); - tester.testAllPublicInstanceMethods(makeLocalCache(createCacheBuilder())); + tester.testAllPublicInstanceMethods(makeLocalCache(createCacheBuilder(), loader)); } public void testSerializationProxyLoading() { diff --git a/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java b/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java index 3a7f416ea63f..a6b92d162d38 100644 --- a/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java +++ b/guava-tests/test/com/google/common/cache/LocalLoadingCacheTest.java @@ -124,7 +124,6 @@ public void testStats() { assertEquals(3.0 / 4, stats.missRate()); assertEquals(3, stats.loadCount()); assertTrue(stats.totalLoadTime() >= totalLoadTime); - totalLoadTime = stats.totalLoadTime(); assertTrue(stats.averageLoadPenalty() >= 0.0); assertEquals(1, stats.evictionCount()); } diff --git a/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java b/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java index 5518190a5f00..8ebeeb16a540 100644 --- a/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java +++ b/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java @@ -55,7 +55,7 @@ public class PopulatedCachesTest extends TestCase { public void testSize_populated() { for (LoadingCache cache : caches()) { // don't let the entries get GCed - List> warmed = warmUp(cache); + List> unused = warmUp(cache); assertEquals(WARMUP_SIZE, cache.size()); assertMapSize(cache.asMap(), WARMUP_SIZE); checkValidState(cache); @@ -125,7 +125,7 @@ public void testPutIfAbsent_populated() { public void testPutAll_populated() { for (LoadingCache cache : caches()) { // don't let the entries get GCed - List> warmed = warmUp(cache); + List> unused = warmUp(cache); Object newKey = new Object(); Object newValue = new Object(); cache.asMap().putAll(ImmutableMap.of(newKey, newValue)); diff --git a/guava-tests/test/com/google/common/collect/ComparatorsTest.java b/guava-tests/test/com/google/common/collect/ComparatorsTest.java index ccf091062a7e..8048c8e05edf 100644 --- a/guava-tests/test/com/google/common/collect/ComparatorsTest.java +++ b/guava-tests/test/com/google/common/collect/ComparatorsTest.java @@ -86,7 +86,7 @@ public void testEmptiesFirst() { Helpers.testComparator(comparator, empty, z, abc); // Just demonstrate that no explicit type parameter is required - comparator = Comparators.emptiesFirst(naturalOrder()); + Comparator> unused = Comparators.emptiesFirst(naturalOrder()); } public void testEmptiesLast() { @@ -98,7 +98,7 @@ public void testEmptiesLast() { Helpers.testComparator(comparator, z, abc, empty); // Just demonstrate that no explicit type parameter is required - comparator = Comparators.emptiesLast(naturalOrder()); + Comparator> unused = Comparators.emptiesLast(naturalOrder()); } public void testMinMaxNatural() { diff --git a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java index 22ea11f23248..6e538d271e47 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java @@ -410,11 +410,7 @@ public void testExhaustive() { } if (anyOverlaps) { - assertThrows( - IllegalArgumentException.class, - () -> { - RangeSet copy = ImmutableRangeSet.copyOf(subset); - }); + assertThrows(IllegalArgumentException.class, () -> ImmutableRangeSet.copyOf(subset)); } else { RangeSet copy = ImmutableRangeSet.copyOf(subset); assertEquals(mutable, copy); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java index 32d6b128baea..f7cc30a968bf 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java @@ -852,20 +852,20 @@ public int compareTo(SelfComparableExample o) { } public void testBuilderGenerics_SelfComparable() { - ImmutableSortedMap.Builder natural = + ImmutableSortedMap.Builder unusedNatural = ImmutableSortedMap.naturalOrder(); - ImmutableSortedMap.Builder reverse = + ImmutableSortedMap.Builder unusedReverse = ImmutableSortedMap.reverseOrder(); } private static class SuperComparableExample extends SelfComparableExample {} public void testBuilderGenerics_SuperComparable() { - ImmutableSortedMap.Builder natural = + ImmutableSortedMap.Builder unusedNatural = ImmutableSortedMap.naturalOrder(); - ImmutableSortedMap.Builder reverse = + ImmutableSortedMap.Builder unusedReverse = ImmutableSortedMap.reverseOrder(); } } diff --git a/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java b/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java index 9248b4c22ae5..034b3e3d1ae0 100644 --- a/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java +++ b/guava-tests/test/com/google/common/collect/MultimapBuilderTest.java @@ -43,19 +43,20 @@ public class MultimapBuilderTest extends TestCase { @J2ktIncompatible @GwtIncompatible // doesn't build without explicit type parameters on build() methods public void testGenerics() { - ListMultimap a = MultimapBuilder.hashKeys().arrayListValues().build(); - SortedSetMultimap b = MultimapBuilder.linkedHashKeys().treeSetValues().build(); - SetMultimap c = + ListMultimap unusedA = MultimapBuilder.hashKeys().arrayListValues().build(); + SortedSetMultimap unusedB = + MultimapBuilder.linkedHashKeys().treeSetValues().build(); + SetMultimap unusedC = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build(); } public void testGenerics_gwtCompatible() { - ListMultimap a = + ListMultimap unusedA = MultimapBuilder.hashKeys().arrayListValues().build(); - SortedSetMultimap b = + SortedSetMultimap unusedB = rawtypeToWildcard(MultimapBuilder.linkedHashKeys().treeSetValues()) .build(); - SetMultimap c = + SetMultimap unusedC = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) .hashSetValues() .build(); diff --git a/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java b/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java index 6b72be802ca8..d969c6aa89ed 100644 --- a/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java @@ -31,7 +31,6 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.base.Ascii; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.Maps.EntryTransformer; @@ -216,22 +215,6 @@ public List> create(Object... elements) { } } - private static final Predicate> FILTER_GET_PREDICATE = - new Predicate>() { - @Override - public boolean apply(Entry entry) { - return !"badvalue".equals(entry.getValue()) && 55556 != entry.getKey(); - } - }; - - private static final Predicate> FILTER_KEYSET_PREDICATE = - new Predicate>() { - @Override - public boolean apply(Entry entry) { - return !"badkey".equals(entry.getKey()) && 55556 != entry.getValue(); - } - }; - public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/OrderingTest.java b/guava-tests/test/com/google/common/collect/OrderingTest.java index 3a50b54e648f..c4d0f316500c 100644 --- a/guava-tests/test/com/google/common/collect/OrderingTest.java +++ b/guava-tests/test/com/google/common/collect/OrderingTest.java @@ -326,37 +326,37 @@ public void testCompound_instance_generics() { Ordering integers = Ordering.explicit(1); // Like by like equals like - Ordering a = numbers.compound(numbers); + Ordering unusedA = numbers.compound(numbers); // The compound takes the more specific type of the two, regardless of order - Ordering b = numbers.compound(objects); - Ordering c = objects.compound(numbers); + Ordering unusedB = numbers.compound(objects); + Ordering unusedC = objects.compound(numbers); - Ordering d = numbers.compound(integers); - Ordering e = integers.compound(numbers); + Ordering unusedD = numbers.compound(integers); + Ordering unusedE = integers.compound(numbers); // This works with three levels too (IDEA falsely reports errors as noted // below. Both javac and eclipse handle these cases correctly.) - Ordering f = numbers.compound(objects).compound(objects); // bad IDEA - Ordering g = objects.compound(numbers).compound(objects); - Ordering h = objects.compound(objects).compound(numbers); + Ordering unusedF = numbers.compound(objects).compound(objects); // bad IDEA + Ordering unusedG = objects.compound(numbers).compound(objects); + Ordering unusedH = objects.compound(objects).compound(numbers); - Ordering i = numbers.compound(objects.compound(objects)); - Ordering j = objects.compound(numbers.compound(objects)); // bad IDEA - Ordering k = objects.compound(objects.compound(numbers)); + Ordering unusedI = numbers.compound(objects.compound(objects)); + Ordering unusedJ = objects.compound(numbers.compound(objects)); // bad IDEA + Ordering unusedK = objects.compound(objects.compound(numbers)); // You can also arbitrarily assign a more restricted type - not an intended // feature, exactly, but unavoidable (I think) and harmless - Ordering l = objects.compound(numbers); + Ordering unusedL = objects.compound(numbers); // This correctly doesn't work: - // Ordering m = numbers.compound(objects); + // Ordering unusedM = numbers.compound(objects); // Sadly, the following works in javac 1.6, but at least it fails for // eclipse, and is *correctly* highlighted red in IDEA. - // Ordering n = objects.compound(numbers); + // Ordering unusedN = objects.compound(numbers); } public void testReverse() { diff --git a/guava-tests/test/com/google/common/collect/RangeTest.java b/guava-tests/test/com/google/common/collect/RangeTest.java index cfc191716ad7..7ea3b0bed73e 100644 --- a/guava-tests/test/com/google/common/collect/RangeTest.java +++ b/guava-tests/test/com/google/common/collect/RangeTest.java @@ -613,7 +613,7 @@ public void testEquals() { @GwtIncompatible // TODO(b/148207871): Restore once Eclipse compiler no longer flakes for this. public void testLegacyComparable() { - Range range = Range.closed(LegacyComparable.X, LegacyComparable.Y); + Range unused = Range.closed(LegacyComparable.X, LegacyComparable.Y); } private static final DiscreteDomain UNBOUNDED_DOMAIN = diff --git a/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java b/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java index d0cc8132a8cb..7b67382fa348 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java @@ -80,7 +80,6 @@ protected BiMap create() { public static final class SynchronizedHashBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { - Object mutex = new Object(); BiMap result = HashBiMap.create(); for (Entry entry : entries) { checkArgument(!result.containsKey(entry.getKey())); diff --git a/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java b/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java index 539e1360788d..bb7de099b4bb 100644 --- a/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java +++ b/guava-tests/test/com/google/common/eventbus/PackageSanityTests.java @@ -41,7 +41,7 @@ private static class DummySubscriber { private final EventBus eventBus = new EventBus(); @Subscribe - public void handle(@Nullable Object anything) {} + public void handle(@Nullable Object unused) {} Subscriber toSubscriber() throws Exception { return Subscriber.create(eventBus, this, subscriberMethod()); diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java index b1a69de2fb00..0079c1c46008 100644 --- a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java +++ b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java @@ -36,8 +36,7 @@ public void nodes_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set nodes = graph.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); } @@ -49,8 +48,7 @@ public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = graph.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); putEdge(N1, N2); assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -62,8 +60,7 @@ public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = graph.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); putEdge(N1, N2); assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -75,8 +72,7 @@ public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = graph.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); putEdge(N1, N2); assertThat(successors).containsExactlyElementsIn(graph.successors(N1)); } @@ -88,10 +84,8 @@ public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set> incidentEdges = graph.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows( - UnsupportedOperationException.class, - () -> incidentEdges.add(EndpointPair.ordered(N1, N2))); + assertThrows( + UnsupportedOperationException.class, () -> incidentEdges.add(EndpointPair.ordered(N1, N2))); putEdge(N1, N2); assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1)); } diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java index bb90a681357b..107aa3e57b3a 100644 --- a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java +++ b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java @@ -66,8 +66,7 @@ public void nodes_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set nodes = network.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(network.nodes()).containsExactlyElementsIn(nodes); } @@ -78,8 +77,7 @@ public void edges_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set edges = network.edges(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); addEdge(N1, N2, E12); assertThat(network.edges()).containsExactlyElementsIn(edges); } @@ -91,8 +89,7 @@ public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set incidentEdges = network.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges); } @@ -104,8 +101,7 @@ public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = network.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); addEdge(N1, N2, E12); assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -133,8 +129,7 @@ public void edgesConnecting_checkReturnedSetMutability() { addNode(N1); addNode(N2); Set edgesConnecting = network.edgesConnecting(N1, N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); + assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); addEdge(N1, N2, E12); assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting); } @@ -146,8 +141,7 @@ public void inEdges_checkReturnedSetMutability() { addNode(N2); Set inEdges = network.inEdges(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges); } @@ -159,8 +153,7 @@ public void outEdges_checkReturnedSetMutability() { addNode(N1); Set outEdges = network.outEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges); } @@ -172,8 +165,7 @@ public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = network.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); addEdge(N1, N2, E12); assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -185,8 +177,7 @@ public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = network.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); addEdge(N1, N2, E12); assertThat(successors).containsExactlyElementsIn(network.successors(N1)); } diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java index 0acc786a43d7..521bc72bd13f 100644 --- a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java +++ b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java @@ -47,8 +47,7 @@ public void nodes_checkReturnedSetMutability() { assume().that(graphIsMutable()).isTrue(); Set nodes = graph.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); } @@ -60,8 +59,7 @@ public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = graph.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); putEdge(N1, N2); assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -73,8 +71,7 @@ public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = graph.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); putEdge(N1, N2); assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -86,8 +83,7 @@ public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = graph.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); putEdge(N1, N2); assertThat(graph.successors(N1)).containsExactlyElementsIn(successors); } @@ -99,10 +95,9 @@ public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set> incidentEdges = graph.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows( - UnsupportedOperationException.class, - () -> incidentEdges.add(EndpointPair.unordered(N1, N2))); + assertThrows( + UnsupportedOperationException.class, + () -> incidentEdges.add(EndpointPair.unordered(N1, N2))); putEdge(N1, N2); assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1)); } diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java index 6bc1d00b6bb6..ab220ca621bb 100644 --- a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java +++ b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java @@ -61,8 +61,7 @@ public void validateUndirectedEdges() { @Test public void nodes_checkReturnedSetMutability() { Set nodes = network.nodes(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2)); addNode(N1); assertThat(network.nodes()).containsExactlyElementsIn(nodes); } @@ -71,8 +70,7 @@ public void nodes_checkReturnedSetMutability() { @Test public void edges_checkReturnedSetMutability() { Set edges = network.edges(); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> edges.add(E12)); addEdge(N1, N2, E12); assertThat(network.edges()).containsExactlyElementsIn(edges); } @@ -82,8 +80,7 @@ public void edges_checkReturnedSetMutability() { public void incidentEdges_checkReturnedSetMutability() { addNode(N1); Set incidentEdges = network.incidentEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges); } @@ -93,8 +90,7 @@ public void incidentEdges_checkReturnedSetMutability() { public void adjacentNodes_checkReturnedSetMutability() { addNode(N1); Set adjacentNodes = network.adjacentNodes(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2)); addEdge(N1, N2, E12); assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes); } @@ -118,8 +114,7 @@ public void edgesConnecting_checkReturnedSetMutability() { addNode(N1); addNode(N2); Set edgesConnecting = network.edgesConnecting(N1, N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); + assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); addEdge(N1, N2, E12); assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting); } @@ -129,8 +124,7 @@ public void edgesConnecting_checkReturnedSetMutability() { public void inEdges_checkReturnedSetMutability() { addNode(N2); Set inEdges = network.inEdges(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges); } @@ -140,8 +134,7 @@ public void inEdges_checkReturnedSetMutability() { public void outEdges_checkReturnedSetMutability() { addNode(N1); Set outEdges = network.outEdges(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); + assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12)); addEdge(N1, N2, E12); assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges); } @@ -151,8 +144,7 @@ public void outEdges_checkReturnedSetMutability() { public void predecessors_checkReturnedSetMutability() { addNode(N2); Set predecessors = network.predecessors(N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); + assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1)); addEdge(N1, N2, E12); assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors); } @@ -162,8 +154,7 @@ public void predecessors_checkReturnedSetMutability() { public void successors_checkReturnedSetMutability() { addNode(N1); Set successors = network.successors(N1); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); + assertThrows(UnsupportedOperationException.class, () -> successors.add(N2)); addEdge(N1, N2, E12); assertThat(network.successors(N1)).containsExactlyElementsIn(successors); } diff --git a/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java b/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java index b773a36e6315..4f3cd6f9d56b 100644 --- a/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java +++ b/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java @@ -109,8 +109,7 @@ public void edgesConnecting_checkReturnedSetMutability() { network.addNode(N1); network.addNode(N2); Set edgesConnecting = network.edgesConnecting(N1, N2); - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); + assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23)); network.addEdge(N1, N2, E12); assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting); } diff --git a/guava-tests/test/com/google/common/graph/GraphsTest.java b/guava-tests/test/com/google/common/graph/GraphsTest.java index 6a41b1ad7997..53a14d548d8a 100644 --- a/guava-tests/test/com/google/common/graph/GraphsTest.java +++ b/guava-tests/test/com/google/common/graph/GraphsTest.java @@ -56,10 +56,6 @@ public class GraphsTest { // in one class (may be a utility class for error messages). private static final String ERROR_PARALLEL_EDGE = "connected by a different edge"; private static final String ERROR_NEGATIVE_COUNT = "is non-negative"; - private static final String ERROR_ADDED_PARALLEL_EDGE = - "Should not be allowed to add a parallel edge."; - private static final String ERROR_ADDED_SELF_LOOP = - "Should not be allowed to add a self-loop edge."; static final String ERROR_SELF_LOOP = "self-loops are not allowed"; @Test diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java index b3c606986484..556653b14b3b 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java @@ -616,9 +616,8 @@ public void testCustomSchedulerFailure() throws Exception { service.secondBarrier.await(); } Thread.sleep(1000); - IllegalStateException e = - assertThrows( - IllegalStateException.class, () -> service.stopAsync().awaitTerminated(100, SECONDS)); + assertThrows( + IllegalStateException.class, () -> service.stopAsync().awaitTerminated(100, SECONDS)); assertEquals(State.FAILED, service.state()); }