The following issues were found
android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
4 issues
Line: 38
@CheckForNull private final transient Object keyHashTable;
@VisibleForTesting final transient @Nullable Object[] alternatingKeysAndValues;
private final transient int keyOffset; // 0 for K-to-V, 1 for V-to-K
private final transient int size;
private final transient RegularImmutableBiMap<V, K> inverse;
/** Constructor for empty bimap. */
@SuppressWarnings("unchecked")
private RegularImmutableBiMap() {
Reported by PMD.
Line: 39
@VisibleForTesting final transient @Nullable Object[] alternatingKeysAndValues;
private final transient int keyOffset; // 0 for K-to-V, 1 for V-to-K
private final transient int size;
private final transient RegularImmutableBiMap<V, K> inverse;
/** Constructor for empty bimap. */
@SuppressWarnings("unchecked")
private RegularImmutableBiMap() {
this.keyHashTable = null;
Reported by PMD.
Line: 44
/** Constructor for empty bimap. */
@SuppressWarnings("unchecked")
private RegularImmutableBiMap() {
this.keyHashTable = null;
this.alternatingKeysAndValues = new Object[0];
this.keyOffset = 0;
this.size = 0;
this.inverse = (RegularImmutableBiMap<V, K>) this;
}
Reported by PMD.
Line: 52
}
/** K-to-V constructor. */
RegularImmutableBiMap(@Nullable Object[] alternatingKeysAndValues, int size) {
this.alternatingKeysAndValues = alternatingKeysAndValues;
this.size = size;
this.keyOffset = 0;
int tableSize = (size >= 2) ? ImmutableSet.chooseTableSize(size) : 0;
this.keyHashTable =
Reported by PMD.
android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
4 issues
Line: 40
new RegularImmutableMultiset<>(ObjectCountHashMap.create());
final transient ObjectCountHashMap<E> contents;
private final transient int size;
@LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
RegularImmutableMultiset(ObjectCountHashMap<E> contents) {
this.contents = contents;
Reported by PMD.
Line: 42
final transient ObjectCountHashMap<E> contents;
private final transient int size;
@LazyInit @CheckForNull private transient ImmutableSet<E> elementSet;
RegularImmutableMultiset(ObjectCountHashMap<E> contents) {
this.contents = contents;
long size = 0;
for (int i = 0; i < contents.size(); i++) {
Reported by PMD.
Line: 84
@Override
public boolean contains(@CheckForNull Object object) {
return RegularImmutableMultiset.this.contains(object);
}
@Override
boolean isPartialView() {
return true;
Reported by PMD.
Line: 84
@Override
public boolean contains(@CheckForNull Object object) {
return RegularImmutableMultiset.this.contains(object);
}
@Override
boolean isPartialView() {
return true;
Reported by PMD.
android/guava/src/com/google/common/collect/SingletonImmutableTable.java
4 issues
Line: 31
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
final R singleRowKey;
final C singleColumnKey;
final V singleValue;
SingletonImmutableTable(R rowKey, C columnKey, V value) {
Reported by PMD.
Line: 32
@GwtCompatible
@ElementTypesAreNonnullByDefault
class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
final R singleRowKey;
final C singleColumnKey;
final V singleValue;
SingletonImmutableTable(R rowKey, C columnKey, V value) {
this.singleRowKey = checkNotNull(rowKey);
Reported by PMD.
Line: 33
@ElementTypesAreNonnullByDefault
class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
final R singleRowKey;
final C singleColumnKey;
final V singleValue;
SingletonImmutableTable(R rowKey, C columnKey, V value) {
this.singleRowKey = checkNotNull(rowKey);
this.singleColumnKey = checkNotNull(columnKey);
Reported by PMD.
Line: 34
class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
final R singleRowKey;
final C singleColumnKey;
final V singleValue;
SingletonImmutableTable(R rowKey, C columnKey, V value) {
this.singleRowKey = checkNotNull(rowKey);
this.singleColumnKey = checkNotNull(columnKey);
this.singleValue = checkNotNull(value);
Reported by PMD.
android/guava/src/com/google/common/collect/TransformedListIterator.java
4 issues
Line: 44
@Override
public final boolean hasPrevious() {
return backingIterator().hasPrevious();
}
@Override
@ParametricNullness
public final T previous() {
Reported by PMD.
Line: 50
@Override
@ParametricNullness
public final T previous() {
return transform(backingIterator().previous());
}
@Override
public final int nextIndex() {
return backingIterator().nextIndex();
Reported by PMD.
Line: 55
@Override
public final int nextIndex() {
return backingIterator().nextIndex();
}
@Override
public final int previousIndex() {
return backingIterator().previousIndex();
Reported by PMD.
Line: 60
@Override
public final int previousIndex() {
return backingIterator().previousIndex();
}
@Override
public void set(@ParametricNullness T element) {
throw new UnsupportedOperationException();
Reported by PMD.
android/guava/src/com/google/common/collect/TreeMultimap.java
4 issues
Line: 77
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractSortedKeySortedSetMultimap<K, V> {
private transient Comparator<? super K> keyComparator;
private transient Comparator<? super V> valueComparator;
/**
* Creates an empty {@code TreeMultimap} ordered by the natural ordering of its keys and values.
Reported by PMD.
Line: 78
@ElementTypesAreNonnullByDefault
public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractSortedKeySortedSetMultimap<K, V> {
private transient Comparator<? super K> keyComparator;
private transient Comparator<? super V> valueComparator;
/**
* Creates an empty {@code TreeMultimap} ordered by the natural ordering of its keys and values.
*/
Reported by PMD.
Line: 79
public class TreeMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractSortedKeySortedSetMultimap<K, V> {
private transient Comparator<? super K> keyComparator;
private transient Comparator<? super V> valueComparator;
/**
* Creates an empty {@code TreeMultimap} ordered by the natural ordering of its keys and values.
*/
public static <K extends Comparable, V extends Comparable> TreeMultimap<K, V> create() {
Reported by PMD.
Line: 145
@Override
Collection<V> createCollection(@ParametricNullness K key) {
if (key == null) {
keyComparator().compare(key, key);
}
return super.createCollection(key);
}
/**
Reported by PMD.
android/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.
android/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java
4 issues
Line: 43
* @param <E> Edge parameter type
*/
@ElementTypesAreNonnullByDefault
final class DirectedMultiNetworkConnections<N, E> extends AbstractDirectedNetworkConnections<N, E> {
private DirectedMultiNetworkConnections(
Map<E, N> inEdges, Map<E, N> outEdges, int selfLoopCount) {
super(inEdges, outEdges, selfLoopCount);
}
Reported by PMD.
Line: 67
@Override
public Set<N> predecessors() {
return Collections.unmodifiableSet(predecessorsMultiset().elementSet());
}
private Multiset<N> predecessorsMultiset() {
Multiset<N> predecessors = getReference(predecessorsReference);
if (predecessors == null) {
Reported by PMD.
Line: 83
@Override
public Set<N> successors() {
return Collections.unmodifiableSet(successorsMultiset().elementSet());
}
private Multiset<N> successorsMultiset() {
Multiset<N> successors = getReference(successorsReference);
if (successors == null) {
Reported by PMD.
Line: 100
return new MultiEdgesConnecting<E>(outEdgeMap, node) {
@Override
public int size() {
return successorsMultiset().count(node);
}
};
}
@Override
Reported by PMD.
android/guava/src/com/google/common/graph/ImmutableGraph.java
4 issues
Line: 51
@ElementTypesAreNonnullByDefault
public class ImmutableGraph<N> extends ForwardingGraph<N> {
@SuppressWarnings("Immutable") // The backing graph must be immutable.
private final BaseGraph<N> backingGraph;
ImmutableGraph(BaseGraph<N> backingGraph) {
this.backingGraph = backingGraph;
}
Reported by PMD.
Line: 63
? (ImmutableGraph<N>) graph
: new ImmutableGraph<N>(
new StandardValueGraph<N, Presence>(
GraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()));
}
/**
* Simply returns its argument.
*
Reported by PMD.
Line: 90
for (N node : graph.nodes()) {
nodeConnections.put(node, connectionsOf(graph, node));
}
return nodeConnections.build();
}
@SuppressWarnings("unchecked")
private static <N> GraphConnections<N, Presence> connectionsOf(Graph<N> graph, N node) {
Function<N, Presence> edgeValueFn =
Reported by PMD.
Line: 131
*/
public static class Builder<N> {
private final MutableGraph<N> mutableGraph;
Builder(GraphBuilder<N> graphBuilder) {
// The incidentEdgeOrder for immutable graphs is always stable. However, we don't want to
// modify this builder, so we make a copy instead.
this.mutableGraph = graphBuilder.copy().incidentEdgeOrder(ElementOrder.<N>stable()).build();
Reported by PMD.
android/guava/src/com/google/common/graph/ImmutableValueGraph.java
4 issues
Line: 90
for (N node : graph.nodes()) {
nodeConnections.put(node, connectionsOf(graph, node));
}
return nodeConnections.build();
}
private static <N, V> GraphConnections<N, V> connectionsOf(
final ValueGraph<N, V> graph, final N node) {
Function<N, V> successorNodeToValueFn =
Reported by PMD.
Line: 133
*/
public static class Builder<N, V> {
private final MutableValueGraph<N, V> mutableValueGraph;
Builder(ValueGraphBuilder<N, V> graphBuilder) {
// The incidentEdgeOrder for immutable graphs is always stable. However, we don't want to
// modify this builder, so we make a copy instead.
this.mutableValueGraph =
Reported by PMD.
Line: 95
private static <N, V> GraphConnections<N, V> connectionsOf(
final ValueGraph<N, V> graph, final N node) {
Function<N, V> successorNodeToValueFn =
new Function<N, V>() {
@Override
public V apply(N successorNode) {
// requireNonNull is safe because the endpoint pair comes from the graph.
return requireNonNull(graph.edgeValueOrDefault(node, successorNode, null));
Reported by PMD.
Line: 95
private static <N, V> GraphConnections<N, V> connectionsOf(
final ValueGraph<N, V> graph, final N node) {
Function<N, V> successorNodeToValueFn =
new Function<N, V>() {
@Override
public V apply(N successorNode) {
// requireNonNull is safe because the endpoint pair comes from the graph.
return requireNonNull(graph.edgeValueOrDefault(node, successorNode, null));
Reported by PMD.
android/guava/src/com/google/common/math/DoubleUtils.java
4 issues
Line: 91
static double bigToDouble(BigInteger x) {
// This is an extremely fast implementation of BigInteger.doubleValue(). JDK patch pending.
BigInteger absX = x.abs();
int exponent = absX.bitLength() - 1;
// exponent == floor(log2(abs(x)))
if (exponent < Long.SIZE - 1) {
return x.longValue();
} else if (exponent > MAX_EXPONENT) {
return x.signum() * POSITIVE_INFINITY;
Reported by PMD.
Line: 108
* It helps to consider the real number signif = absX * 2^(SIGNIFICAND_BITS - exponent).
*/
int shift = exponent - SIGNIFICAND_BITS - 1;
long twiceSignifFloor = absX.shiftRight(shift).longValue();
long signifFloor = twiceSignifFloor >> 1;
signifFloor &= SIGNIFICAND_MASK; // remove the implied bit
/*
* We round up if either the fractional part of signif is strictly greater than 0.5 (which is
Reported by PMD.
Line: 108
* It helps to consider the real number signif = absX * 2^(SIGNIFICAND_BITS - exponent).
*/
int shift = exponent - SIGNIFICAND_BITS - 1;
long twiceSignifFloor = absX.shiftRight(shift).longValue();
long signifFloor = twiceSignifFloor >> 1;
signifFloor &= SIGNIFICAND_MASK; // remove the implied bit
/*
* We round up if either the fractional part of signif is strictly greater than 0.5 (which is
Reported by PMD.
Line: 118
* >= 0.5 and signifFloor is odd (which is true if both the 0.5 bit and the 1 bit are set).
*/
boolean increment =
(twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift);
long signifRounded = increment ? signifFloor + 1 : signifFloor;
long bits = (long) (exponent + EXPONENT_BIAS) << SIGNIFICAND_BITS;
bits += signifRounded;
/*
* If signifRounded == 2^53, we'd need to set all of the significand bits to zero and add 1 to
Reported by PMD.