The following issues were found
guava-testlib/src/com/google/common/collect/testing/features/ConflictingRequirementsException.java
4 issues
Line: 29
*/
@GwtCompatible
public class ConflictingRequirementsException extends Exception {
private Set<Feature<?>> conflicts;
private Object source;
public ConflictingRequirementsException(
String message, Set<Feature<?>> conflicts, Object source) {
super(message);
Reported by PMD.
Line: 29
*/
@GwtCompatible
public class ConflictingRequirementsException extends Exception {
private Set<Feature<?>> conflicts;
private Object source;
public ConflictingRequirementsException(
String message, Set<Feature<?>> conflicts, Object source) {
super(message);
Reported by PMD.
Line: 30
@GwtCompatible
public class ConflictingRequirementsException extends Exception {
private Set<Feature<?>> conflicts;
private Object source;
public ConflictingRequirementsException(
String message, Set<Feature<?>> conflicts, Object source) {
super(message);
this.conflicts = conflicts;
Reported by PMD.
Line: 30
@GwtCompatible
public class ConflictingRequirementsException extends Exception {
private Set<Feature<?>> conflicts;
private Object source;
public ConflictingRequirementsException(
String message, Set<Feature<?>> conflicts, Object source) {
super(message);
this.conflicts = conflicts;
Reported by PMD.
guava/src/com/google/common/primitives/ParseRequest.java
4 issues
Line: 23
@GwtCompatible
@ElementTypesAreNonnullByDefault
final class ParseRequest {
final String rawValue;
final int radix;
private ParseRequest(String rawValue, int radix) {
this.rawValue = rawValue;
this.radix = radix;
Reported by PMD.
Line: 24
@ElementTypesAreNonnullByDefault
final class ParseRequest {
final String rawValue;
final int radix;
private ParseRequest(String rawValue, int radix) {
this.rawValue = rawValue;
this.radix = radix;
}
Reported by PMD.
Line: 43
if (stringValue.startsWith("0x") || stringValue.startsWith("0X")) {
rawValue = stringValue.substring(2);
radix = 16;
} else if (firstChar == '#') {
rawValue = stringValue.substring(1);
radix = 16;
} else if (firstChar == '0' && stringValue.length() > 1) {
rawValue = stringValue.substring(1);
radix = 8;
Reported by PMD.
Line: 39
// Handle radix specifier if present
String rawValue;
int radix;
char firstChar = stringValue.charAt(0);
if (stringValue.startsWith("0x") || stringValue.startsWith("0X")) {
rawValue = stringValue.substring(2);
radix = 16;
} else if (firstChar == '#') {
rawValue = stringValue.substring(1);
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/ForwardingObjectTesterTest.java
4 issues
Line: 29
*/
public class ForwardingObjectTesterTest extends TestCase {
public void testFailsToForward() {
try {
ForwardingObjectTester.testForwardingObject(FailToForward.class);
} catch (AssertionError | UnsupportedOperationException expected) {
// UnsupportedOperationException is what we see on Android.
return;
Reported by PMD.
Line: 39
fail("Should have thrown");
}
@AndroidIncompatible // TODO(cpovirk): java.lang.IllegalAccessError: superclass not accessible
public void testSuccessfulForwarding() {
ForwardingObjectTester.testForwardingObject(ForwardToDelegate.class);
}
private abstract static class FailToForward extends ForwardingObject implements Runnable {
Reported by PMD.
Line: 40
}
@AndroidIncompatible // TODO(cpovirk): java.lang.IllegalAccessError: superclass not accessible
public void testSuccessfulForwarding() {
ForwardingObjectTester.testForwardingObject(ForwardToDelegate.class);
}
private abstract static class FailToForward extends ForwardingObject implements Runnable {
@Override
Reported by PMD.
Line: 52
private abstract static class ForwardToDelegate extends ForwardingObject implements Runnable {
@Override
public void run() {
delegate().run();
}
@Override
protected abstract Runnable delegate();
}
Reported by PMD.
guava/src/com/google/common/collect/EvictingQueue.java
4 issues
Line: 51
@ElementTypesAreNonnullByDefault
public final class EvictingQueue<E> extends ForwardingQueue<E> implements Serializable {
private final Queue<E> delegate;
@VisibleForTesting final int maxSize;
private EvictingQueue(int maxSize) {
checkArgument(maxSize >= 0, "maxSize (%s) must >= 0", maxSize);
Reported by PMD.
Line: 51
@ElementTypesAreNonnullByDefault
public final class EvictingQueue<E> extends ForwardingQueue<E> implements Serializable {
private final Queue<E> delegate;
@VisibleForTesting final int maxSize;
private EvictingQueue(int maxSize) {
checkArgument(maxSize >= 0, "maxSize (%s) must >= 0", maxSize);
Reported by PMD.
Line: 53
private final Queue<E> delegate;
@VisibleForTesting final int maxSize;
private EvictingQueue(int maxSize) {
checkArgument(maxSize >= 0, "maxSize (%s) must >= 0", maxSize);
this.delegate = new ArrayDeque<E>(maxSize);
this.maxSize = maxSize;
Reported by PMD.
Line: 130
}
@Override
public Object[] toArray() {
/*
* If we could, we'd declare the no-arg `Collection.toArray()` to return "Object[] but elements
* have the same nullness as E." Since we can't, we declare it to return nullable elements, and
* we can override it in our non-null-guaranteeing subtypes to present a better signature to
* their users.
Reported by PMD.
guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java
4 issues
Line: 46
@ElementTypesAreNonnullByDefault
abstract class AbstractDirectedNetworkConnections<N, E> implements NetworkConnections<N, E> {
/** Keys are edges incoming to the origin node, values are the source node. */
final Map<E, N> inEdgeMap;
/** Keys are edges outgoing from the origin node, values are the target node. */
final Map<E, N> outEdgeMap;
private int selfLoopCount;
Reported by PMD.
Line: 49
final Map<E, N> inEdgeMap;
/** Keys are edges outgoing from the origin node, values are the target node. */
final Map<E, N> outEdgeMap;
private int selfLoopCount;
AbstractDirectedNetworkConnections(Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
this.inEdgeMap = checkNotNull(inEdgeMap);
Reported by PMD.
Line: 51
/** Keys are edges outgoing from the origin node, values are the target node. */
final Map<E, N> outEdgeMap;
private int selfLoopCount;
AbstractDirectedNetworkConnections(Map<E, N> inEdgeMap, Map<E, N> outEdgeMap, int selfLoopCount) {
this.inEdgeMap = checkNotNull(inEdgeMap);
this.outEdgeMap = checkNotNull(outEdgeMap);
this.selfLoopCount = checkNonNegative(selfLoopCount);
Reported by PMD.
Line: 74
(selfLoopCount == 0)
? Iterables.concat(inEdgeMap.keySet(), outEdgeMap.keySet())
: Sets.union(inEdgeMap.keySet(), outEdgeMap.keySet());
return Iterators.unmodifiableIterator(incidentEdges.iterator());
}
@Override
public int size() {
return IntMath.saturatedAdd(inEdgeMap.size(), outEdgeMap.size() - selfLoopCount);
Reported by PMD.
guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
4 issues
Line: 42
static final ImmutableSortedMultiset<Comparable> NATURAL_EMPTY_MULTISET =
new RegularImmutableSortedMultiset<>(Ordering.natural());
@VisibleForTesting final transient RegularImmutableSortedSet<E> elementSet;
private final transient long[] cumulativeCounts;
private final transient int offset;
private final transient int length;
RegularImmutableSortedMultiset(Comparator<? super E> comparator) {
Reported by PMD.
Line: 55
}
RegularImmutableSortedMultiset(
RegularImmutableSortedSet<E> elementSet, long[] cumulativeCounts, int offset, int length) {
this.elementSet = elementSet;
this.cumulativeCounts = cumulativeCounts;
this.offset = offset;
this.length = length;
}
Reported by PMD.
Line: 68
@Override
Entry<E> getEntry(int index) {
return Multisets.immutableEntry(elementSet.asList().get(index), getCount(index));
}
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
checkNotNull(action);
Reported by PMD.
Line: 75
public void forEachEntry(ObjIntConsumer<? super E> action) {
checkNotNull(action);
for (int i = 0; i < length; i++) {
action.accept(elementSet.asList().get(i), getCount(i));
}
}
@Override
@CheckForNull
Reported by PMD.
guava/src/com/google/common/collect/CompactHashing.java
4 issues
Line: 166
Object table,
int[] entries,
@Nullable Object[] keys,
@CheckForNull @Nullable Object[] values) {
int hash = Hashing.smearedHash(key);
int tableIndex = hash & mask;
int next = tableGet(table, tableIndex);
if (next == UNSET) {
return -1;
Reported by PMD.
Line: 174
return -1;
}
int hashPrefix = getHashPrefix(hash, mask);
int lastEntryIndex = -1;
do {
int entryIndex = next - 1;
int entry = entries[entryIndex];
if (getHashPrefix(entry, mask) == hashPrefix
&& Objects.equal(key, keys[entryIndex])
Reported by PMD.
Line: 192
return entryIndex;
}
lastEntryIndex = entryIndex;
next = getNext(entry, mask);
} while (next != UNSET);
return -1;
}
}
Reported by PMD.
Line: 192
return entryIndex;
}
lastEntryIndex = entryIndex;
next = getNext(entry, mask);
} while (next != UNSET);
return -1;
}
}
Reported by PMD.
guava/src/com/google/common/collect/CompactLinkedHashMap.java
4 issues
Line: 57
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactLinkedHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends CompactHashMap<K, V> {
// TODO(lowasser): implement removeEldestEntry so this can be used as a drop-in replacement
/** Creates an empty {@code CompactLinkedHashMap} instance. */
public static <K extends @Nullable Object, V extends @Nullable Object>
Reported by PMD.
Line: 58
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactLinkedHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends CompactHashMap<K, V> {
// TODO(lowasser): implement removeEldestEntry so this can be used as a drop-in replacement
/** Creates an empty {@code CompactLinkedHashMap} instance. */
public static <K extends @Nullable Object, V extends @Nullable Object>
CompactLinkedHashMap<K, V> create() {
Reported by PMD.
Line: 100
/** Pointer to the last node in the linked list, or {@code ENDPOINT} if there are no entries. */
private transient int lastEntry;
private final boolean accessOrder;
CompactLinkedHashMap() {
this(CompactHashing.DEFAULT_SIZE);
}
Reported by PMD.
Line: 138
@CanIgnoreReturnValue
Map<K, V> convertToHashFloodingResistantImplementation() {
Map<K, V> result = super.convertToHashFloodingResistantImplementation();
links = null;
return result;
}
/*
* For discussion of the safety of the following methods for operating on predecessors and
Reported by PMD.
guava/src/com/google/common/collect/AbstractMapEntry.java
4 issues
Line: 54
public boolean equals(@CheckForNull Object object) {
if (object instanceof Entry) {
Entry<?, ?> that = (Entry<?, ?>) object;
return Objects.equal(this.getKey(), that.getKey())
&& Objects.equal(this.getValue(), that.getValue());
}
return false;
}
Reported by PMD.
Line: 55
if (object instanceof Entry) {
Entry<?, ?> that = (Entry<?, ?>) object;
return Objects.equal(this.getKey(), that.getKey())
&& Objects.equal(this.getValue(), that.getValue());
}
return false;
}
@Override
Reported by PMD.
Line: 64
public int hashCode() {
K k = getKey();
V v = getValue();
return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
}
/** Returns a string representation of the form {@code {key}={value}}. */
@Override
public String toString() {
Reported by PMD.
Line: 64
public int hashCode() {
K k = getKey();
V v = getValue();
return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
}
/** Returns a string representation of the form {@code {key}={value}}. */
@Override
public String toString() {
Reported by PMD.
guava/src/com/google/common/collect/Comparators.java
4 issues
Line: 82
checkNotNull(comparator);
Iterator<? extends T> it = iterable.iterator();
if (it.hasNext()) {
T prev = it.next();
while (it.hasNext()) {
T next = it.next();
if (comparator.compare(prev, next) > 0) {
return false;
}
Reported by PMD.
Line: 88
if (comparator.compare(prev, next) > 0) {
return false;
}
prev = next;
}
}
return true;
}
Reported by PMD.
Line: 105
checkNotNull(comparator);
Iterator<? extends T> it = iterable.iterator();
if (it.hasNext()) {
T prev = it.next();
while (it.hasNext()) {
T next = it.next();
if (comparator.compare(prev, next) >= 0) {
return false;
}
Reported by PMD.
Line: 111
if (comparator.compare(prev, next) >= 0) {
return false;
}
prev = next;
}
}
return true;
}
Reported by PMD.