The following issues were found
guava-gwt/test/com/google/common/GwtTestSuite.java
5 issues
Line: 33
* Runs all _gwt tests. Grouping them into a suite is much faster than running each as a one-test
* "suite," as the per-suite setup is expensive.
*/
public class GwtTestSuite extends TestCase {
public static Test suite() throws IOException {
GWTTestSuite suite = new GWTTestSuite();
for (ClassInfo info
: ClassPath.from(GwtTestSuite.class.getClassLoader()).getTopLevelClasses()) {
if (info.getName().endsWith("_gwt")) {
Reported by PMD.
Line: 34
* "suite," as the per-suite setup is expensive.
*/
public class GwtTestSuite extends TestCase {
public static Test suite() throws IOException {
GWTTestSuite suite = new GWTTestSuite();
for (ClassInfo info
: ClassPath.from(GwtTestSuite.class.getClassLoader()).getTopLevelClasses()) {
if (info.getName().endsWith("_gwt")) {
Class<?> clazz = info.load();
Reported by PMD.
Line: 37
public static Test suite() throws IOException {
GWTTestSuite suite = new GWTTestSuite();
for (ClassInfo info
: ClassPath.from(GwtTestSuite.class.getClassLoader()).getTopLevelClasses()) {
if (info.getName().endsWith("_gwt")) {
Class<?> clazz = info.load();
// TODO(cpovirk): why does asSubclass() throw? Is it something about ClassLoaders?
@SuppressWarnings("unchecked")
Class<? extends GWTTestCase> cast = (Class<? extends GWTTestCase>) clazz;
Reported by PMD.
Line: 37
public static Test suite() throws IOException {
GWTTestSuite suite = new GWTTestSuite();
for (ClassInfo info
: ClassPath.from(GwtTestSuite.class.getClassLoader()).getTopLevelClasses()) {
if (info.getName().endsWith("_gwt")) {
Class<?> clazz = info.load();
// TODO(cpovirk): why does asSubclass() throw? Is it something about ClassLoaders?
@SuppressWarnings("unchecked")
Class<? extends GWTTestCase> cast = (Class<? extends GWTTestCase>) clazz;
Reported by PMD.
Line: 38
GWTTestSuite suite = new GWTTestSuite();
for (ClassInfo info
: ClassPath.from(GwtTestSuite.class.getClassLoader()).getTopLevelClasses()) {
if (info.getName().endsWith("_gwt")) {
Class<?> clazz = info.load();
// TODO(cpovirk): why does asSubclass() throw? Is it something about ClassLoaders?
@SuppressWarnings("unchecked")
Class<? extends GWTTestCase> cast = (Class<? extends GWTTestCase>) clazz;
suite.addTestSuite(cast);
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
5 issues
Line: 59
checkNotNull(timeoutUnit);
try {
return callable.call();
} catch (RuntimeException e) {
throw new UncheckedExecutionException(e);
} catch (Exception e) {
throw new ExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
Reported by PMD.
Line: 61
return callable.call();
} catch (RuntimeException e) {
throw new UncheckedExecutionException(e);
} catch (Exception e) {
throw new ExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
} catch (Throwable e) {
// It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend
Reported by PMD.
Line: 65
throw new ExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
} catch (Throwable e) {
// It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend
// Exception, so we'll treat it like an Exception.
throw new ExecutionException(e);
}
}
Reported by PMD.
Line: 85
checkNotNull(timeoutUnit);
try {
runnable.run();
} catch (RuntimeException e) {
throw new UncheckedExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
} catch (Throwable e) {
// It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend
Reported by PMD.
Line: 89
throw new UncheckedExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
} catch (Throwable e) {
// It's a non-Error, non-Exception Throwable. Such classes are usually intended to extend
// Exception, so we'll treat it like a RuntimeException.
throw new UncheckedExecutionException(e);
}
}
Reported by PMD.
android/guava/src/com/google/common/io/LineBuffer.java
5 issues
Line: 36
@ElementTypesAreNonnullByDefault
abstract class LineBuffer {
/** Holds partial line contents. */
private StringBuilder line = new StringBuilder();
/** Whether a line ending with a CR is pending processing. */
private boolean sawReturn;
/**
* Process additional characters from the stream. When a line separator is found the contents of
Reported by PMD.
Line: 36
@ElementTypesAreNonnullByDefault
abstract class LineBuffer {
/** Holds partial line contents. */
private StringBuilder line = new StringBuilder();
/** Whether a line ending with a CR is pending processing. */
private boolean sawReturn;
/**
* Process additional characters from the stream. When a line separator is found the contents of
Reported by PMD.
Line: 38
/** Holds partial line contents. */
private StringBuilder line = new StringBuilder();
/** Whether a line ending with a CR is pending processing. */
private boolean sawReturn;
/**
* Process additional characters from the stream. When a line separator is found the contents of
* the line and the line separator itself are passed to the abstract {@link #handleLine} method.
*
Reported by PMD.
Line: 54
int pos = off;
if (sawReturn && len > 0) {
// Last call to add ended with a CR; we can handle the line now.
if (finishLine(cbuf[pos] == '\n')) {
pos++;
}
}
int start = pos;
Reported by PMD.
Line: 66
line.append(cbuf, start, pos - start);
sawReturn = true;
if (pos + 1 < end) {
if (finishLine(cbuf[pos + 1] == '\n')) {
pos++;
}
}
start = pos + 1;
break;
Reported by PMD.
android/guava/src/com/google/common/io/MultiInputStream.java
5 issues
Line: 36
@ElementTypesAreNonnullByDefault
final class MultiInputStream extends InputStream {
private Iterator<? extends ByteSource> it;
@CheckForNull private InputStream in;
/**
* Creates a new instance.
*
Reported by PMD.
Line: 36
@ElementTypesAreNonnullByDefault
final class MultiInputStream extends InputStream {
private Iterator<? extends ByteSource> it;
@CheckForNull private InputStream in;
/**
* Creates a new instance.
*
Reported by PMD.
Line: 37
final class MultiInputStream extends InputStream {
private Iterator<? extends ByteSource> it;
@CheckForNull private InputStream in;
/**
* Creates a new instance.
*
* @param it an iterator of I/O suppliers that will provide each substream
Reported by PMD.
Line: 55
try {
in.close();
} finally {
in = null;
}
}
}
/** Closes the current input stream and opens the next one, if any. */
Reported by PMD.
Line: 64
private void advance() throws IOException {
close();
if (it.hasNext()) {
in = it.next().openStream();
}
}
@Override
public int available() throws IOException {
Reported by PMD.
android/guava/src/com/google/common/io/MultiReader.java
5 issues
Line: 40
MultiReader(Iterator<? extends CharSource> readers) throws IOException {
this.it = readers;
advance();
}
/** Closes the current reader and opens the next one, if any. */
private void advance() throws IOException {
close();
Reported by PMD.
Line: 35
@GwtIncompatible
@ElementTypesAreNonnullByDefault
class MultiReader extends Reader {
private final Iterator<? extends CharSource> it;
@CheckForNull private Reader current;
MultiReader(Iterator<? extends CharSource> readers) throws IOException {
this.it = readers;
advance();
Reported by PMD.
Line: 36
@ElementTypesAreNonnullByDefault
class MultiReader extends Reader {
private final Iterator<? extends CharSource> it;
@CheckForNull private Reader current;
MultiReader(Iterator<? extends CharSource> readers) throws IOException {
this.it = readers;
advance();
}
Reported by PMD.
Line: 47
private void advance() throws IOException {
close();
if (it.hasNext()) {
current = it.next().openStream();
}
}
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
Reported by PMD.
Line: 91
try {
current.close();
} finally {
current = null;
}
}
}
}
Reported by PMD.
android/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java
5 issues
Line: 49
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class AbstractMapBasedMultiset<E extends @Nullable Object> extends AbstractMultiset<E>
implements Serializable {
transient ObjectCountHashMap<E> backingMap;
transient long size;
AbstractMapBasedMultiset(int distinctElements) {
Reported by PMD.
Line: 52
implements Serializable {
transient ObjectCountHashMap<E> backingMap;
transient long size;
AbstractMapBasedMultiset(int distinctElements) {
backingMap = newBackingMap(distinctElements);
}
Reported by PMD.
Line: 167
* enough it's not especially worth it.
*/
abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
int entryIndex = backingMap.firstIndex();
int toRemove = -1;
int expectedModCount = backingMap.modCount;
@ParametricNullness
abstract T result(int entryIndex);
Reported by PMD.
Line: 168
*/
abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
int entryIndex = backingMap.firstIndex();
int toRemove = -1;
int expectedModCount = backingMap.modCount;
@ParametricNullness
abstract T result(int entryIndex);
Reported by PMD.
Line: 169
abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
int entryIndex = backingMap.firstIndex();
int toRemove = -1;
int expectedModCount = backingMap.modCount;
@ParametricNullness
abstract T result(int entryIndex);
private void checkForConcurrentModification() {
Reported by PMD.
android/guava/src/com/google/common/collect/DiscreteDomain.java
5 issues
Line: 82
@Override
Integer offset(Integer origin, long distance) {
checkNonnegative(distance, "distance");
return Ints.checkedCast(origin.longValue() + distance);
}
@Override
public long distance(Integer start, Integer end) {
Reported by PMD.
Line: 225
@Override
public long distance(BigInteger start, BigInteger end) {
return end.subtract(start).max(MIN_LONG).min(MAX_LONG).longValue();
}
private Object readResolve() {
return INSTANCE;
}
Reported by PMD.
Line: 225
@Override
public long distance(BigInteger start, BigInteger end) {
return end.subtract(start).max(MIN_LONG).min(MAX_LONG).longValue();
}
private Object readResolve() {
return INSTANCE;
}
Reported by PMD.
Line: 225
@Override
public long distance(BigInteger start, BigInteger end) {
return end.subtract(start).max(MIN_LONG).min(MAX_LONG).longValue();
}
private Object readResolve() {
return INSTANCE;
}
Reported by PMD.
Line: 240
private static final long serialVersionUID = 0;
}
final boolean supportsFastOffset;
/** Constructor for use by subclasses. */
protected DiscreteDomain() {
this(false);
}
Reported by PMD.
android/guava/src/com/google/common/collect/EmptyContiguousSet.java
5 issues
Line: 31
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class EmptyContiguousSet<C extends Comparable> extends ContiguousSet<C> {
EmptyContiguousSet(DiscreteDomain<C> domain) {
super(domain);
}
@Override
Reported by PMD.
Line: 31
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
final class EmptyContiguousSet<C extends Comparable> extends ContiguousSet<C> {
EmptyContiguousSet(DiscreteDomain<C> domain) {
super(domain);
}
@Override
Reported by PMD.
Line: 128
public boolean equals(@CheckForNull Object object) {
if (object instanceof Set) {
Set<?> that = (Set<?>) object;
return that.isEmpty();
}
return false;
}
@GwtIncompatible // not used in GWT
Reported by PMD.
Line: 146
@GwtIncompatible // serialization
private static final class SerializedForm<C extends Comparable> implements Serializable {
private final DiscreteDomain<C> domain;
private SerializedForm(DiscreteDomain<C> domain) {
this.domain = domain;
}
Reported by PMD.
Line: 168
@GwtIncompatible // NavigableSet
@Override
ImmutableSortedSet<C> createDescendingSet() {
return ImmutableSortedSet.emptySet(Ordering.natural().reverse());
}
}
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTester.java
5 issues
Line: 44
DELEGATE_METHOD = ForwardingObject.class.getDeclaredMethod("delegate");
DELEGATE_METHOD.setAccessible(true);
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
Reported by PMD.
Line: 69
T stubber = doReturn(delegate).when(mock);
DELEGATE_METHOD.invoke(stubber);
} catch (Exception e) {
throw new RuntimeException(e);
}
return mock;
}
});
}
Reported by PMD.
Line: 35
*
* @author Ben Yu
*/
final class ForwardingObjectTester {
private static final Method DELEGATE_METHOD;
static {
try {
Reported by PMD.
Line: 66
public T apply(Object delegate) {
T mock = mock(forwarderClass, CALLS_REAL_METHODS.get());
try {
T stubber = doReturn(delegate).when(mock);
DELEGATE_METHOD.invoke(stubber);
} catch (Exception e) {
throw new RuntimeException(e);
}
return mock;
Reported by PMD.
Line: 68
try {
T stubber = doReturn(delegate).when(mock);
DELEGATE_METHOD.invoke(stubber);
} catch (Exception e) {
throw new RuntimeException(e);
}
return mock;
}
});
Reported by PMD.
guava-tests/test/com/google/common/math/MathBenchmarking.java
5 issues
Line: 31
*
* @author Louis Wasserman
*/
final class MathBenchmarking {
static final int ARRAY_SIZE = 0x10000;
static final int ARRAY_MASK = 0x0ffff;
static final Random RANDOM_SOURCE = new Random(314159265358979L);
static final int MAX_EXPONENT = 100;
Reported by PMD.
Line: 86
BigInteger result;
do {
result = randomNonNegativeBigInteger(numBits);
} while (result.signum() == 0);
return result;
}
/**
* Generates a number in [0, 2^numBits) with an exponential distribution. The floor of the log2 of
Reported by PMD.
Line: 110
*/
static BigInteger randomNonZeroBigInteger(int numBits) {
BigInteger result = randomPositiveBigInteger(numBits);
return RANDOM_SOURCE.nextBoolean() ? result : result.negate();
}
/**
* Chooses a number in (-2^numBits, 2^numBits) at random, with density concentrated in numbers of
* lower magnitude.
Reported by PMD.
Line: 122
if (RANDOM_SOURCE.nextBoolean()) {
return randomNonNegativeBigInteger(numBits);
}
BigInteger neg = randomNonNegativeBigInteger(numBits).negate();
if (neg.signum() != 0) {
return neg;
}
}
}
Reported by PMD.
Line: 123
return randomNonNegativeBigInteger(numBits);
}
BigInteger neg = randomNonNegativeBigInteger(numBits).negate();
if (neg.signum() != 0) {
return neg;
}
}
}
Reported by PMD.