The following issues were found
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.
guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java
5 issues
Line: 41
* @author Louis Wasserman
*/
public class ForwardingCollectionTest extends TestCase {
static final class StandardImplForwardingCollection<T> extends ForwardingCollection<T> {
private final Collection<T> backingCollection;
StandardImplForwardingCollection(Collection<T> backingCollection) {
this.backingCollection = backingCollection;
}
Reported by PMD.
Line: 42
*/
public class ForwardingCollectionTest extends TestCase {
static final class StandardImplForwardingCollection<T> extends ForwardingCollection<T> {
private final Collection<T> backingCollection;
StandardImplForwardingCollection(Collection<T> backingCollection) {
this.backingCollection = backingCollection;
}
Reported by PMD.
Line: 104
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingCollectionTest.class);
suite.addTest(
CollectionTestSuiteBuilder.using(
Reported by PMD.
Line: 138
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Collection.class,
new Function<Collection, Collection>() {
Reported by PMD.
Line: 139
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Collection.class,
new Function<Collection, Collection>() {
@Override
Reported by PMD.
guava-tests/test/com/google/common/collect/MultimapsFilterEntriesAsMapTest.java
5 issues
Line: 46
private Multimap<String, Integer> createMultimap() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("zero", 55556);
unfiltered.put("one", 55556);
unfiltered.put("badkey", 1);
return Multimaps.filterEntries(unfiltered, PREDICATE);
}
Reported by PMD.
Line: 47
private Multimap<String, Integer> createMultimap() {
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("zero", 55556);
unfiltered.put("one", 55556);
unfiltered.put("badkey", 1);
return Multimaps.filterEntries(unfiltered, PREDICATE);
}
@Override
Reported by PMD.
Line: 48
Multimap<String, Integer> unfiltered = HashMultimap.create();
unfiltered.put("zero", 55556);
unfiltered.put("one", 55556);
unfiltered.put("badkey", 1);
return Multimaps.filterEntries(unfiltered, PREDICATE);
}
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
Reported by PMD.
Line: 55
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
Multimap<String, Integer> multimap = createMultimap();
return multimap.asMap();
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> multimap = createMultimap();
Reported by PMD.
Line: 62
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> multimap = createMultimap();
populate(multimap);
return multimap.asMap();
}
}
Reported by PMD.
guava-tests/benchmark/com/google/common/math/DoubleMathBenchmark.java
5 issues
Line: 38
private static final int[] factorials = new int[ARRAY_SIZE];
private static final double[] doubles = new double[ARRAY_SIZE];
@BeforeExperiment
void setUp() {
for (int i = 0; i < ARRAY_SIZE; i++) {
positiveDoubles[i] = randomPositiveDouble();
doubles[i] = randomDouble(Long.SIZE);
factorials[i] = RANDOM_SOURCE.nextInt(100);
Reported by PMD.
Line: 69
@Benchmark
int isMathematicalInteger(int reps) {
int tmp = 0;
for (int i = 0; i < reps; i++) {
int j = i & ARRAY_MASK;
if (DoubleMath.isMathematicalInteger(doubles[j])) {
tmp++;
}
Reported by PMD.
Line: 73
for (int i = 0; i < reps; i++) {
int j = i & ARRAY_MASK;
if (DoubleMath.isMathematicalInteger(doubles[j])) {
tmp++;
}
}
return tmp;
}
Reported by PMD.
Line: 81
@Benchmark
int isPowerOfTwo(int reps) {
int tmp = 0;
for (int i = 0; i < reps; i++) {
int j = i & ARRAY_MASK;
if (DoubleMath.isPowerOfTwo(doubles[j])) {
tmp++;
}
Reported by PMD.
Line: 85
for (int i = 0; i < reps; i++) {
int j = i & ARRAY_MASK;
if (DoubleMath.isPowerOfTwo(doubles[j])) {
tmp++;
}
}
return tmp;
}
}
Reported by PMD.
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.
guava-testlib/src/com/google/common/collect/testing/google/SetMultimapTestSuiteBuilder.java
5 issues
Line: 56
@Override
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(SetMultimapAsMapTester.class);
testers.add(SetMultimapEqualsTester.class);
testers.add(SetMultimapPutTester.class);
testers.add(SetMultimapPutAllTester.class);
testers.add(SetMultimapReplaceValuesTester.class);
return testers;
Reported by PMD.
Line: 57
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(SetMultimapAsMapTester.class);
testers.add(SetMultimapEqualsTester.class);
testers.add(SetMultimapPutTester.class);
testers.add(SetMultimapPutAllTester.class);
testers.add(SetMultimapReplaceValuesTester.class);
return testers;
}
Reported by PMD.
Line: 58
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(SetMultimapAsMapTester.class);
testers.add(SetMultimapEqualsTester.class);
testers.add(SetMultimapPutTester.class);
testers.add(SetMultimapPutAllTester.class);
testers.add(SetMultimapReplaceValuesTester.class);
return testers;
}
Reported by PMD.
Line: 59
testers.add(SetMultimapAsMapTester.class);
testers.add(SetMultimapEqualsTester.class);
testers.add(SetMultimapPutTester.class);
testers.add(SetMultimapPutAllTester.class);
testers.add(SetMultimapReplaceValuesTester.class);
return testers;
}
@Override
Reported by PMD.
Line: 60
testers.add(SetMultimapEqualsTester.class);
testers.add(SetMultimapPutTester.class);
testers.add(SetMultimapPutAllTester.class);
testers.add(SetMultimapReplaceValuesTester.class);
return testers;
}
@Override
TestSuite computeMultimapGetTestSuite(
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultisetContainsTester.java
5 issues
Line: 32
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetContainsTester<E> extends AbstractMultisetTester<E> {
@CollectionSize.Require(absent = ZERO)
public void testContainsAllMultisetIgnoresFrequency() {
assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 34
public class MultisetContainsTester<E> extends AbstractMultisetTester<E> {
@CollectionSize.Require(absent = ZERO)
public void testContainsAllMultisetIgnoresFrequency() {
assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
}
@CollectionSize.Require(absent = ZERO)
public void testContainsAllListIgnoresFrequency() {
assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));
Reported by PMD.
Line: 34
public class MultisetContainsTester<E> extends AbstractMultisetTester<E> {
@CollectionSize.Require(absent = ZERO)
public void testContainsAllMultisetIgnoresFrequency() {
assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
}
@CollectionSize.Require(absent = ZERO)
public void testContainsAllListIgnoresFrequency() {
assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));
Reported by PMD.
Line: 37
assertTrue(getMultiset().containsAll(getSubjectGenerator().create(e0(), e0(), e0())));
}
@CollectionSize.Require(absent = ZERO)
public void testContainsAllListIgnoresFrequency() {
assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));
}
}
Reported by PMD.
Line: 39
@CollectionSize.Require(absent = ZERO)
public void testContainsAllListIgnoresFrequency() {
assertTrue(getMultiset().containsAll(Arrays.asList(e0(), e0(), e0())));
}
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ListToArrayTester.java
5 issues
Line: 37
public class ListToArrayTester<E> extends AbstractListTester<E> {
// CollectionToArrayTester tests everything except ordering.
public void testToArray_noArg() {
Object[] actual = getList().toArray();
assertArrayEquals("toArray() order should match list", createOrderedArray(), actual);
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 38
// CollectionToArrayTester tests everything except ordering.
public void testToArray_noArg() {
Object[] actual = getList().toArray();
assertArrayEquals("toArray() order should match list", createOrderedArray(), actual);
}
@CollectionSize.Require(absent = ZERO)
public void testToArray_tooSmall() {
Reported by PMD.
Line: 42
assertArrayEquals("toArray() order should match list", createOrderedArray(), actual);
}
@CollectionSize.Require(absent = ZERO)
public void testToArray_tooSmall() {
Object[] actual = getList().toArray(new Object[0]);
assertArrayEquals("toArray(tooSmall) order should match list", createOrderedArray(), actual);
}
Reported by PMD.
Line: 48
assertArrayEquals("toArray(tooSmall) order should match list", createOrderedArray(), actual);
}
public void testToArray_largeEnough() {
Object[] actual = getList().toArray(new Object[getNumElements()]);
assertArrayEquals("toArray(largeEnough) order should match list", createOrderedArray(), actual);
}
private static void assertArrayEquals(String message, Object[] expected, Object[] actual) {
Reported by PMD.
Line: 53
assertArrayEquals("toArray(largeEnough) order should match list", createOrderedArray(), actual);
}
private static void assertArrayEquals(String message, Object[] expected, Object[] actual) {
assertEquals(message, Arrays.asList(expected), Arrays.asList(actual));
}
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/AbstractListTester.java
5 issues
Line: 54
protected void expectContents(Collection<E> expectedCollection) {
List<E> expectedList = Helpers.copyToList(expectedCollection);
// Avoid expectEquals() here to delay reason manufacture until necessary.
if (getList().size() != expectedList.size()) {
fail("size mismatch: " + reportContext(expectedList));
}
for (int i = 0; i < expectedList.size(); i++) {
E expected = expectedList.get(i);
E actual = getList().get(i);
Reported by PMD.
Line: 54
protected void expectContents(Collection<E> expectedCollection) {
List<E> expectedList = Helpers.copyToList(expectedCollection);
// Avoid expectEquals() here to delay reason manufacture until necessary.
if (getList().size() != expectedList.size()) {
fail("size mismatch: " + reportContext(expectedList));
}
for (int i = 0; i < expectedList.size(); i++) {
E expected = expectedList.get(i);
E actual = getList().get(i);
Reported by PMD.
Line: 59
}
for (int i = 0; i < expectedList.size(); i++) {
E expected = expectedList.get(i);
E actual = getList().get(i);
if (expected != actual && (expected == null || !expected.equals(actual))) {
fail("mismatch at index " + i + ": " + reportContext(expectedList));
}
}
}
Reported by PMD.
Line: 60
for (int i = 0; i < expectedList.size(); i++) {
E expected = expectedList.get(i);
E actual = getList().get(i);
if (expected != actual && (expected == null || !expected.equals(actual))) {
fail("mismatch at index " + i + ": " + reportContext(expectedList));
}
}
}
Reported by PMD.
Line: 60
for (int i = 0; i < expectedList.size(); i++) {
E expected = expectedList.get(i);
E actual = getList().get(i);
if (expected != actual && (expected == null || !expected.equals(actual))) {
fail("mismatch at index " + i + ": " + reportContext(expectedList));
}
}
}
Reported by PMD.
guava-tests/test/com/google/common/graph/PackageSanityTests.java
5 issues
Line: 61
setDefault(EndpointPair.class, EndpointPair.ordered("A", "B"));
}
@Override
public void testNulls() throws Exception {
try {
super.testNulls();
} catch (AssertionFailedError e) {
assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
Reported by PMD.
Line: 66
try {
super.testNulls();
} catch (AssertionFailedError e) {
assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
.that(e)
.hasCauseThat()
.hasMessageThat()
.contains(ERROR_ELEMENT_NOT_IN_GRAPH);
}
Reported by PMD.
Line: 66
try {
super.testNulls();
} catch (AssertionFailedError e) {
assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
.that(e)
.hasCauseThat()
.hasMessageThat()
.contains(ERROR_ELEMENT_NOT_IN_GRAPH);
}
Reported by PMD.
Line: 66
try {
super.testNulls();
} catch (AssertionFailedError e) {
assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
.that(e)
.hasCauseThat()
.hasMessageThat()
.contains(ERROR_ELEMENT_NOT_IN_GRAPH);
}
Reported by PMD.
Line: 66
try {
super.testNulls();
} catch (AssertionFailedError e) {
assertWithMessage("Method did not throw null pointer OR element not in graph exception.")
.that(e)
.hasCauseThat()
.hasMessageThat()
.contains(ERROR_ELEMENT_NOT_IN_GRAPH);
}
Reported by PMD.