The following issues were found
android/guava/src/com/google/common/collect/CompactLinkedHashSet.java
5 issues
Line: 53
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactLinkedHashSet<E extends @Nullable Object> extends CompactHashSet<E> {
/** Creates an empty {@code CompactLinkedHashSet} instance. */
public static <E extends @Nullable Object> CompactLinkedHashSet<E> create() {
return new CompactLinkedHashSet<>();
}
Reported by PMD.
Line: 53
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactLinkedHashSet<E extends @Nullable Object> extends CompactHashSet<E> {
/** Creates an empty {@code CompactLinkedHashSet} instance. */
public static <E extends @Nullable Object> CompactLinkedHashSet<E> create() {
return new CompactLinkedHashSet<>();
}
Reported by PMD.
Line: 70
public static <E extends @Nullable Object> CompactLinkedHashSet<E> create(
Collection<? extends E> collection) {
CompactLinkedHashSet<E> set = createWithExpectedSize(collection.size());
set.addAll(collection);
return set;
}
/**
* Creates a {@code CompactLinkedHashSet} instance containing the given elements in unspecified
Reported by PMD.
Line: 153
@CanIgnoreReturnValue
Set<E> convertToHashFloodingResistantImplementation() {
Set<E> result = super.convertToHashFloodingResistantImplementation();
this.predecessor = null;
this.successor = null;
return result;
}
/*
Reported by PMD.
Line: 154
Set<E> convertToHashFloodingResistantImplementation() {
Set<E> result = super.convertToHashFloodingResistantImplementation();
this.predecessor = null;
this.successor = null;
return result;
}
/*
* For discussion of the safety of the following methods for operating on predecessors and
Reported by PMD.
android/guava/src/com/google/common/graph/EdgesConnecting.java
5 issues
Line: 40
@ElementTypesAreNonnullByDefault
final class EdgesConnecting<E> extends AbstractSet<E> {
private final Map<?, E> nodeToOutEdge;
private final Object targetNode;
EdgesConnecting(Map<?, E> nodeToEdgeMap, Object targetNode) {
this.nodeToOutEdge = checkNotNull(nodeToEdgeMap);
this.targetNode = checkNotNull(targetNode);
Reported by PMD.
Line: 41
final class EdgesConnecting<E> extends AbstractSet<E> {
private final Map<?, E> nodeToOutEdge;
private final Object targetNode;
EdgesConnecting(Map<?, E> nodeToEdgeMap, Object targetNode) {
this.nodeToOutEdge = checkNotNull(nodeToEdgeMap);
this.targetNode = checkNotNull(targetNode);
}
Reported by PMD.
Line: 52
public UnmodifiableIterator<E> iterator() {
E connectingEdge = getConnectingEdge();
return (connectingEdge == null)
? ImmutableSet.<E>of().iterator()
: Iterators.singletonIterator(connectingEdge);
}
@Override
public int size() {
Reported by PMD.
Line: 52
public UnmodifiableIterator<E> iterator() {
E connectingEdge = getConnectingEdge();
return (connectingEdge == null)
? ImmutableSet.<E>of().iterator()
: Iterators.singletonIterator(connectingEdge);
}
@Override
public int size() {
Reported by PMD.
Line: 64
@Override
public boolean contains(@CheckForNull Object edge) {
E connectingEdge = getConnectingEdge();
return (connectingEdge != null && connectingEdge.equals(edge));
}
@CheckForNull
private E getConnectingEdge() {
return nodeToOutEdge.get(targetNode);
Reported by PMD.
android/guava/src/com/google/common/base/Defaults.java
5 issues
Line: 30
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Defaults {
private Defaults() {}
private static final Double DOUBLE_DEFAULT = 0d;
private static final Float FLOAT_DEFAULT = 0f;
Reported by PMD.
Line: 30
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Defaults {
private Defaults() {}
private static final Double DOUBLE_DEFAULT = 0d;
private static final Float FLOAT_DEFAULT = 0f;
Reported by PMD.
Line: 43
*/
@SuppressWarnings("unchecked")
@CheckForNull
public static <T> T defaultValue(Class<T> type) {
checkNotNull(type);
if (type.isPrimitive()) {
if (type == boolean.class) {
return (T) Boolean.FALSE;
} else if (type == char.class) {
Reported by PMD.
Line: 43
*/
@SuppressWarnings("unchecked")
@CheckForNull
public static <T> T defaultValue(Class<T> type) {
checkNotNull(type);
if (type.isPrimitive()) {
if (type == boolean.class) {
return (T) Boolean.FALSE;
} else if (type == char.class) {
Reported by PMD.
Line: 43
*/
@SuppressWarnings("unchecked")
@CheckForNull
public static <T> T defaultValue(Class<T> type) {
checkNotNull(type);
if (type.isPrimitive()) {
if (type == boolean.class) {
return (T) Boolean.FALSE;
} else if (type == char.class) {
Reported by PMD.
android/guava/src/com/google/thirdparty/publicsuffix/TrieParser.java
5 issues
Line: 25
/** Parser for a map of reversed domain names stored as a serialized radix tree. */
@GwtCompatible
final class TrieParser {
private static final Joiner PREFIX_JOINER = Joiner.on("");
/**
* Parses a serialized trie representation of a map of reversed public suffixes into an immutable
* map of public suffixes.
Reported by PMD.
Line: 52
* @param builder A map builder to which all entries will be added.
* @return The number of characters consumed from {@code encoded}.
*/
private static int doParseTrieToBuilder(
Deque<CharSequence> stack,
CharSequence encoded,
int start,
ImmutableMap.Builder<String, PublicSuffixType> builder) {
Reported by PMD.
Line: 52
* @param builder A map builder to which all entries will be added.
* @return The number of characters consumed from {@code encoded}.
*/
private static int doParseTrieToBuilder(
Deque<CharSequence> stack,
CharSequence encoded,
int start,
ImmutableMap.Builder<String, PublicSuffixType> builder) {
Reported by PMD.
Line: 78
// ':' represents an interior node that represents a private entry in the map
// ',' represents a leaf node, which represents a private entry in the map.
String domain = PREFIX_JOINER.join(stack);
if (domain.length() > 0) {
builder.put(domain, PublicSuffixType.fromCode(c));
}
}
idx++;
Reported by PMD.
Line: 60
int encodedLen = encoded.length();
int idx = start;
char c = '\0';
// Read all of the characters for this node.
for (; idx < encodedLen; idx++) {
c = encoded.charAt(idx);
if (c == '&' || c == '?' || c == '!' || c == ':' || c == ',') {
Reported by PMD.
android/guava/src/com/google/common/reflect/TypeVisitor.java
5 issues
Line: 58
* @author Ben Yu
*/
@ElementTypesAreNonnullByDefault
abstract class TypeVisitor {
private final Set<Type> visited = Sets.newHashSet();
/**
* Visits the given types. Null types are ignored. This allows subclasses to call {@code
Reported by PMD.
Line: 60
@ElementTypesAreNonnullByDefault
abstract class TypeVisitor {
private final Set<Type> visited = Sets.newHashSet();
/**
* Visits the given types. Null types are ignored. This allows subclasses to call {@code
* visit(parameterizedType.getOwnerType())} safely without having to check nulls.
*/
Reported by PMD.
Line: 66
* Visits the given types. Null types are ignored. This allows subclasses to call {@code
* visit(parameterizedType.getOwnerType())} safely without having to check nulls.
*/
public final void visit(@Nullable Type... types) {
for (Type type : types) {
if (type == null || !visited.add(type)) {
// null owner type, or already visited;
continue;
}
Reported by PMD.
Line: 72
// null owner type, or already visited;
continue;
}
boolean succeeded = false;
try {
if (type instanceof TypeVariable) {
visitTypeVariable((TypeVariable<?>) type);
} else if (type instanceof WildcardType) {
visitWildcardType((WildcardType) type);
Reported by PMD.
Line: 72
// null owner type, or already visited;
continue;
}
boolean succeeded = false;
try {
if (type instanceof TypeVariable) {
visitTypeVariable((TypeVariable<?>) type);
} else if (type instanceof WildcardType) {
visitWildcardType((WildcardType) type);
Reported by PMD.
android/guava/src/com/google/common/collect/ForwardingQueue.java
5 issues
Line: 62
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
public boolean offer(@ParametricNullness E o) {
return delegate().offer(o);
}
@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
@CheckForNull
Reported by PMD.
Line: 69
@Override
@CheckForNull
public E poll() {
return delegate().poll();
}
@CanIgnoreReturnValue
@Override
@ParametricNullness
Reported by PMD.
Line: 76
@Override
@ParametricNullness
public E remove() {
return delegate().remove();
}
@Override
@CheckForNull
public E peek() {
Reported by PMD.
Line: 82
@Override
@CheckForNull
public E peek() {
return delegate().peek();
}
@Override
@ParametricNullness
public E element() {
Reported by PMD.
Line: 88
@Override
@ParametricNullness
public E element() {
return delegate().element();
}
/**
* A sensible definition of {@link #offer} in terms of {@link #add}. If you override {@link #add},
* you may wish to override {@link #offer} to forward to this implementation.
Reported by PMD.
android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java
5 issues
Line: 32
* @since 13.0
*/
@Beta
public final class ImmutableTypeToInstanceMap<B> extends ForwardingMap<TypeToken<? extends B>, B>
implements TypeToInstanceMap<B> {
/** Returns an empty type to instance map. */
public static <B> ImmutableTypeToInstanceMap<B> of() {
return new ImmutableTypeToInstanceMap<B>(ImmutableMap.<TypeToken<? extends B>, B>of());
Reported by PMD.
Line: 63
*/
@Beta
public static final class Builder<B> {
private final ImmutableMap.Builder<TypeToken<? extends B>, B> mapBuilder =
ImmutableMap.builder();
private Builder() {}
/**
Reported by PMD.
Line: 98
}
}
private final ImmutableMap<TypeToken<? extends B>, B> delegate;
private ImmutableTypeToInstanceMap(ImmutableMap<TypeToken<? extends B>, B> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 98
}
}
private final ImmutableMap<TypeToken<? extends B>, B> delegate;
private ImmutableTypeToInstanceMap(ImmutableMap<TypeToken<? extends B>, B> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 123
@CanIgnoreReturnValue
@Deprecated
@Override
@DoNotCall("Always throws UnsupportedOperationException")
public <T extends B> T putInstance(TypeToken<T> type, T value) {
throw new UnsupportedOperationException();
}
/**
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableBiMap.java
5 issues
Line: 40
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {
/**
* Returns the empty bimap.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
Reported by PMD.
Line: 40
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {
/**
* Returns the empty bimap.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
Reported by PMD.
Line: 100
*
* @throws IllegalArgumentException if duplicate keys or values are added
*/
public static <K, V> ImmutableBiMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
checkEntryNotNull(k1, v1);
checkEntryNotNull(k2, v2);
checkEntryNotNull(k3, v3);
checkEntryNotNull(k4, v4);
Reported by PMD.
Line: 297
ImmutableBiMap<K, V> bimap = (ImmutableBiMap<K, V>) map;
// TODO(lowasser): if we need to make a copy of a BiMap because the
// forward map is a view, don't make a copy of the non-view delegate map
if (!bimap.isPartialView()) {
return bimap;
}
}
return copyOf(map.entrySet());
}
Reported by PMD.
Line: 339
*/
@Override
public ImmutableSet<V> values() {
return inverse().keySet();
}
@Override
final ImmutableSet<V> createValues() {
throw new AssertionError("should never be called");
Reported by PMD.
guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java
5 issues
Line: 24
abstract class ShortsMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native short min(short... array);
@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native short max(short... array);
}
Reported by PMD.
Line: 24
abstract class ShortsMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native short min(short... array);
@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native short max(short... array);
}
Reported by PMD.
Line: 27
public static native short min(short... array);
@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native short max(short... array);
}
Reported by PMD.
Line: 27
public static native short min(short... array);
@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native short max(short... array);
}
Reported by PMD.
Line: 21
import jsinterop.annotations.JsPackage;
/** Web specializations for {@link Shorts} methods. */
abstract class ShortsMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native short min(short... array);
@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
Reported by PMD.
android/guava/src/com/google/common/graph/UndirectedGraphConnections.java
5 issues
Line: 42
* @param <V> Value parameter type
*/
@ElementTypesAreNonnullByDefault
final class UndirectedGraphConnections<N, V> implements GraphConnections<N, V> {
private final Map<N, V> adjacentNodeValues;
private UndirectedGraphConnections(Map<N, V> adjacentNodeValues) {
this.adjacentNodeValues = checkNotNull(adjacentNodeValues);
}
Reported by PMD.
Line: 43
*/
@ElementTypesAreNonnullByDefault
final class UndirectedGraphConnections<N, V> implements GraphConnections<N, V> {
private final Map<N, V> adjacentNodeValues;
private UndirectedGraphConnections(Map<N, V> adjacentNodeValues) {
this.adjacentNodeValues = checkNotNull(adjacentNodeValues);
}
Reported by PMD.
Line: 84
@Override
public Iterator<EndpointPair<N>> incidentEdgeIterator(final N thisNode) {
return Iterators.transform(
adjacentNodeValues.keySet().iterator(),
new Function<N, EndpointPair<N>>() {
@Override
public EndpointPair<N> apply(N incidentNode) {
return EndpointPair.unordered(thisNode, incidentNode);
}
Reported by PMD.
Line: 102
@Override
public void removePredecessor(N node) {
@SuppressWarnings("unused")
V unused = removeSuccessor(node);
}
@Override
@CheckForNull
public V removeSuccessor(N node) {
Reported by PMD.
Line: 114
@Override
public void addPredecessor(N node, V value) {
@SuppressWarnings("unused")
V unused = addSuccessor(node, value);
}
@Override
@CheckForNull
public V addSuccessor(N node, V value) {
Reported by PMD.