The following issues were found
android/guava/src/com/google/common/util/concurrent/RateLimiter.java
3 issues
Line: 96
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class RateLimiter {
/**
* Creates a {@code RateLimiter} with the specified stable throughput, given as "permits per
* second" (commonly referred to as <i>QPS</i>, queries per second).
*
* <p>The returned {@code RateLimiter} ensures that on average no more than {@code
Reported by PMD.
Line: 185
* The underlying timer; used both to measure elapsed time and sleep as necessary. A separate
* object to facilitate testing.
*/
private final SleepingStopwatch stopwatch;
// Can't be initialized in the constructor because mocks don't call the constructor.
@CheckForNull private volatile Object mutexDoNotUseDirectly;
private Object mutex() {
Reported by PMD.
Line: 188
private final SleepingStopwatch stopwatch;
// Can't be initialized in the constructor because mocks don't call the constructor.
@CheckForNull private volatile Object mutexDoNotUseDirectly;
private Object mutex() {
Object mutex = mutexDoNotUseDirectly;
if (mutex == null) {
synchronized (this) {
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableEnumSet.java
3 issues
Line: 82
}
@Override
public boolean containsAll(Collection<?> collection) {
if (collection instanceof ImmutableEnumSet<?>) {
collection = ((ImmutableEnumSet<?>) collection).delegate;
}
return delegate.containsAll(collection);
}
Reported by PMD.
Line: 95
}
@Override
public boolean equals(@CheckForNull Object object) {
if (object == this) {
return true;
}
if (object instanceof ImmutableEnumSet) {
object = ((ImmutableEnumSet<?>) object).delegate;
Reported by PMD.
Line: 110
return true;
}
@LazyInit private transient int hashCode;
@Override
public int hashCode() {
int result = hashCode;
return (result == 0) ? hashCode = delegate.hashCode() : result;
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
3 issues
Line: 31
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
/**
* Not supported. Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety,
* instead. This method exists only to hide {@link ImmutableMap#builder} from consumers of {@code
* ImmutableSortedMap}.
*
Reported by PMD.
Line: 82
* @deprecated <b>Pass keys of type {@code Comparable} to use {@link
* ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
throw new UnsupportedOperationException();
}
Reported by PMD.
Line: 131
*/
@DoNotCall("Pass keys of type Comparable")
@Deprecated
public static <K, V> ImmutableSortedMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
throw new UnsupportedOperationException();
}
// No copyOf() fauxveride; see ImmutableSortedSetFauxverideShim.
Reported by PMD.
android/guava/src/com/google/common/graph/AbstractGraphBuilder.java
3 issues
Line: 27
* @author James Sexton
*/
@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
final boolean directed;
boolean allowsSelfLoops = false;
ElementOrder<N> nodeOrder = ElementOrder.insertion();
ElementOrder<N> incidentEdgeOrder = ElementOrder.unordered();
Reported by PMD.
Line: 28
*/
@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
final boolean directed;
boolean allowsSelfLoops = false;
ElementOrder<N> nodeOrder = ElementOrder.insertion();
ElementOrder<N> incidentEdgeOrder = ElementOrder.unordered();
Optional<Integer> expectedNodeCount = Optional.absent();
Reported by PMD.
Line: 29
@ElementTypesAreNonnullByDefault
abstract class AbstractGraphBuilder<N> {
final boolean directed;
boolean allowsSelfLoops = false;
ElementOrder<N> nodeOrder = ElementOrder.insertion();
ElementOrder<N> incidentEdgeOrder = ElementOrder.unordered();
Optional<Integer> expectedNodeCount = Optional.absent();
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
3 issues
Line: 39
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
/**
* Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better
* type-safety, instead. This method exists only to hide {@link ImmutableMultiset#builder} from
* consumers of {@code ImmutableSortedMultiset}.
*
Reported by PMD.
Line: 63
* @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
* ImmutableSortedMultiset#of(Comparable)}.</b>
*/
@DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> of(E element) {
throw new UnsupportedOperationException();
}
Reported by PMD.
Line: 158
*/
@DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
@Deprecated
public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) {
throw new UnsupportedOperationException();
}
/*
* We would like to include an unsupported "<E> copyOf(Iterable<E>)" here, providing only the
Reported by PMD.
android/guava/src/com/google/common/eventbus/DeadEvent.java
3 issues
Line: 69
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString();
}
}
Reported by PMD.
Line: 69
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString();
}
}
Reported by PMD.
Line: 69
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("source", source).add("event", event).toString();
}
}
Reported by PMD.
android/guava/src/com/google/common/io/CountingInputStream.java
3 issues
Line: 36
@ElementTypesAreNonnullByDefault
public final class CountingInputStream extends FilterInputStream {
private long count;
private long mark = -1;
/**
* Wraps another input stream, counting the number of bytes read.
*
Reported by PMD.
Line: 37
public final class CountingInputStream extends FilterInputStream {
private long count;
private long mark = -1;
/**
* Wraps another input stream, counting the number of bytes read.
*
* @param in the input stream to be wrapped
Reported by PMD.
Line: 37
public final class CountingInputStream extends FilterInputStream {
private long count;
private long mark = -1;
/**
* Wraps another input stream, counting the number of bytes read.
*
* @param in the input stream to be wrapped
Reported by PMD.
android/guava/src/com/google/common/math/MathPreconditions.java
3 issues
Line: 30
@GwtCompatible
@CanIgnoreReturnValue
@ElementTypesAreNonnullByDefault
final class MathPreconditions {
static int checkPositive(String role, int x) {
if (x <= 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be > 0");
}
return x;
Reported by PMD.
Line: 54
static int checkNonNegative(String role, int x) {
if (x < 0) {
throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
}
return x;
}
static long checkNonNegative(String role, long x) {
Reported by PMD.
Line: 74
}
static double checkNonNegative(String role, double x) {
if (!(x >= 0)) { // not x < 0, to work with NaN.
throw new IllegalArgumentException(role + " (" + x + ") must be >= 0");
}
return x;
}
Reported by PMD.
android/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.
android/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.