The following issues were found
android/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.
android/guava-tests/test/com/google/common/graph/StandardMutableDirectedGraphTest.java
5 issues
Line: 41
});
}
private final boolean allowsSelfLoops;
private final ElementOrder<Integer> incidentEdgeOrder;
public StandardMutableDirectedGraphTest(
boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
this.allowsSelfLoops = allowsSelfLoops;
Reported by PMD.
Line: 42
}
private final boolean allowsSelfLoops;
private final ElementOrder<Integer> incidentEdgeOrder;
public StandardMutableDirectedGraphTest(
boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
this.allowsSelfLoops = allowsSelfLoops;
this.incidentEdgeOrder = incidentEdgeOrder;
Reported by PMD.
Line: 52
@Override
public MutableGraph<Integer> createGraph() {
return GraphBuilder.directed()
.allowsSelfLoops(allowsSelfLoops)
.incidentEdgeOrder(incidentEdgeOrder)
.build();
}
Reported by PMD.
Line: 52
@Override
public MutableGraph<Integer> createGraph() {
return GraphBuilder.directed()
.allowsSelfLoops(allowsSelfLoops)
.incidentEdgeOrder(incidentEdgeOrder)
.build();
}
Reported by PMD.
Line: 52
@Override
public MutableGraph<Integer> createGraph() {
return GraphBuilder.directed()
.allowsSelfLoops(allowsSelfLoops)
.incidentEdgeOrder(incidentEdgeOrder)
.build();
}
Reported by PMD.
android/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.
android/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.
android/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.
android/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.
android/guava-tests/test/com/google/common/graph/StandardMutableUndirectedGraphTest.java
5 issues
Line: 41
});
}
private final boolean allowsSelfLoops;
private final ElementOrder<Integer> incidentEdgeOrder;
public StandardMutableUndirectedGraphTest(
boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
this.allowsSelfLoops = allowsSelfLoops;
Reported by PMD.
Line: 42
}
private final boolean allowsSelfLoops;
private final ElementOrder<Integer> incidentEdgeOrder;
public StandardMutableUndirectedGraphTest(
boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
this.allowsSelfLoops = allowsSelfLoops;
this.incidentEdgeOrder = incidentEdgeOrder;
Reported by PMD.
Line: 52
@Override
public MutableGraph<Integer> createGraph() {
return GraphBuilder.undirected()
.allowsSelfLoops(allowsSelfLoops)
.incidentEdgeOrder(incidentEdgeOrder)
.build();
}
Reported by PMD.
Line: 52
@Override
public MutableGraph<Integer> createGraph() {
return GraphBuilder.undirected()
.allowsSelfLoops(allowsSelfLoops)
.incidentEdgeOrder(incidentEdgeOrder)
.build();
}
Reported by PMD.
Line: 52
@Override
public MutableGraph<Integer> createGraph() {
return GraphBuilder.undirected()
.allowsSelfLoops(allowsSelfLoops)
.incidentEdgeOrder(incidentEdgeOrder)
.build();
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestStringListGenerator.java
4 issues
Line: 49
* Creates a new collection containing the given elements; implement this method instead of {@link
* #create(Object...)}.
*/
protected abstract List<String> create(String[] elements);
@Override
public String[] createArray(int length) {
return new String[length];
}
Reported by PMD.
Line: 37
@Override
public List<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
Reported by PMD.
Line: 38
@Override
public List<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
Reported by PMD.
Line: 40
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
/**
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/TestStringCollectionGenerator.java
4 issues
Line: 46
return create(array);
}
protected abstract Collection<String> create(String[] elements);
@Override
public String[] createArray(int length) {
return new String[length];
}
Reported by PMD.
Line: 38
@Override
public Collection<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
Reported by PMD.
Line: 39
@Override
public Collection<String> create(Object... elements) {
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
Reported by PMD.
Line: 41
String[] array = new String[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (String) e;
}
return create(array);
}
protected abstract Collection<String> create(String[] elements);
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultisetSerializationTester.java
4 issues
Line: 37
@GwtCompatible // but no-op
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetSerializationTester<E> extends AbstractMultisetTester<E> {
@CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
public void testEntrySetSerialization() {
Set<Multiset.Entry<E>> expected = getMultiset().entrySet();
assertEquals(expected, SerializableTester.reserialize(expected));
}
Reported by PMD.
Line: 39
public class MultisetSerializationTester<E> extends AbstractMultisetTester<E> {
@CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
public void testEntrySetSerialization() {
Set<Multiset.Entry<E>> expected = getMultiset().entrySet();
assertEquals(expected, SerializableTester.reserialize(expected));
}
@CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
public void testElementSetSerialization() {
Reported by PMD.
Line: 43
assertEquals(expected, SerializableTester.reserialize(expected));
}
@CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
public void testElementSetSerialization() {
Set<E> expected = getMultiset().elementSet();
assertEquals(expected, SerializableTester.reserialize(expected));
}
}
Reported by PMD.
Line: 45
@CollectionFeature.Require(SERIALIZABLE_INCLUDING_VIEWS)
public void testElementSetSerialization() {
Set<E> expected = getMultiset().elementSet();
assertEquals(expected, SerializableTester.reserialize(expected));
}
}
Reported by PMD.