The following issues were found
guava-tests/test/com/google/common/collect/ForwardingQueueTest.java
5 issues
Line: 41
*/
public class ForwardingQueueTest extends TestCase {
static final class StandardImplForwardingQueue<T> extends ForwardingQueue<T> {
private final Queue<T> backingQueue;
StandardImplForwardingQueue(Queue<T> backingQueue) {
this.backingQueue = backingQueue;
}
Reported by PMD.
Line: 42
public class ForwardingQueueTest extends TestCase {
static final class StandardImplForwardingQueue<T> extends ForwardingQueue<T> {
private final Queue<T> backingQueue;
StandardImplForwardingQueue(Queue<T> backingQueue) {
this.backingQueue = backingQueue;
}
Reported by PMD.
Line: 119
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingQueueTest.class);
suite.addTest(
QueueTestSuiteBuilder.using(
Reported by PMD.
Line: 142
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Queue.class,
new Function<Queue, Queue>() {
Reported by PMD.
Line: 143
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Queue.class,
new Function<Queue, Queue>() {
@Override
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ListLastIndexOfTester.java
5 issues
Line: 39
public class ListLastIndexOfTester<E> extends AbstractListIndexOfTester<E> {
@Override
protected int find(Object o) {
return getList().lastIndexOf(o);
}
@Override
protected String getMethodName() {
return "lastIndexOf";
Reported by PMD.
Line: 47
return "lastIndexOf";
}
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testLastIndexOf_duplicate() {
E[] array = createSamplesArray();
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
Reported by PMD.
Line: 52
public void testLastIndexOf_duplicate() {
E[] array = createSamplesArray();
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
assertEquals(
"lastIndexOf(duplicate) should return index of last occurrence",
getNumElements() / 2,
getList().lastIndexOf(e0()));
}
Reported by PMD.
Line: 56
assertEquals(
"lastIndexOf(duplicate) should return index of last occurrence",
getNumElements() / 2,
getList().lastIndexOf(e0()));
}
}
Reported by PMD.
Line: 50
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testLastIndexOf_duplicate() {
E[] array = createSamplesArray();
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
assertEquals(
"lastIndexOf(duplicate) should return index of last occurrence",
getNumElements() / 2,
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ListIndexOfTester.java
5 issues
Line: 39
public class ListIndexOfTester<E> extends AbstractListIndexOfTester<E> {
@Override
protected int find(Object o) {
return getList().indexOf(o);
}
@Override
protected String getMethodName() {
return "indexOf";
Reported by PMD.
Line: 47
return "indexOf";
}
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testIndexOf_duplicate() {
E[] array = createSamplesArray();
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
Reported by PMD.
Line: 52
public void testIndexOf_duplicate() {
E[] array = createSamplesArray();
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
assertEquals(
"indexOf(duplicate) should return index of first occurrence", 0, getList().indexOf(e0()));
}
}
Reported by PMD.
Line: 54
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
assertEquals(
"indexOf(duplicate) should return index of first occurrence", 0, getList().indexOf(e0()));
}
}
Reported by PMD.
Line: 50
@CollectionFeature.Require(absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testIndexOf_duplicate() {
E[] array = createSamplesArray();
array[getNumElements() / 2] = e0();
collection = getSubjectGenerator().create(array);
assertEquals(
"indexOf(duplicate) should return index of first occurrence", 0, getList().indexOf(e0()));
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/SetAddTester.java
5 issues
Line: 40
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetAddTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAdd_supportedPresent() {
assertFalse("add(present) should return false", getSet().add(e0()));
expectUnchanged();
}
Reported by PMD.
Line: 43
@CollectionFeature.Require(SUPPORTS_ADD)
@CollectionSize.Require(absent = ZERO)
public void testAdd_supportedPresent() {
assertFalse("add(present) should return false", getSet().add(e0()));
expectUnchanged();
}
@CollectionFeature.Require(value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 47
expectUnchanged();
}
@CollectionFeature.Require(value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testAdd_supportedNullPresent() {
E[] array = createArrayWithNullElement();
collection = getSubjectGenerator().create(array);
assertFalse("add(nullPresent) should return false", getSet().add(null));
Reported by PMD.
Line: 51
@CollectionSize.Require(absent = ZERO)
public void testAdd_supportedNullPresent() {
E[] array = createArrayWithNullElement();
collection = getSubjectGenerator().create(array);
assertFalse("add(nullPresent) should return false", getSet().add(null));
expectContents(array);
}
/**
Reported by PMD.
Line: 52
public void testAdd_supportedNullPresent() {
E[] array = createArrayWithNullElement();
collection = getSubjectGenerator().create(array);
assertFalse("add(nullPresent) should return false", getSet().add(null));
expectContents(array);
}
/**
* Returns the {@link Method} instance for {@link #testAdd_supportedNullPresent()} so that tests
Reported by PMD.
guava-tests/benchmark/com/google/common/collect/SetCreationBenchmark.java
5 issues
Line: 35
"3", "6", "11", "23", "45", "91", "181", "362", "724", "1448", "2896", "5793", "11585", "23170",
"46341", "92682", "185364", "370728", "741455", "1482910", "2965821", "5931642"
})
private int size;
// "" means no fixed seed
@Param("1234")
private SpecialRandom random;
Reported by PMD.
Line: 39
// "" means no fixed seed
@Param("1234")
private SpecialRandom random;
@Param({"ImmutableSetImpl", "HashSetImpl"})
private SetImpl impl;
// the following must be set during setUp
Reported by PMD.
Line: 42
private SpecialRandom random;
@Param({"ImmutableSetImpl", "HashSetImpl"})
private SetImpl impl;
// the following must be set during setUp
private CollectionBenchmarkSampleData sampleData;
@BeforeExperiment
Reported by PMD.
Line: 45
private SetImpl impl;
// the following must be set during setUp
private CollectionBenchmarkSampleData sampleData;
@BeforeExperiment
void setUp() {
sampleData = new CollectionBenchmarkSampleData(true, random, 0.8, size);
}
Reported by PMD.
Line: 47
// the following must be set during setUp
private CollectionBenchmarkSampleData sampleData;
@BeforeExperiment
void setUp() {
sampleData = new CollectionBenchmarkSampleData(true, random, 0.8, size);
}
@Benchmark
Reported by PMD.
guava-tests/benchmark/com/google/common/collect/SetIterationBenchmark.java
5 issues
Line: 36
"3", "6", "11", "23", "45", "91", "181", "362", "724", "1448", "2896", "5793", "11585", "23170",
"46341", "92682", "185364", "370728", "741455", "1482910", "2965821", "5931642"
})
private int size;
// "" means no fixed seed
@Param("1234")
private SpecialRandom random;
Reported by PMD.
Line: 40
// "" means no fixed seed
@Param("1234")
private SpecialRandom random;
@Param({"ImmutableSetImpl", "HashSetImpl"})
private SetImpl impl;
// the following must be set during setUp
Reported by PMD.
Line: 43
private SpecialRandom random;
@Param({"ImmutableSetImpl", "HashSetImpl"})
private SetImpl impl;
// the following must be set during setUp
private Set<Element> setToTest;
@BeforeExperiment
Reported by PMD.
Line: 46
private SetImpl impl;
// the following must be set during setUp
private Set<Element> setToTest;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
new CollectionBenchmarkSampleData(true, random, 0.8, size);
Reported by PMD.
Line: 48
// the following must be set during setUp
private Set<Element> setToTest;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
new CollectionBenchmarkSampleData(true, random, 0.8, size);
setToTest = (Set<Element>) impl.create(sampleData.getValuesInSet());
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ListGetTester.java
5 issues
Line: 31
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListGetTester<E> extends AbstractListTester<E> {
public void testGet_valid() {
// This calls get() on each index and checks the result:
expectContents(createOrderedArray());
}
public void testGet_negative() {
Reported by PMD.
Line: 36
expectContents(createOrderedArray());
}
public void testGet_negative() {
try {
getList().get(-1);
fail("get(-1) should throw");
} catch (IndexOutOfBoundsException expected) {
}
Reported by PMD.
Line: 38
public void testGet_negative() {
try {
getList().get(-1);
fail("get(-1) should throw");
} catch (IndexOutOfBoundsException expected) {
}
}
Reported by PMD.
Line: 44
}
}
public void testGet_tooLarge() {
try {
getList().get(getNumElements());
fail("get(size) should throw");
} catch (IndexOutOfBoundsException expected) {
}
Reported by PMD.
Line: 46
public void testGet_tooLarge() {
try {
getList().get(getNumElements());
fail("get(size) should throw");
} catch (IndexOutOfBoundsException expected) {
}
}
}
Reported by PMD.
guava-testlib/src/com/google/common/testing/ClusterException.java
5 issues
Line: 62
* @author Luiz-Otavio Zorzella
*/
@GwtCompatible
final class ClusterException extends RuntimeException {
public final Collection<? extends Throwable> exceptions;
private ClusterException(Collection<? extends Throwable> exceptions) {
super(
Reported by PMD.
Line: 64
@GwtCompatible
final class ClusterException extends RuntimeException {
public final Collection<? extends Throwable> exceptions;
private ClusterException(Collection<? extends Throwable> exceptions) {
super(
exceptions.size() + " exceptions were thrown. The first exception is listed as a cause.",
exceptions.iterator().next());
Reported by PMD.
Line: 100
* @throws IllegalArgumentException if {@code exceptions} is empty
*/
public static RuntimeException create(Collection<? extends Throwable> exceptions) {
if (exceptions.size() == 0) {
throw new IllegalArgumentException("Can't create an ExceptionCollection with no exceptions");
}
if (exceptions.size() == 1) {
Throwable temp = exceptions.iterator().next();
if (temp instanceof RuntimeException) {
Reported by PMD.
Line: 103
if (exceptions.size() == 0) {
throw new IllegalArgumentException("Can't create an ExceptionCollection with no exceptions");
}
if (exceptions.size() == 1) {
Throwable temp = exceptions.iterator().next();
if (temp instanceof RuntimeException) {
return (RuntimeException) temp;
} else {
return new RuntimeException(temp);
Reported by PMD.
Line: 104
throw new IllegalArgumentException("Can't create an ExceptionCollection with no exceptions");
}
if (exceptions.size() == 1) {
Throwable temp = exceptions.iterator().next();
if (temp instanceof RuntimeException) {
return (RuntimeException) temp;
} else {
return new RuntimeException(temp);
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/SetMultimapPutAllTester.java
5 issues
Line: 37
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapPutAllTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllHandlesDuplicates() {
@SuppressWarnings("unchecked")
List<V> valuesToPut = Arrays.asList(v0(), v1(), v0());
for (K k : sampleKeys()) {
Reported by PMD.
Line: 45
for (K k : sampleKeys()) {
resetContainer();
Set<V> expectedValues = copyToSet(multimap().get(k));
multimap().putAll(k, valuesToPut);
expectedValues.addAll(valuesToPut);
assertGet(k, expectedValues);
Reported by PMD.
Line: 47
Set<V> expectedValues = copyToSet(multimap().get(k));
multimap().putAll(k, valuesToPut);
expectedValues.addAll(valuesToPut);
assertGet(k, expectedValues);
}
}
Reported by PMD.
Line: 48
Set<V> expectedValues = copyToSet(multimap().get(k));
multimap().putAll(k, valuesToPut);
expectedValues.addAll(valuesToPut);
assertGet(k, expectedValues);
}
}
}
Reported by PMD.
Line: 40
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllHandlesDuplicates() {
@SuppressWarnings("unchecked")
List<V> valuesToPut = Arrays.asList(v0(), v1(), v0());
for (K k : sampleKeys()) {
resetContainer();
Set<V> expectedValues = copyToSet(multimap().get(k));
Reported by PMD.
guava-testlib/src/com/google/common/testing/TearDownStack.java
5 issues
Line: 45
private static final Logger logger = Logger.getLogger(TearDownStack.class.getName());
@GuardedBy("stack")
final LinkedList<TearDown> stack = new LinkedList<>();
private final boolean suppressThrows;
public TearDownStack() {
this.suppressThrows = false;
Reported by PMD.
Line: 45
private static final Logger logger = Logger.getLogger(TearDownStack.class.getName());
@GuardedBy("stack")
final LinkedList<TearDown> stack = new LinkedList<>();
private final boolean suppressThrows;
public TearDownStack() {
this.suppressThrows = false;
Reported by PMD.
Line: 47
@GuardedBy("stack")
final LinkedList<TearDown> stack = new LinkedList<>();
private final boolean suppressThrows;
public TearDownStack() {
this.suppressThrows = false;
}
Reported by PMD.
Line: 75
for (TearDown tearDown : stackCopy) {
try {
tearDown.tearDown();
} catch (Throwable t) {
if (suppressThrows) {
logger.log(Level.INFO, "exception thrown during tearDown", t);
} else {
exceptions.add(t);
}
Reported by PMD.
Line: 83
}
}
}
if (!suppressThrows && (exceptions.size() > 0)) {
throw ClusterException.create(exceptions);
}
}
}
Reported by PMD.