The following issues were found
guava-tests/test/com/google/common/io/TestInputStream.java
3 issues
Line: 34
/** @author Colin Decker */
public class TestInputStream extends FilterInputStream {
private final ImmutableSet<TestOption> options;
private boolean closed;
public TestInputStream(InputStream in, TestOption... options) throws IOException {
this(in, Arrays.asList(options));
}
Reported by PMD.
Line: 35
public class TestInputStream extends FilterInputStream {
private final ImmutableSet<TestOption> options;
private boolean closed;
public TestInputStream(InputStream in, TestOption... options) throws IOException {
this(in, Arrays.asList(options));
}
Reported by PMD.
Line: 35
public class TestInputStream extends FilterInputStream {
private final ImmutableSet<TestOption> options;
private boolean closed;
public TestInputStream(InputStream in, TestOption... options) throws IOException {
this(in, Arrays.asList(options));
}
Reported by PMD.
guava-tests/test/com/google/common/io/TestOutputStream.java
3 issues
Line: 33
/** @author Colin Decker */
public class TestOutputStream extends FilterOutputStream {
private final ImmutableSet<TestOption> options;
private boolean closed;
public TestOutputStream(OutputStream out, TestOption... options) throws IOException {
this(out, Arrays.asList(options));
}
Reported by PMD.
Line: 34
public class TestOutputStream extends FilterOutputStream {
private final ImmutableSet<TestOption> options;
private boolean closed;
public TestOutputStream(OutputStream out, TestOption... options) throws IOException {
this(out, Arrays.asList(options));
}
Reported by PMD.
Line: 34
public class TestOutputStream extends FilterOutputStream {
private final ImmutableSet<TestOption> options;
private boolean closed;
public TestOutputStream(OutputStream out, TestOption... options) throws IOException {
this(out, Arrays.asList(options));
}
Reported by PMD.
guava-tests/test/com/google/common/cache/TestingRemovalListeners.java
3 issues
Line: 28
* @author mike nonemacher
*/
@GwtCompatible(emulated = true)
class TestingRemovalListeners {
/** Returns a new no-op {@code RemovalListener}. */
static <K, V> NullRemovalListener<K, V> nullRemovalListener() {
return new NullRemovalListener<>();
}
Reported by PMD.
Line: 48
/** {@link RemovalListener} that adds all {@link RemovalNotification} objects to a queue. */
@GwtIncompatible // ConcurrentLinkedQueue
static class QueuingRemovalListener<K, V> extends ConcurrentLinkedQueue<RemovalNotification<K, V>>
implements RemovalListener<K, V> {
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
add(notification);
Reported by PMD.
Line: 63
*/
static class CountingRemovalListener<K, V> implements RemovalListener<K, V> {
private final AtomicInteger count = new AtomicInteger();
private volatile RemovalNotification<K, V> lastNotification;
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
count.incrementAndGet();
lastNotification = notification;
Reported by PMD.
guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
3 issues
Line: 40
@Override
protected SortedMap<String, String> makePopulatedMap() {
SortedMap<String, Integer> underlying = Maps.newTreeMap();
underlying.put("a", 1);
underlying.put("b", 2);
underlying.put("c", 3);
return Maps.transformValues(underlying, Functions.toStringFunction());
}
}
Reported by PMD.
Line: 41
protected SortedMap<String, String> makePopulatedMap() {
SortedMap<String, Integer> underlying = Maps.newTreeMap();
underlying.put("a", 1);
underlying.put("b", 2);
underlying.put("c", 3);
return Maps.transformValues(underlying, Functions.toStringFunction());
}
}
Reported by PMD.
Line: 42
SortedMap<String, Integer> underlying = Maps.newTreeMap();
underlying.put("a", 1);
underlying.put("b", 2);
underlying.put("c", 3);
return Maps.transformValues(underlying, Functions.toStringFunction());
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/ImmutableMultimapAsMapImplementsMapTest.java
3 issues
Line: 39
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return ImmutableMultimap.<String, Integer>of().asMap();
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> delegate = HashMultimap.create();
Reported by PMD.
Line: 39
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return ImmutableMultimap.<String, Integer>of().asMap();
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> delegate = HashMultimap.create();
Reported by PMD.
Line: 46
protected Map<String, Collection<Integer>> makePopulatedMap() {
Multimap<String, Integer> delegate = HashMultimap.create();
populate(delegate);
return ImmutableMultimap.copyOf(delegate).asMap();
}
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/SetMultimapReplaceValuesTester.java
3 issues
Line: 37
public class SetMultimapReplaceValuesTester<K, V>
extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
public void testReplaceValuesHandlesDuplicates() {
@SuppressWarnings("unchecked")
List<V> values = Arrays.asList(v0(), v1(), v0());
for (K k : sampleKeys()) {
Reported by PMD.
Line: 44
for (K k : sampleKeys()) {
resetContainer();
multimap().replaceValues(k, values);
assertGet(k, v0(), v1());
}
}
}
Reported by PMD.
Line: 40
@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
public void testReplaceValuesHandlesDuplicates() {
@SuppressWarnings("unchecked")
List<V> values = Arrays.asList(v0(), v1(), v0());
for (K k : sampleKeys()) {
resetContainer();
multimap().replaceValues(k, values);
assertGet(k, v0(), v1());
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/SetMultimapEqualsTester.java
3 issues
Line: 34
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapEqualsTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
SetMultimap<K, V> multimap1 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v0()),
Reported by PMD.
Line: 37
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
SetMultimap<K, V> multimap1 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v4()));
SetMultimap<K, V> multimap2 =
Reported by PMD.
Line: 43
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v4()));
SetMultimap<K, V> multimap2 =
getSubjectGenerator()
.create(
Helpers.mapEntry(k0(), v1()),
Helpers.mapEntry(k0(), v0()),
Helpers.mapEntry(k0(), v4()));
new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
3 issues
Line: 41
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> {
/**
* Not supported. Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety,
* instead. This method exists only to hide {@link ImmutableSet#builder} from consumers of {@code
* ImmutableSortedSet}.
*
Reported by PMD.
Line: 93
* @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
* ImmutableSortedSet#of(Comparable, Comparable)}.</b>
*/
@DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
throw new UnsupportedOperationException();
}
Reported by PMD.
Line: 171
*/
@DoNotCall("Pass parameters of type Comparable")
@Deprecated
public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
throw new UnsupportedOperationException();
}
/*
* We would like to include an unsupported "<E> copyOf(Iterable<E>)" here,
Reported by PMD.
guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/JdkBackedImmutableBiMap.java
3 issues
Line: 22
* GWT emulation of {@link JdkBackedImmutableBiMap}. Never used, but must exist so that the client
* is willing to deserialize maps that were this type on the server.
*/
class JdkBackedImmutableBiMap<K, V> extends RegularImmutableBiMap<K, V> {
private JdkBackedImmutableBiMap(ImmutableMap<K, V> delegate, ImmutableBiMap<V, K> inverse) {
super(delegate, inverse);
}
}
Reported by PMD.
Line: 22
* GWT emulation of {@link JdkBackedImmutableBiMap}. Never used, but must exist so that the client
* is willing to deserialize maps that were this type on the server.
*/
class JdkBackedImmutableBiMap<K, V> extends RegularImmutableBiMap<K, V> {
private JdkBackedImmutableBiMap(ImmutableMap<K, V> delegate, ImmutableBiMap<V, K> inverse) {
super(delegate, inverse);
}
}
Reported by PMD.
Line: 22
* GWT emulation of {@link JdkBackedImmutableBiMap}. Never used, but must exist so that the client
* is willing to deserialize maps that were this type on the server.
*/
class JdkBackedImmutableBiMap<K, V> extends RegularImmutableBiMap<K, V> {
private JdkBackedImmutableBiMap(ImmutableMap<K, V> delegate, ImmutableBiMap<V, K> inverse) {
super(delegate, inverse);
}
}
Reported by PMD.
android/guava/src/com/google/common/collect/NullsFirstOrdering.java
3 issues
Line: 29
@ElementTypesAreNonnullByDefault
final class NullsFirstOrdering<T extends @Nullable Object> extends Ordering<@Nullable T>
implements Serializable {
final Ordering<? super T> ordering;
NullsFirstOrdering(Ordering<? super T> ordering) {
this.ordering = ordering;
}
Reported by PMD.
Line: 37
@Override
public int compare(@CheckForNull T left, @CheckForNull T right) {
if (left == right) {
return 0;
}
if (left == null) {
return RIGHT_IS_GREATER;
}
Reported by PMD.
Line: 53
@SuppressWarnings("nullness") // should be safe, but not sure if we can avoid the warning
public <S extends @Nullable T> Ordering<S> reverse() {
// ordering.reverse() might be optimized, so let it do its thing
return ordering.reverse().nullsLast();
}
@SuppressWarnings("unchecked") // still need the right way to explain this
@Override
public <S extends T> Ordering<@Nullable S> nullsFirst() {
Reported by PMD.