The following issues were found
guava-tests/test/com/google/common/eventbus/PackageSanityTests.java
3 issues
Line: 31
public class PackageSanityTests extends AbstractPackageSanityTests {
public PackageSanityTests() throws Exception {
DummySubscriber dummySubscriber = new DummySubscriber();
setDefault(Subscriber.class, dummySubscriber.toSubscriber());
setDefault(Method.class, DummySubscriber.subscriberMethod());
setDefault(SubscriberExceptionContext.class, dummySubscriber.toContext());
setDefault(Dispatcher.class, Dispatcher.immediate());
Reported by PMD.
Line: 41
private static class DummySubscriber {
private final EventBus eventBus = new EventBus();
@Subscribe
public void handle(@Nullable Object anything) {}
Subscriber toSubscriber() throws Exception {
Reported by PMD.
Line: 46
@Subscribe
public void handle(@Nullable Object anything) {}
Subscriber toSubscriber() throws Exception {
return Subscriber.create(eventBus, this, subscriberMethod());
}
SubscriberExceptionContext toContext() {
return new SubscriberExceptionContext(eventBus, new Object(), this, subscriberMethod());
Reported by PMD.
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.
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.
guava-tests/test/com/google/common/escape/CharEscaperBuilderTest.java
3 issues
Line: 23
public class CharEscaperBuilderTest extends TestCase {
public void testAddEscapes() {
char[] cs = {'a', 'b', 'c'};
CharEscaperBuilder builder = new CharEscaperBuilder().addEscapes(cs, "Z");
Escaper escaper = builder.toEscaper();
assertEquals("ZZZdef", escaper.escape("abcdef"));
}
Reported by PMD.
Line: 27
char[] cs = {'a', 'b', 'c'};
CharEscaperBuilder builder = new CharEscaperBuilder().addEscapes(cs, "Z");
Escaper escaper = builder.toEscaper();
assertEquals("ZZZdef", escaper.escape("abcdef"));
}
}
Reported by PMD.
Line: 27
char[] cs = {'a', 'b', 'c'};
CharEscaperBuilder builder = new CharEscaperBuilder().addEscapes(cs, "Z");
Escaper escaper = builder.toEscaper();
assertEquals("ZZZdef", escaper.escape("abcdef"));
}
}
Reported by PMD.
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.
guava-testlib/src/com/google/common/collect/testing/testers/SetRemoveTester.java
3 issues
Line: 36
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetRemoveTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
getSet().remove(e0());
assertFalse(
"After remove(present) a set should not contain the removed element.",
Reported by PMD.
Line: 39
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
getSet().remove(e0());
assertFalse(
"After remove(present) a set should not contain the removed element.",
getSet().contains(e0()));
}
}
Reported by PMD.
Line: 42
getSet().remove(e0());
assertFalse(
"After remove(present) a set should not contain the removed element.",
getSet().contains(e0()));
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/ImmutableSetMultimapAsMapImplementsMapTest.java
3 issues
Line: 39
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return ImmutableSetMultimap.<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 ImmutableSetMultimap.<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 ImmutableSetMultimap.copyOf(delegate).asMap();
}
}
Reported by PMD.
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.
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.
guava-tests/test/com/google/common/io/TestByteSink.java
3 issues
Line: 32
public class TestByteSink extends ByteSink implements TestStreamSupplier {
private final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
private final ImmutableSet<TestOption> options;
private boolean outputStreamOpened;
private boolean outputStreamClosed;
public TestByteSink(TestOption... options) {
Reported by PMD.
Line: 34
private final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
private final ImmutableSet<TestOption> options;
private boolean outputStreamOpened;
private boolean outputStreamClosed;
public TestByteSink(TestOption... options) {
this.options = ImmutableSet.copyOf(options);
}
Reported by PMD.
Line: 35
private final ImmutableSet<TestOption> options;
private boolean outputStreamOpened;
private boolean outputStreamClosed;
public TestByteSink(TestOption... options) {
this.options = ImmutableSet.copyOf(options);
}
Reported by PMD.