The following issues were found
guava/src/com/google/common/collect/ImmutableList.java
39 issues
Line: 695
for (int i = 0; i < n; i++) {
hashCode = 31 * hashCode + get(i).hashCode();
hashCode = ~~hashCode;
// needed to deal with GWT integer overflow
}
return hashCode;
}
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkElementIndex;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
Reported by PMD.
Line: 66
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code
* ImmutableList}, in encounter order.
Reported by PMD.
Line: 67
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code
* ImmutableList}, in encounter order.
*
Reported by PMD.
Line: 87
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
// Casting to any type is safe because the list will never hold any elements.
@SuppressWarnings("unchecked")
public static <E> ImmutableList<E> of() {
return (ImmutableList<E>) EMPTY;
}
/**
Reported by PMD.
Line: 180
*
* @throws NullPointerException if any element is null
*/
public static <E> ImmutableList<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
}
/**
Reported by PMD.
Line: 190
*
* @throws NullPointerException if any element is null
*/
public static <E> ImmutableList<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11) {
return construct(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11);
}
// These go up to eleven. After that, you just get the varargs form, and
Reported by PMD.
Line: 207
* @since 3.0 (source-compatible since 2.0)
*/
@SafeVarargs // For Eclipse. For internal javac we have disabled this pointless type of warning.
public static <E> ImmutableList<E> of(
E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12, E... others) {
checkArgument(
others.length <= Integer.MAX_VALUE - 12, "the total number of elements must fit in an int");
Object[] array = new Object[12 + others.length];
array[0] = e1;
Reported by PMD.
Line: 263
if (elements instanceof ImmutableCollection) {
@SuppressWarnings("unchecked") // all supported methods are covariant
ImmutableList<E> list = ((ImmutableCollection<E>) elements).asList();
return list.isPartialView() ? ImmutableList.<E>asImmutableList(list.toArray()) : list;
}
return construct(elements.toArray());
}
/**
Reported by PMD.
guava/src/com/google/common/collect/ImmutableMultimap.java
39 issues
Line: 212
@CanIgnoreReturnValue
public Builder<K, V> putAll(K key, Iterable<? extends V> values) {
if (key == null) {
throw new NullPointerException("null key in entry: null=" + Iterables.toString(values));
}
Collection<V> valueCollection = builderMap.get(key);
if (valueCollection != null) {
for (V value : values) {
checkEntryNotNull(key, value);
Reported by PMD.
Line: 744
@GwtIncompatible // not present in emulated superclass
@Override
int copyIntoArray(@Nullable Object[] dst, int offset) {
for (ImmutableCollection<V> valueCollection : multimap.map.values()) {
offset = valueCollection.copyIntoArray(dst, offset);
}
return offset;
}
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.Maps.immutableEntry;
import static java.util.Objects.requireNonNull;
Reported by PMD.
Line: 73
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V>
implements Serializable {
/**
* Returns an empty multimap.
*
Reported by PMD.
Line: 74
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V>
implements Serializable {
/**
* Returns an empty multimap.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
Reported by PMD.
Line: 115
* Returns an immutable multimap containing the given entries, in the "key-grouped" insertion
* order described in the <a href="#iteration">class documentation</a>.
*/
public static <K, V> ImmutableMultimap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
return ImmutableListMultimap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
}
// looking for of() with > 5 entries? Use the builder instead.
Reported by PMD.
Line: 150
* @since 2.0
*/
@DoNotMock
public static class Builder<K, V> {
final Map<K, Collection<V>> builderMap;
@CheckForNull Comparator<? super K> keyComparator;
@CheckForNull Comparator<? super V> valueComparator;
/**
Reported by PMD.
Line: 151
*/
@DoNotMock
public static class Builder<K, V> {
final Map<K, Collection<V>> builderMap;
@CheckForNull Comparator<? super K> keyComparator;
@CheckForNull Comparator<? super V> valueComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
Reported by PMD.
Line: 152
@DoNotMock
public static class Builder<K, V> {
final Map<K, Collection<V>> builderMap;
@CheckForNull Comparator<? super K> keyComparator;
@CheckForNull Comparator<? super V> valueComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
* ImmutableMultimap#builder}.
Reported by PMD.
Line: 153
public static class Builder<K, V> {
final Map<K, Collection<V>> builderMap;
@CheckForNull Comparator<? super K> keyComparator;
@CheckForNull Comparator<? super V> valueComparator;
/**
* Creates a new builder. The returned builder is equivalent to the builder generated by {@link
* ImmutableMultimap#builder}.
*/
Reported by PMD.
guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
39 issues
Line: 92
public void testGetSubtypeOf_impossibleWildcard() {
TypeToken<List<? extends Number>> numberList = new TypeToken<List<? extends Number>>() {};
abstract class StringList implements List<String> {}
try {
numberList.getSubtype(StringList.class);
fail();
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 501
private static class Mall<T> {
class Shop<ProductT> {}
abstract class Retailer<ProductT> extends Shop<ProductT>
implements Comparator<ProductT>, ConsumerFacing<ProductT> {}
}
private static class Outlet<T> extends Mall<T> {}
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import java.io.Serializable;
import java.util.Comparator;
Reported by PMD.
Line: 29
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeTokenSubtypeTest extends TestCase {
public void testOwnerTypeSubtypes() throws Exception {
new OwnerTypeSubtypingTests().testAllDeclarations();
}
public void testWildcardSubtypes() throws Exception {
new WildcardSubtypingTests().testAllDeclarations();
Reported by PMD.
Line: 29
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeTokenSubtypeTest extends TestCase {
public void testOwnerTypeSubtypes() throws Exception {
new OwnerTypeSubtypingTests().testAllDeclarations();
}
public void testWildcardSubtypes() throws Exception {
new WildcardSubtypingTests().testAllDeclarations();
Reported by PMD.
Line: 33
new OwnerTypeSubtypingTests().testAllDeclarations();
}
public void testWildcardSubtypes() throws Exception {
new WildcardSubtypingTests().testAllDeclarations();
}
/**
* This test reproduces the bug in canonicalizeWildcardType() when the type variable is
Reported by PMD.
Line: 33
new OwnerTypeSubtypingTests().testAllDeclarations();
}
public void testWildcardSubtypes() throws Exception {
new WildcardSubtypingTests().testAllDeclarations();
}
/**
* This test reproduces the bug in canonicalizeWildcardType() when the type variable is
Reported by PMD.
Line: 41
* This test reproduces the bug in canonicalizeWildcardType() when the type variable is
* recursively bounded.
*/
public void testRecursiveWildcardSubtypeBug() throws Exception {
try {
new RecursiveTypeBoundBugExample<>().testAllDeclarations();
fail();
} catch (Exception e) {
assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
Reported by PMD.
Line: 44
public void testRecursiveWildcardSubtypeBug() throws Exception {
try {
new RecursiveTypeBoundBugExample<>().testAllDeclarations();
fail();
} catch (Exception e) {
assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
}
}
Reported by PMD.
Line: 45
try {
new RecursiveTypeBoundBugExample<>().testAllDeclarations();
fail();
} catch (Exception e) {
assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
}
}
public void testSubtypeOfInnerClass_nonStaticAnonymousClass() {
Reported by PMD.
guava/src/com/google/common/cache/CacheBuilder.java
39 issues
Line: 194
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_EXPIRATION_NANOS = 0;
Reported by PMD.
Line: 194
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_EXPIRATION_NANOS = 0;
Reported by PMD.
Line: 194
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_EXPIRATION_NANOS = 0;
Reported by PMD.
Line: 194
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_EXPIRATION_NANOS = 0;
Reported by PMD.
Line: 194
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_EXPIRATION_NANOS = 0;
Reported by PMD.
Line: 198
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_EXPIRATION_NANOS = 0;
@SuppressWarnings("GoodTime") // should be a java.time.Duration
private static final int DEFAULT_REFRESH_NANOS = 0;
Reported by PMD.
Line: 267
static final int UNSET_INT = -1;
boolean strictParsing = true;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
long maximumSize = UNSET_INT;
long maximumWeight = UNSET_INT;
Reported by PMD.
Line: 269
boolean strictParsing = true;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
long maximumSize = UNSET_INT;
long maximumWeight = UNSET_INT;
@Nullable Weigher<? super K, ? super V> weigher;
Reported by PMD.
Line: 269
boolean strictParsing = true;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
long maximumSize = UNSET_INT;
long maximumWeight = UNSET_INT;
@Nullable Weigher<? super K, ? super V> weigher;
Reported by PMD.
Line: 270
boolean strictParsing = true;
int initialCapacity = UNSET_INT;
int concurrencyLevel = UNSET_INT;
long maximumSize = UNSET_INT;
long maximumWeight = UNSET_INT;
@Nullable Weigher<? super K, ? super V> weigher;
@Nullable Strength keyStrength;
Reported by PMD.
guava/src/com/google/common/collect/Collections2.java
39 issues
Line: 693
Collections.swap(list, j - c[j] + s, j - q + s);
c[j] = q;
break;
}
}
void switchDirection() {
o[j] = -o[j];
Reported by PMD.
Line: 108
checkNotNull(collection);
try {
return collection.contains(object);
} catch (ClassCastException | NullPointerException e) {
return false;
}
}
/**
Reported by PMD.
Line: 108
checkNotNull(collection);
try {
return collection.contains(object);
} catch (ClassCastException | NullPointerException e) {
return false;
}
}
/**
Reported by PMD.
Line: 121
checkNotNull(collection);
try {
return collection.remove(object);
} catch (ClassCastException | NullPointerException e) {
return false;
}
}
static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
Reported by PMD.
Line: 121
checkNotNull(collection);
try {
return collection.remove(object);
} catch (ClassCastException | NullPointerException e) {
return false;
}
}
static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
Reported by PMD.
Line: 126
}
}
static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
final Collection<E> unfiltered;
final Predicate<? super E> predicate;
FilteredCollection(Collection<E> unfiltered, Predicate<? super E> predicate) {
this.unfiltered = unfiltered;
Reported by PMD.
Line: 127
}
static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
final Collection<E> unfiltered;
final Predicate<? super E> predicate;
FilteredCollection(Collection<E> unfiltered, Predicate<? super E> predicate) {
this.unfiltered = unfiltered;
this.predicate = predicate;
Reported by PMD.
Line: 128
static class FilteredCollection<E extends @Nullable Object> extends AbstractCollection<E> {
final Collection<E> unfiltered;
final Predicate<? super E> predicate;
FilteredCollection(Collection<E> unfiltered, Predicate<? super E> predicate) {
this.unfiltered = unfiltered;
this.predicate = predicate;
}
Reported by PMD.
Line: 235
@Override
public @Nullable Object[] toArray() {
// creating an ArrayList so filtering happens once
return Lists.newArrayList(iterator()).toArray();
}
@Override
@SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
public <T extends @Nullable Object> T[] toArray(T[] array) {
Reported by PMD.
Line: 241
@Override
@SuppressWarnings("nullness") // b/192354773 in our checker affects toArray declarations
public <T extends @Nullable Object> T[] toArray(T[] array) {
return Lists.newArrayList(iterator()).toArray(array);
}
}
/**
* Returns a collection that applies {@code function} to each element of {@code fromCollection}.
Reported by PMD.
guava/src/com/google/common/net/MediaType.java
39 issues
Line: 15
* the License.
*/
package com.google.common.net;
import static com.google.common.base.CharMatcher.ascii;
import static com.google.common.base.CharMatcher.javaIsoControl;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.base.Preconditions.checkArgument;
Reported by PMD.
Line: 79
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class MediaType {
private static final String CHARSET_ATTRIBUTE = "charset";
private static final ImmutableListMultimap<String, String> UTF_8_CONSTANT_PARAMETERS =
ImmutableListMultimap.of(CHARSET_ATTRIBUTE, Ascii.toLowerCase(UTF_8.name()));
/** Matcher for type, subtype and attributes. */
Reported by PMD.
Line: 79
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class MediaType {
private static final String CHARSET_ATTRIBUTE = "charset";
private static final ImmutableListMultimap<String, String> UTF_8_CONSTANT_PARAMETERS =
ImmutableListMultimap.of(CHARSET_ATTRIBUTE, Ascii.toLowerCase(UTF_8.name()));
/** Matcher for type, subtype and attributes. */
Reported by PMD.
Line: 763
*/
public static final MediaType FONT_WOFF2 = createConstant(FONT_TYPE, "woff2");
private final String type;
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
Reported by PMD.
Line: 763
*/
public static final MediaType FONT_WOFF2 = createConstant(FONT_TYPE, "woff2");
private final String type;
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
Reported by PMD.
Line: 764
public static final MediaType FONT_WOFF2 = createConstant(FONT_TYPE, "woff2");
private final String type;
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
@LazyInit private int hashCode;
Reported by PMD.
Line: 764
public static final MediaType FONT_WOFF2 = createConstant(FONT_TYPE, "woff2");
private final String type;
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
@LazyInit private int hashCode;
Reported by PMD.
Line: 765
private final String type;
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
@LazyInit private int hashCode;
Reported by PMD.
Line: 765
private final String type;
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
@LazyInit private int hashCode;
Reported by PMD.
Line: 767
private final String subtype;
private final ImmutableListMultimap<String, String> parameters;
@LazyInit @CheckForNull private String toString;
@LazyInit private int hashCode;
@LazyInit @CheckForNull private Optional<Charset> parsedCharset;
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
38 issues
Line: 102
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractScheduledService implements Service {
private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
/**
* A scheduler defines the policy for how the {@link AbstractScheduledService} should run its
* task.
Reported by PMD.
Line: 173
}
/* use AbstractService for state management */
private final AbstractService delegate = new ServiceDelegate();
@WeakOuter
private final class ServiceDelegate extends AbstractService {
// A handle to the running task so that we can stop it when a shutdown has been requested.
Reported by PMD.
Line: 180
// A handle to the running task so that we can stop it when a shutdown has been requested.
// These two fields are volatile because their values will be accessed from multiple threads.
@CheckForNull private volatile Cancellable runningTask;
@CheckForNull private volatile ScheduledExecutorService executorService;
// This lock protects the task so we can ensure that none of the template methods (startUp,
// shutDown or runOneIteration) run concurrently with one another.
// TODO(lukes): why don't we use ListenableFuture to sequence things? Then we could drop the
Reported by PMD.
Line: 181
// A handle to the running task so that we can stop it when a shutdown has been requested.
// These two fields are volatile because their values will be accessed from multiple threads.
@CheckForNull private volatile Cancellable runningTask;
@CheckForNull private volatile ScheduledExecutorService executorService;
// This lock protects the task so we can ensure that none of the template methods (startUp,
// shutDown or runOneIteration) run concurrently with one another.
// TODO(lukes): why don't we use ListenableFuture to sequence things? Then we could drop the
// lock.
Reported by PMD.
Line: 187
// shutDown or runOneIteration) run concurrently with one another.
// TODO(lukes): why don't we use ListenableFuture to sequence things? Then we could drop the
// lock.
private final ReentrantLock lock = new ReentrantLock();
@WeakOuter
class Task implements Runnable {
@Override
public void run() {
Reported by PMD.
Line: 199
* requireNonNull is safe because Task isn't run (or at least it doesn't succeed in taking
* the lock) until after it's scheduled and the runningTask field is set.
*/
if (requireNonNull(runningTask).isCancelled()) {
// task may have been cancelled while blocked on the lock.
return;
}
AbstractScheduledService.this.runOneIteration();
} catch (Throwable t) {
Reported by PMD.
Line: 203
// task may have been cancelled while blocked on the lock.
return;
}
AbstractScheduledService.this.runOneIteration();
} catch (Throwable t) {
try {
shutDown();
} catch (Exception ignored) {
logger.log(
Reported by PMD.
Line: 203
// task may have been cancelled while blocked on the lock.
return;
}
AbstractScheduledService.this.runOneIteration();
} catch (Throwable t) {
try {
shutDown();
} catch (Exception ignored) {
logger.log(
Reported by PMD.
Line: 204
return;
}
AbstractScheduledService.this.runOneIteration();
} catch (Throwable t) {
try {
shutDown();
} catch (Exception ignored) {
logger.log(
Level.WARNING,
Reported by PMD.
Line: 207
} catch (Throwable t) {
try {
shutDown();
} catch (Exception ignored) {
logger.log(
Level.WARNING,
"Error while attempting to shut down the service after failure.",
ignored);
}
Reported by PMD.
guava-tests/test/com/google/common/collect/ImmutableSetTest.java
38 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 59
* @author Nick Kralevich
*/
@GwtCompatible(emulated = true)
public class ImmutableSetTest extends AbstractImmutableSetTest {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
Reported by PMD.
Line: 61
@GwtCompatible(emulated = true)
public class ImmutableSetTest extends AbstractImmutableSetTest {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(new ImmutableSetCopyOfGenerator())
Reported by PMD.
Line: 62
public class ImmutableSetTest extends AbstractImmutableSetTest {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
SetTestSuiteBuilder.using(new ImmutableSetCopyOfGenerator())
.named(ImmutableSetTest.class.getName())
Reported by PMD.
Line: 225
return ImmutableSet.copyOf(elements);
}
public void testCreation_allDuplicates() {
ImmutableSet<String> set = ImmutableSet.copyOf(Lists.newArrayList("a", "a"));
assertTrue(set instanceof SingletonImmutableSet);
assertEquals(Lists.newArrayList("a"), Lists.newArrayList(set));
}
Reported by PMD.
Line: 225
return ImmutableSet.copyOf(elements);
}
public void testCreation_allDuplicates() {
ImmutableSet<String> set = ImmutableSet.copyOf(Lists.newArrayList("a", "a"));
assertTrue(set instanceof SingletonImmutableSet);
assertEquals(Lists.newArrayList("a"), Lists.newArrayList(set));
}
Reported by PMD.
Line: 231
assertEquals(Lists.newArrayList("a"), Lists.newArrayList(set));
}
public void testCreation_oneDuplicate() {
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "a");
assertEquals(
Lists.newArrayList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"),
Reported by PMD.
Line: 240
Lists.newArrayList(set));
}
public void testCreation_manyDuplicates() {
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "c", "c", "c", "b", "b", "a", "a", "c", "c", "c", "a");
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
Reported by PMD.
Line: 244
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "c", "c", "c", "b", "b", "a", "a", "c", "c", "c", "a");
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
public void testCreation_arrayOfArray() {
String[] array = new String[] {"a"};
Set<String[]> set = ImmutableSet.<String[]>of(array);
Reported by PMD.
Line: 244
// now we'll get the varargs overload
ImmutableSet<String> set =
ImmutableSet.of("a", "b", "c", "c", "c", "c", "b", "b", "a", "a", "c", "c", "c", "a");
assertThat(set).containsExactly("a", "b", "c").inOrder();
}
public void testCreation_arrayOfArray() {
String[] array = new String[] {"a"};
Set<String[]> set = ImmutableSet.<String[]>of(array);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ConcurrentMapReplaceEntryTester.java
38 issues
Line: 40
*/
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ConcurrentMapReplaceEntryTester<K, V> extends AbstractMapTester<K, V> {
@Override
protected ConcurrentMap<K, V> getMap() {
return (ConcurrentMap<K, V>) super.getMap();
}
Reported by PMD.
Line: 46
return (ConcurrentMap<K, V>) super.getMap();
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
assertTrue(getMap().replace(k0(), v0(), v3()));
expectReplacement(entry(k0(), v3()));
}
Reported by PMD.
Line: 49
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
assertTrue(getMap().replace(k0(), v0(), v3()));
expectReplacement(entry(k0(), v3()));
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 53
expectReplacement(entry(k0(), v3()));
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresentUnchanged() {
assertTrue(getMap().replace(k0(), v0(), v0()));
expectUnchanged();
}
Reported by PMD.
Line: 56
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresentUnchanged() {
assertTrue(getMap().replace(k0(), v0(), v0()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 60
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedWrongValue() {
assertFalse(getMap().replace(k0(), v3(), v4()));
expectUnchanged();
}
Reported by PMD.
Line: 63
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedWrongValue() {
assertFalse(getMap().replace(k0(), v3(), v4()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
Reported by PMD.
Line: 67
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
assertFalse(getMap().replace(k3(), v3(), v4()));
expectUnchanged();
}
Reported by PMD.
Line: 69
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
assertFalse(getMap().replace(k3(), v3(), v4()));
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 73
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_presentNullValueUnsupported() {
try {
getMap().replace(k0(), v0(), null);
fail("Expected NullPointerException");
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapReplaceEntryTester.java
38 issues
Line: 39
*/
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapReplaceEntryTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
try {
Reported by PMD.
Line: 41
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapReplaceEntryTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
try {
assertTrue(getMap().replace(k0(), v0(), v3()));
expectReplacement(entry(k0(), v3()));
Reported by PMD.
Line: 45
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresent() {
try {
assertTrue(getMap().replace(k0(), v0(), v3()));
expectReplacement(entry(k0(), v3()));
} catch (ClassCastException tolerated) { // for ClassToInstanceMap
expectUnchanged();
}
}
Reported by PMD.
Line: 52
}
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresentUnchanged() {
assertTrue(getMap().replace(k0(), v0(), v0()));
expectUnchanged();
}
Reported by PMD.
Line: 55
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedPresentUnchanged() {
assertTrue(getMap().replace(k0(), v0(), v0()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 59
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedWrongValue() {
assertFalse(getMap().replace(k0(), v3(), v4()));
expectUnchanged();
}
Reported by PMD.
Line: 62
@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_supportedWrongValue() {
assertFalse(getMap().replace(k0(), v3(), v4()));
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
Reported by PMD.
Line: 66
expectUnchanged();
}
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
assertFalse(getMap().replace(k3(), v3(), v4()));
expectUnchanged();
}
Reported by PMD.
Line: 68
@MapFeature.Require(SUPPORTS_PUT)
public void testReplaceEntry_supportedAbsentKey() {
assertFalse(getMap().replace(k3(), v3(), v4()));
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 72
expectUnchanged();
}
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testReplaceEntry_presentNullValueUnsupported() {
try {
getMap().replace(k0(), v0(), null);
fail("Expected NullPointerException");
Reported by PMD.