The following issues were found
guava-tests/test/com/google/common/graph/NetworkMutationTest.java
45 issues
Line: 40
private static final int NODE_POOL_SIZE = 1000; // must be >> NUM_NODES
@Test
public void directedNetwork() {
testNetworkMutation(NetworkBuilder.directed());
}
@Test
public void undirectedNetwork() {
Reported by PMD.
Line: 45
}
@Test
public void undirectedNetwork() {
testNetworkMutation(NetworkBuilder.undirected());
}
private static void testNetworkMutation(NetworkBuilder<? super Integer, Object> networkBuilder) {
Random gen = new Random(42); // Fixed seed so test results are deterministic.
Reported by PMD.
Line: 49
testNetworkMutation(NetworkBuilder.undirected());
}
private static void testNetworkMutation(NetworkBuilder<? super Integer, Object> networkBuilder) {
Random gen = new Random(42); // Fixed seed so test results are deterministic.
for (int trial = 0; trial < NUM_TRIALS; ++trial) {
MutableNetwork<Integer, Object> network =
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
Reported by PMD.
Line: 54
for (int trial = 0; trial < NUM_TRIALS; ++trial) {
MutableNetwork<Integer, Object> network =
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
assertThat(network.nodes()).isEmpty();
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
Reported by PMD.
Line: 54
for (int trial = 0; trial < NUM_TRIALS; ++trial) {
MutableNetwork<Integer, Object> network =
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
assertThat(network.nodes()).isEmpty();
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
Reported by PMD.
Line: 56
MutableNetwork<Integer, Object> network =
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
assertThat(network.nodes()).isEmpty();
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
while (network.nodes().size() < NUM_NODES) {
network.addNode(gen.nextInt(NODE_POOL_SIZE));
Reported by PMD.
Line: 56
MutableNetwork<Integer, Object> network =
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
assertThat(network.nodes()).isEmpty();
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
while (network.nodes().size() < NUM_NODES) {
network.addNode(gen.nextInt(NODE_POOL_SIZE));
Reported by PMD.
Line: 57
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
assertThat(network.nodes()).isEmpty();
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
while (network.nodes().size() < NUM_NODES) {
network.addNode(gen.nextInt(NODE_POOL_SIZE));
}
Reported by PMD.
Line: 57
networkBuilder.allowsParallelEdges(true).allowsSelfLoops(true).build();
assertThat(network.nodes()).isEmpty();
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
while (network.nodes().size() < NUM_NODES) {
network.addNode(gen.nextInt(NODE_POOL_SIZE));
}
Reported by PMD.
Line: 60
assertThat(network.edges()).isEmpty();
AbstractNetworkTest.validateNetwork(network);
while (network.nodes().size() < NUM_NODES) {
network.addNode(gen.nextInt(NODE_POOL_SIZE));
}
ArrayList<Integer> nodeList = new ArrayList<>(network.nodes());
for (int i = 0; i < NUM_EDGES; ++i) {
// Parallel edges are allowed, so this should always succeed.
Reported by PMD.
guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
45 issues
Line: 43
@GwtIncompatible
public abstract class AbstractListenableFutureTest extends TestCase {
protected CountDownLatch latch;
protected ListenableFuture<Boolean> future;
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 44
public abstract class AbstractListenableFutureTest extends TestCase {
protected CountDownLatch latch;
protected ListenableFuture<Boolean> future;
@Override
protected void setUp() throws Exception {
// Create a latch and a future that waits on the latch.
Reported by PMD.
Line: 46
protected CountDownLatch latch;
protected ListenableFuture<Boolean> future;
@Override
protected void setUp() throws Exception {
// Create a latch and a future that waits on the latch.
latch = new CountDownLatch(1);
future = createListenableFuture(Boolean.TRUE, null, latch);
Reported by PMD.
Line: 54
future = createListenableFuture(Boolean.TRUE, null, latch);
}
@Override
protected void tearDown() throws Exception {
// Make sure we have no waiting threads.
latch.countDown();
}
Reported by PMD.
Line: 66
V value, Exception except, CountDownLatch waitOn);
/** Tests that the {@link Future#get()} method blocks until a value is available. */
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
Reported by PMD.
Line: 66
V value, Exception except, CountDownLatch waitOn);
/** Tests that the {@link Future#get()} method blocks until a value is available. */
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
Reported by PMD.
Line: 68
/** Tests that the {@link Future#get()} method blocks until a value is available. */
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
final Throwable[] badness = new Throwable[1];
Reported by PMD.
Line: 69
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
final Throwable[] badness = new Throwable[1];
// Wait on the future in a separate thread.
Reported by PMD.
Line: 80
@Override
public void run() {
try {
assertSame(Boolean.TRUE, future.get());
successLatch.countDown();
} catch (Throwable t) {
t.printStackTrace();
badness[0] = t;
}
Reported by PMD.
Line: 82
try {
assertSame(Boolean.TRUE, future.get());
successLatch.countDown();
} catch (Throwable t) {
t.printStackTrace();
badness[0] = t;
}
}
})
Reported by PMD.
android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java
45 issues
Line: 36
* @author Jige Yu
*/
@GwtCompatible(emulated = true)
public class FakeTickerTest extends TestCase {
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(new FakeTicker());
Reported by PMD.
Line: 38
@GwtCompatible(emulated = true)
public class FakeTickerTest extends TestCase {
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(new FakeTicker());
}
Reported by PMD.
Line: 39
public class FakeTickerTest extends TestCase {
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(new FakeTicker());
}
public void testAdvance() {
Reported by PMD.
Line: 44
tester.testAllPublicInstanceMethods(new FakeTicker());
}
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
Reported by PMD.
Line: 44
tester.testAllPublicInstanceMethods(new FakeTicker());
}
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
Reported by PMD.
Line: 46
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
}
Reported by PMD.
Line: 47
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
}
Reported by PMD.
Line: 48
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
}
public void testAutoIncrementStep_returnsSameInstance() {
Reported by PMD.
Line: 50
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
}
public void testAutoIncrementStep_returnsSameInstance() {
FakeTicker ticker = new FakeTicker();
assertSame(ticker, ticker.setAutoIncrementStep(10, TimeUnit.NANOSECONDS));
Reported by PMD.
Line: 53
assertEquals(1000010L, ticker.read());
}
public void testAutoIncrementStep_returnsSameInstance() {
FakeTicker ticker = new FakeTicker();
assertSame(ticker, ticker.setAutoIncrementStep(10, TimeUnit.NANOSECONDS));
}
public void testAutoIncrementStep_nanos() {
Reported by PMD.
guava/src/com/google/common/collect/Iterators.java
45 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.instanceOf;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.instanceOf;
Reported by PMD.
Line: 72
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterators {
private Iterators() {}
/**
* Returns the empty iterator.
*
Reported by PMD.
Line: 72
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterators {
private Iterators() {}
/**
* Returns the empty iterator.
*
Reported by PMD.
Line: 72
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterators {
private Iterators() {}
/**
* Returns the empty iterator.
*
Reported by PMD.
Line: 72
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterators {
private Iterators() {}
/**
* Returns the empty iterator.
*
Reported by PMD.
Line: 90
* <p>The {@link Iterable} equivalent of this method is {@link ImmutableSet#of()}.
*/
// Casting to any type is safe since there are no actual elements.
@SuppressWarnings("unchecked")
static <T extends @Nullable Object> UnmodifiableListIterator<T> emptyListIterator() {
return (UnmodifiableListIterator<T>) ArrayItr.EMPTY;
}
/**
Reported by PMD.
Line: 416
* one, we can optimistically store the new Iterator and then be willing to throw it out if
* the user calls remove().)
*/
return iterator.hasNext() || iterable.iterator().hasNext();
}
@Override
@ParametricNullness
public T next() {
Reported by PMD.
Line: 468
private static <I extends Iterator<?>> Iterator<I> consumingForArray(
final @Nullable I... elements) {
return new UnmodifiableIterator<I>() {
int index = 0;
@Override
public boolean hasNext() {
return index < elements.length;
}
Reported by PMD.
Line: 642
array[count] = iterator.next();
}
for (int i = count; i < size; i++) {
array[i] = null; // for GWT
}
List<@Nullable T> list = Collections.unmodifiableList(Arrays.asList(array));
// TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
if (pad || count == size) {
Reported by PMD.
android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
45 issues
Line: 43
@GwtIncompatible
public abstract class AbstractListenableFutureTest extends TestCase {
protected CountDownLatch latch;
protected ListenableFuture<Boolean> future;
@Override
protected void setUp() throws Exception {
Reported by PMD.
Line: 44
public abstract class AbstractListenableFutureTest extends TestCase {
protected CountDownLatch latch;
protected ListenableFuture<Boolean> future;
@Override
protected void setUp() throws Exception {
// Create a latch and a future that waits on the latch.
Reported by PMD.
Line: 46
protected CountDownLatch latch;
protected ListenableFuture<Boolean> future;
@Override
protected void setUp() throws Exception {
// Create a latch and a future that waits on the latch.
latch = new CountDownLatch(1);
future = createListenableFuture(Boolean.TRUE, null, latch);
Reported by PMD.
Line: 54
future = createListenableFuture(Boolean.TRUE, null, latch);
}
@Override
protected void tearDown() throws Exception {
// Make sure we have no waiting threads.
latch.countDown();
}
Reported by PMD.
Line: 66
V value, Exception except, CountDownLatch waitOn);
/** Tests that the {@link Future#get()} method blocks until a value is available. */
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
Reported by PMD.
Line: 66
V value, Exception except, CountDownLatch waitOn);
/** Tests that the {@link Future#get()} method blocks until a value is available. */
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
Reported by PMD.
Line: 68
/** Tests that the {@link Future#get()} method blocks until a value is available. */
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
final Throwable[] badness = new Throwable[1];
Reported by PMD.
Line: 69
public void testGetBlocksUntilValueAvailable() throws Throwable {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
final CountDownLatch successLatch = new CountDownLatch(1);
final Throwable[] badness = new Throwable[1];
// Wait on the future in a separate thread.
Reported by PMD.
Line: 80
@Override
public void run() {
try {
assertSame(Boolean.TRUE, future.get());
successLatch.countDown();
} catch (Throwable t) {
t.printStackTrace();
badness[0] = t;
}
Reported by PMD.
Line: 82
try {
assertSame(Boolean.TRUE, future.get());
successLatch.countDown();
} catch (Throwable t) {
t.printStackTrace();
badness[0] = t;
}
}
})
Reported by PMD.
android/guava-tests/test/com/google/common/collect/HashMultisetTest.java
45 issues
Line: 44
@GwtCompatible(emulated = true)
public class HashMultisetTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(hashMultisetGenerator())
.withFeatures(
Reported by PMD.
Line: 48
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(hashMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SERIALIZABLE,
Reported by PMD.
Line: 48
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(hashMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SERIALIZABLE,
Reported by PMD.
Line: 48
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(hashMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SERIALIZABLE,
Reported by PMD.
Line: 71
};
}
public void testCreate() {
Multiset<String> multiset = HashMultiset.create();
multiset.add("foo", 2);
multiset.add("bar");
assertEquals(3, multiset.size());
assertEquals(2, multiset.count("foo"));
Reported by PMD.
Line: 71
};
}
public void testCreate() {
Multiset<String> multiset = HashMultiset.create();
multiset.add("foo", 2);
multiset.add("bar");
assertEquals(3, multiset.size());
assertEquals(2, multiset.count("foo"));
Reported by PMD.
Line: 73
public void testCreate() {
Multiset<String> multiset = HashMultiset.create();
multiset.add("foo", 2);
multiset.add("bar");
assertEquals(3, multiset.size());
assertEquals(2, multiset.count("foo"));
}
Reported by PMD.
Line: 73
public void testCreate() {
Multiset<String> multiset = HashMultiset.create();
multiset.add("foo", 2);
multiset.add("bar");
assertEquals(3, multiset.size());
assertEquals(2, multiset.count("foo"));
}
Reported by PMD.
Line: 74
public void testCreate() {
Multiset<String> multiset = HashMultiset.create();
multiset.add("foo", 2);
multiset.add("bar");
assertEquals(3, multiset.size());
assertEquals(2, multiset.count("foo"));
}
public void testCreateWithSize() {
Reported by PMD.
Line: 75
Multiset<String> multiset = HashMultiset.create();
multiset.add("foo", 2);
multiset.add("bar");
assertEquals(3, multiset.size());
assertEquals(2, multiset.count("foo"));
}
public void testCreateWithSize() {
Multiset<String> multiset = HashMultiset.create(50);
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
45 issues
Line: 36
*/
public class ListenableFutureTaskTest extends TestCase {
private ExecutorService exec;
protected final CountDownLatch runLatch = new CountDownLatch(1);
protected final CountDownLatch taskLatch = new CountDownLatch(1);
protected final CountDownLatch listenerLatch = new CountDownLatch(1);
Reported by PMD.
Line: 38
private ExecutorService exec;
protected final CountDownLatch runLatch = new CountDownLatch(1);
protected final CountDownLatch taskLatch = new CountDownLatch(1);
protected final CountDownLatch listenerLatch = new CountDownLatch(1);
protected volatile boolean throwException = false;
Reported by PMD.
Line: 39
private ExecutorService exec;
protected final CountDownLatch runLatch = new CountDownLatch(1);
protected final CountDownLatch taskLatch = new CountDownLatch(1);
protected final CountDownLatch listenerLatch = new CountDownLatch(1);
protected volatile boolean throwException = false;
protected final ListenableFutureTask<Integer> task =
Reported by PMD.
Line: 40
protected final CountDownLatch runLatch = new CountDownLatch(1);
protected final CountDownLatch taskLatch = new CountDownLatch(1);
protected final CountDownLatch listenerLatch = new CountDownLatch(1);
protected volatile boolean throwException = false;
protected final ListenableFutureTask<Integer> task =
ListenableFutureTask.create(
Reported by PMD.
Line: 42
protected final CountDownLatch taskLatch = new CountDownLatch(1);
protected final CountDownLatch listenerLatch = new CountDownLatch(1);
protected volatile boolean throwException = false;
protected final ListenableFutureTask<Integer> task =
ListenableFutureTask.create(
new Callable<Integer>() {
@Override
Reported by PMD.
Line: 42
protected final CountDownLatch taskLatch = new CountDownLatch(1);
protected final CountDownLatch listenerLatch = new CountDownLatch(1);
protected volatile boolean throwException = false;
protected final ListenableFutureTask<Integer> task =
ListenableFutureTask.create(
new Callable<Integer>() {
@Override
Reported by PMD.
Line: 44
protected volatile boolean throwException = false;
protected final ListenableFutureTask<Integer> task =
ListenableFutureTask.create(
new Callable<Integer>() {
@Override
public Integer call() throws Exception {
runLatch.countDown();
Reported by PMD.
Line: 58
}
});
@Override
protected void setUp() throws Exception {
super.setUp();
exec = Executors.newCachedThreadPool();
Reported by PMD.
Line: 74
directExecutor());
}
@Override
protected void tearDown() throws Exception {
if (exec != null) {
exec.shutdown();
}
Reported by PMD.
Line: 84
}
public void testListenerDoesNotRunUntilTaskCompletes() throws Exception {
// Test default state of not started.
assertEquals(1, listenerLatch.getCount());
assertFalse(task.isDone());
assertFalse(task.isCancelled());
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapEntriesTester.java
45 issues
Line: 47
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapEntriesTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testEntries() {
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 48
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapEntriesTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testEntries() {
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testContainsEntryWithNullKeyPresent() {
Reported by PMD.
Line: 51
assertEqualIgnoringOrder(getSampleElements(), multimap().entries());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testContainsEntryWithNullKeyPresent() {
initMultimapWithNullKey();
assertContains(multimap().entries(), Helpers.mapEntry((K) null, getValueForNullKey()));
}
Reported by PMD.
Line: 55
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testContainsEntryWithNullKeyPresent() {
initMultimapWithNullKey();
assertContains(multimap().entries(), Helpers.mapEntry((K) null, getValueForNullKey()));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testContainsEntryWithNullKeyAbsent() {
assertFalse(multimap().entries().contains(Helpers.mapEntry(null, v0())));
Reported by PMD.
Line: 58
assertContains(multimap().entries(), Helpers.mapEntry((K) null, getValueForNullKey()));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testContainsEntryWithNullKeyAbsent() {
assertFalse(multimap().entries().contains(Helpers.mapEntry(null, v0())));
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 60
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testContainsEntryWithNullKeyAbsent() {
assertFalse(multimap().entries().contains(Helpers.mapEntry(null, v0())));
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testContainsEntryWithNullValuePresent() {
Reported by PMD.
Line: 60
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testContainsEntryWithNullKeyAbsent() {
assertFalse(multimap().entries().contains(Helpers.mapEntry(null, v0())));
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testContainsEntryWithNullValuePresent() {
Reported by PMD.
Line: 63
assertFalse(multimap().entries().contains(Helpers.mapEntry(null, v0())));
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testContainsEntryWithNullValuePresent() {
initMultimapWithNullValue();
assertContains(multimap().entries(), Helpers.mapEntry(getKeyForNullValue(), (V) null));
}
Reported by PMD.
Line: 67
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testContainsEntryWithNullValuePresent() {
initMultimapWithNullValue();
assertContains(multimap().entries(), Helpers.mapEntry(getKeyForNullValue(), (V) null));
}
@MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
public void testContainsEntryWithNullValueAbsent() {
assertFalse(multimap().entries().contains(Helpers.mapEntry(k0(), null)));
Reported by PMD.
Line: 70
assertContains(multimap().entries(), Helpers.mapEntry(getKeyForNullValue(), (V) null));
}
@MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES)
public void testContainsEntryWithNullValueAbsent() {
assertFalse(multimap().entries().contains(Helpers.mapEntry(k0(), null)));
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
45 issues
Line: 319
try {
recurse(0);
} catch (RuntimeException e) {
throw new RuntimeException(Arrays.toString(stimuli), e);
}
}
private void recurse(int level) {
// We're going to reuse the stimuli array 3^steps times by overwriting it
Reported by PMD.
Line: 44
* @author Chris Povirk
*/
@GwtCompatible
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
Reported by PMD.
Line: 45
*/
@GwtCompatible
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
Reported by PMD.
Line: 46
@GwtCompatible
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
Reported by PMD.
Line: 47
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
Reported by PMD.
Line: 48
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
* Meta-exception thrown by {@link AbstractIteratorTester.MultiExceptionListIterator} instead of
Reported by PMD.
Line: 49
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
* Meta-exception thrown by {@link AbstractIteratorTester.MultiExceptionListIterator} instead of
* throwing any particular exception type.
Reported by PMD.
Line: 50
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
* Meta-exception thrown by {@link AbstractIteratorTester.MultiExceptionListIterator} instead of
* throwing any particular exception type.
*/
Reported by PMD.
Line: 97
if (!isPermitted(exception)) {
String message =
"Exception "
+ exception.getClass().getSimpleName()
+ " was thrown; expected "
+ getMessage();
Helpers.fail(exception, message);
}
}
Reported by PMD.
Line: 129
* <p>This class is accessible but not supported in GWT as it references {@link
* PermittedMetaException}.
*/
protected final class MultiExceptionListIterator implements ListIterator<E> {
// TODO: track seen elements when order isn't guaranteed
// TODO: verify contents afterward
// TODO: something shiny and new instead of Stack
// TODO: test whether null is supported (create a Feature)
/**
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableMap.java
45 issues
Line: 61
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
/**
* Returns the empty map. This map behaves and performs comparably to {@link
* Collections#emptyMap}, and is preferable mainly for consistency and maintainability of your
* code.
Reported by PMD.
Line: 70
*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
public static <K, V> ImmutableMap<K, V> of() {
return (ImmutableMap<K, V>) RegularImmutableMap.EMPTY;
}
/**
Reported by PMD.
Line: 126
*
* @throws IllegalArgumentException if duplicate keys are provided
*/
public static <K, V> ImmutableMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
checkEntryNotNull(k1, v1);
checkEntryNotNull(k2, v2);
checkEntryNotNull(k3, v3);
checkEntryNotNull(k4, v4);
Reported by PMD.
Line: 378
(V) requireNonNull(alternatingKeysAndValues[2 * i + 1]));
}
Arrays.sort(
entries, 0, size, Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
for (int i = 0; i < size; i++) {
alternatingKeysAndValues[2 * i] = entries[i].getKey();
alternatingKeysAndValues[2 * i + 1] = entries[i].getValue();
}
}
Reported by PMD.
Line: 403
if ((map instanceof ImmutableMap) && !(map instanceof SortedMap)) {
@SuppressWarnings("unchecked") // safe since map is not writable
ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) map;
if (!kvMap.isPartialView()) {
return kvMap;
}
}
return copyOf(map.entrySet());
}
Reported by PMD.
Line: 531
@Override
public boolean containsValue(@CheckForNull Object value) {
return values().contains(value);
}
// Overriding to mark it Nullable
@Override
@CheckForNull
Reported by PMD.
Line: 552
*/
// @Override under Java 8 / API Level 24
@CheckForNull
public final V getOrDefault(@CheckForNull Object key, @CheckForNull V defaultValue) {
V result = get(key);
// TODO(b/192579700): Use a ternary once it no longer confuses our nullness checker.
if (result != null) {
return result;
} else {
Reported by PMD.
Line: 562
}
}
@LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<Entry<K, V>> entrySet;
/**
* Returns an immutable set of the mappings in this map. The iteration order is specified by the
* method used to create this map. Typically, this is insertion order.
*/
Reported by PMD.
Line: 576
abstract ImmutableSet<Entry<K, V>> createEntrySet();
@LazyInit @RetainedWith @CheckForNull private transient ImmutableSet<K> keySet;
/**
* Returns an immutable set of the keys in this map, in the same order that they appear in {@link
* #entrySet}.
*/
Reported by PMD.
Line: 596
abstract ImmutableSet<K> createKeySet();
UnmodifiableIterator<K> keyIterator() {
final UnmodifiableIterator<Entry<K, V>> entryIterator = entrySet().iterator();
return new UnmodifiableIterator<K>() {
@Override
public boolean hasNext() {
return entryIterator.hasNext();
}
Reported by PMD.