The following issues were found
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.
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.
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.
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.
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.
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.
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/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.
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.
guava/src/com/google/common/base/Platform.java
5 issues
Line: 125
"https://stackoverflow.com/q/5189914/28465",
"https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
}
logger.log(
java.util.logging.Level.WARNING,
"Later in 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());
Reported by PMD.
Line: 33
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
private static final Logger logger = Logger.getLogger(Platform.class.getName());
private static final PatternCompiler patternCompiler = loadPatternCompiler();
private Platform() {}
Reported by PMD.
Line: 50
}
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
}
static String formatCompact4Digits(double value) {
return String.format(Locale.ROOT, "%.4g", value);
Reported by PMD.
Line: 51
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
WeakReference<? extends Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
return ref == null ? Optional.<T>absent() : Optional.of(enumClass.cast(ref.get()));
}
static String formatCompact4Digits(double value) {
return String.format(Locale.ROOT, "%.4g", value);
}
Reported by PMD.
Line: 96
return new JdkPatternCompiler();
}
private static void logPatternCompilerError(ServiceConfigurationError e) {
logger.log(Level.WARNING, "Error loading regex compiler, falling back to next option", e);
}
private static final class JdkPatternCompiler implements PatternCompiler {
@Override
Reported by PMD.