The following issues were found
android/guava-testlib/src/com/google/common/escape/testing/EscaperAsserts.java
3 issues
Line: 52
try {
escaper.escape((String) null);
Assert.fail("exception not thrown when escaping a null string");
} catch (NullPointerException e) {
// pass
}
}
/**
Reported by PMD.
Line: 52
try {
escaper.escape((String) null);
Assert.fail("exception not thrown when escaping a null string");
} catch (NullPointerException e) {
// pass
}
}
/**
Reported by PMD.
Line: 52
try {
escaper.escape((String) null);
Assert.fail("exception not thrown when escaping a null string");
} catch (NullPointerException e) {
// pass
}
}
/**
Reported by PMD.
android/guava-testlib/src/com/google/common/util/concurrent/testing/TestingExecutors.java
3 issues
Line: 98
private static final class NoOpScheduledExecutorService extends AbstractListeningExecutorService
implements ListeningScheduledExecutorService {
private volatile boolean shutdown;
@Override
public void shutdown() {
shutdown = true;
}
Reported by PMD.
Line: 98
private static final class NoOpScheduledExecutorService extends AbstractListeningExecutorService
implements ListeningScheduledExecutorService {
private volatile boolean shutdown;
@Override
public void shutdown() {
shutdown = true;
}
Reported by PMD.
Line: 27
import com.google.common.util.concurrent.AbstractListeningExecutorService;
import com.google.common.util.concurrent.ListenableScheduledFuture;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Delayed;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
Reported by PMD.
android/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java
3 issues
Line: 39
// TODO: MinimalCollection should perhaps throw
for (Object element : elements) {
if (element == null) {
throw new NullPointerException();
}
}
return MinimalCollection.of(elements);
}
})
Reported by PMD.
Line: 30
*
* @author Kevin Bourrillion
*/
public class MinimalCollectionTest extends TestCase {
public static Test suite() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
Reported by PMD.
Line: 31
* @author Kevin Bourrillion
*/
public class MinimalCollectionTest extends TestCase {
public static Test suite() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
@Override
public Collection<String> create(String[] elements) {
// TODO: MinimalCollection should perhaps throw
Reported by PMD.
android/guava-tests/benchmark/com/google/common/collect/PowerSetBenchmark.java
3 issues
Line: 33
*/
public class PowerSetBenchmark {
@Param({"2", "4", "8", "16"})
int elements;
Set<Set<Integer>> powerSet;
@BeforeExperiment
void setUp() {
Reported by PMD.
Line: 35
@Param({"2", "4", "8", "16"})
int elements;
Set<Set<Integer>> powerSet;
@BeforeExperiment
void setUp() {
Set<Integer> set = ContiguousSet.create(Range.closed(1, elements), integers());
powerSet = Sets.powerSet(set);
Reported by PMD.
Line: 37
Set<Set<Integer>> powerSet;
@BeforeExperiment
void setUp() {
Set<Integer> set = ContiguousSet.create(Range.closed(1, elements), integers());
powerSet = Sets.powerSet(set);
}
Reported by PMD.
android/guava-tests/benchmark/com/google/common/math/DoubleMathRoundingBenchmark.java
3 issues
Line: 40
private static final double[] positiveDoubles = new double[ARRAY_SIZE];
@Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
RoundingMode mode;
@BeforeExperiment
void setUp() {
for (int i = 0; i < ARRAY_SIZE; i++) {
doubleInIntRange[i] = randomDouble(Integer.SIZE - 2);
Reported by PMD.
Line: 42
@Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
RoundingMode mode;
@BeforeExperiment
void setUp() {
for (int i = 0; i < ARRAY_SIZE; i++) {
doubleInIntRange[i] = randomDouble(Integer.SIZE - 2);
doubleInLongRange[i] = randomDouble(Long.SIZE - 2);
positiveDoubles[i] = randomPositiveDouble();
Reported by PMD.
Line: 76
int tmp = 0;
for (int i = 0; i < reps; i++) {
int j = i & ARRAY_MASK;
tmp += DoubleMath.roundToBigInteger(positiveDoubles[j], mode).intValue();
}
return tmp;
}
@Benchmark
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/ListCreationTester.java
3 issues
Line: 38
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListCreationTester<E> extends AbstractListTester<E> {
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
Reported by PMD.
Line: 43
public void testCreateWithDuplicates() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
expectContents(array);
}
}
Reported by PMD.
Line: 41
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
expectContents(array);
}
Reported by PMD.
android/guava-tests/test/com/google/common/cache/TestingRemovalListeners.java
3 issues
Line: 28
* @author mike nonemacher
*/
@GwtCompatible(emulated = true)
class TestingRemovalListeners {
/** Returns a new no-op {@code RemovalListener}. */
static <K, V> NullRemovalListener<K, V> nullRemovalListener() {
return new NullRemovalListener<>();
}
Reported by PMD.
Line: 48
/** {@link RemovalListener} that adds all {@link RemovalNotification} objects to a queue. */
@GwtIncompatible // ConcurrentLinkedQueue
static class QueuingRemovalListener<K, V> extends ConcurrentLinkedQueue<RemovalNotification<K, V>>
implements RemovalListener<K, V> {
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
add(notification);
Reported by PMD.
Line: 63
*/
static class CountingRemovalListener<K, V> implements RemovalListener<K, V> {
private final AtomicInteger count = new AtomicInteger();
private volatile RemovalNotification<K, V> lastNotification;
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
count.incrementAndGet();
lastNotification = notification;
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/SetMultimapReplaceValuesTester.java
3 issues
Line: 37
public class SetMultimapReplaceValuesTester<K, V>
extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
public void testReplaceValuesHandlesDuplicates() {
@SuppressWarnings("unchecked")
List<V> values = Arrays.asList(v0(), v1(), v0());
for (K k : sampleKeys()) {
Reported by PMD.
Line: 44
for (K k : sampleKeys()) {
resetContainer();
multimap().replaceValues(k, values);
assertGet(k, v0(), v1());
}
}
}
Reported by PMD.
Line: 40
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
public void testReplaceValuesHandlesDuplicates() {
@SuppressWarnings("unchecked")
List<V> values = Arrays.asList(v0(), v1(), v0());
for (K k : sampleKeys()) {
resetContainer();
multimap().replaceValues(k, values);
assertGet(k, v0(), v1());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/SetMultimapEqualsTester.java
3 issues
Line: 34
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapEqualsTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
SetMultimap<K, V> multimap1 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v0()),
Reported by PMD.
Line: 37
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
SetMultimap<K, V> multimap1 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v4()));
SetMultimap<K, V> multimap2 =
Reported by PMD.
Line: 43
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v4()));
SetMultimap<K, V> multimap2 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k0(), v4()));
new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ImmutableMultimapAsMapImplementsMapTest.java
3 issues
Line: 39
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return ImmutableMultimap.<String, Integer>of().asMap();
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> delegate = HashMultimap.create();
Reported by PMD.
Line: 39
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return ImmutableMultimap.<String, Integer>of().asMap();
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> delegate = HashMultimap.create();
Reported by PMD.
Line: 46
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> delegate = HashMultimap.create();
populate(delegate);
return ImmutableMultimap.copyOf(delegate).asMap();
}
}
Reported by PMD.