The following issues were found
guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
2 issues
Line: 28
*/
public class CountingOutputStreamTest extends IoTestCase {
public void testCount() throws Exception {
int written = 0;
ByteArrayOutputStream out = new ByteArrayOutputStream();
CountingOutputStream counter = new CountingOutputStream(out);
assertEquals(written, out.size());
assertEquals(written, counter.getCount());
Reported by PMD.
Line: 28
*/
public class CountingOutputStreamTest extends IoTestCase {
public void testCount() throws Exception {
int written = 0;
ByteArrayOutputStream out = new ByteArrayOutputStream();
CountingOutputStream counter = new CountingOutputStream(out);
assertEquals(written, out.size());
assertEquals(written, counter.getCount());
Reported by PMD.
guava-tests/test/com/google/common/eventbus/outside/OutsideEventBusTest.java
2 issues
Line: 37
* That is, even if exactly the same method works from inside the common.eventbus package tests,
* it can fail here.
*/
public void testAnonymous() {
final AtomicReference<String> holder = new AtomicReference<>();
final AtomicInteger deliveries = new AtomicInteger();
EventBus bus = new EventBus();
bus.register(
new Object() {
Reported by PMD.
Line: 37
* That is, even if exactly the same method works from inside the common.eventbus package tests,
* it can fail here.
*/
public void testAnonymous() {
final AtomicReference<String> holder = new AtomicReference<>();
final AtomicInteger deliveries = new AtomicInteger();
EventBus bus = new EventBus();
bus.register(
new Object() {
Reported by PMD.
guava-tests/test/com/google/common/cache/TestingWeighers.java
2 issues
Line: 22
*
* @author Charles Fry
*/
public class TestingWeighers {
/** Returns a {@link Weigher} that returns the given {@code constant} for every request. */
static Weigher<Object, Object> constantWeigher(int constant) {
return new ConstantWeigher(constant);
}
Reported by PMD.
Line: 40
}
static final class ConstantWeigher implements Weigher<Object, Object> {
private final int constant;
ConstantWeigher(int constant) {
this.constant = constant;
}
Reported by PMD.
guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java
2 issues
Line: 30
*
* @author Kevin Bourrillion
*/
public class OpenJdk6Tests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(OpenJdk6SetTests.suite());
suite.addTest(OpenJdk6ListTests.suite());
suite.addTest(OpenJdk6QueueTests.suite());
Reported by PMD.
Line: 31
* @author Kevin Bourrillion
*/
public class OpenJdk6Tests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(OpenJdk6SetTests.suite());
suite.addTest(OpenJdk6ListTests.suite());
suite.addTest(OpenJdk6QueueTests.suite());
suite.addTest(OpenJdk6MapTests.suite());
Reported by PMD.
guava-tests/test/com/google/common/collect/BenchmarkHelpers.java
2 issues
Line: 256
@Override
public <K extends Comparable<K>, V> SortedMap<K, V> create(Map<K, V> map) {
SortedMap<K, V> result = Maps.newTreeMap();
result.putAll(map);
return result;
}
},
ConcurrentSkipListImpl {
@Override
Reported by PMD.
Line: 356
<R extends Comparable<R>, C extends Comparable<C>, V> Table<R, C, V> create(
Table<R, C, V> contents) {
Table<R, C, V> table = TreeBasedTable.create();
table.putAll(contents);
return table;
}
},
ArrayTableImpl {
@Override
Reported by PMD.
guava-tests/test/com/google/common/collect/RegularImmutableAsListTest.java
2 issues
Line: 31
* RegularImmutableAsList should assume its input is null-free without checking, because it only
* gets invoked from other immutable collections.
*/
public void testDoesntCheckForNull() {
ImmutableSet<Integer> set = ImmutableSet.of(1, 2, 3);
new RegularImmutableAsList<Integer>(set, new Object[] {null, null, null});
// shouldn't throw!
}
}
Reported by PMD.
Line: 31
* RegularImmutableAsList should assume its input is null-free without checking, because it only
* gets invoked from other immutable collections.
*/
public void testDoesntCheckForNull() {
ImmutableSet<Integer> set = ImmutableSet.of(1, 2, 3);
new RegularImmutableAsList<Integer>(set, new Object[] {null, null, null});
// shouldn't throw!
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/SpecialRandom.java
2 issues
Line: 34
return (s.length() == 0) ? new SpecialRandom() : new SpecialRandom(Long.parseLong(s));
}
private final boolean hasSeed;
private final long seed;
public SpecialRandom() {
this.hasSeed = false;
this.seed = 0;
Reported by PMD.
Line: 35
}
private final boolean hasSeed;
private final long seed;
public SpecialRandom() {
this.hasSeed = false;
this.seed = 0;
}
Reported by PMD.
guava-tests/benchmark/com/google/common/eventbus/EventBusBenchmark.java
2 issues
Line: 29
*/
public class EventBusBenchmark {
private EventBus eventBus;
@BeforeExperiment
void setUp() {
eventBus = new EventBus("for benchmarking purposes");
eventBus.register(this);
Reported by PMD.
Line: 31
private EventBus eventBus;
@BeforeExperiment
void setUp() {
eventBus = new EventBus("for benchmarking purposes");
eventBus.register(this);
}
Reported by PMD.
guava-tests/test/com/google/common/math/TestPlatform.java
2 issues
Line: 23
/** @author Chris Povirk */
@GwtCompatible(emulated = true)
class TestPlatform {
static boolean intsCanGoOutOfRange() {
return false;
}
static boolean isAndroid() {
Reported by PMD.
Line: 29
}
static boolean isAndroid() {
return System.getProperty("java.runtime.name").contains("Android");
}
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapSizeTester.java
2 issues
Line: 32
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapSizeTester<K, V> extends AbstractMapTester<K, V> {
public void testSize() {
assertEquals("size():", getNumElements(), getMap().size());
}
}
Reported by PMD.
Line: 33
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapSizeTester<K, V> extends AbstractMapTester<K, V> {
public void testSize() {
assertEquals("size():", getNumElements(), getMap().size());
}
}
Reported by PMD.