The following issues were found
guava-testlib/src/com/google/common/collect/testing/ListTestSuiteBuilder.java
24 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect.testing;
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect.testing;
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
Reported by PMD.
Line: 71
protected List<Class<? extends AbstractTester>> getTesters() {
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(CollectionSerializationEqualTester.class);
testers.add(ListAddAllAtIndexTester.class);
testers.add(ListAddAllTester.class);
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
Reported by PMD.
Line: 72
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
testers.add(CollectionSerializationEqualTester.class);
testers.add(ListAddAllAtIndexTester.class);
testers.add(ListAddAllTester.class);
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
Reported by PMD.
Line: 73
testers.add(CollectionSerializationEqualTester.class);
testers.add(ListAddAllAtIndexTester.class);
testers.add(ListAddAllTester.class);
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
testers.add(ListGetTester.class);
Reported by PMD.
Line: 74
testers.add(CollectionSerializationEqualTester.class);
testers.add(ListAddAllAtIndexTester.class);
testers.add(ListAddAllTester.class);
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
testers.add(ListGetTester.class);
testers.add(ListHashCodeTester.class);
Reported by PMD.
Line: 75
testers.add(ListAddAllAtIndexTester.class);
testers.add(ListAddAllTester.class);
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
testers.add(ListGetTester.class);
testers.add(ListHashCodeTester.class);
testers.add(ListIndexOfTester.class);
Reported by PMD.
Line: 76
testers.add(ListAddAllTester.class);
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
testers.add(ListGetTester.class);
testers.add(ListHashCodeTester.class);
testers.add(ListIndexOfTester.class);
testers.add(ListLastIndexOfTester.class);
Reported by PMD.
Line: 77
testers.add(ListAddAtIndexTester.class);
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
testers.add(ListGetTester.class);
testers.add(ListHashCodeTester.class);
testers.add(ListIndexOfTester.class);
testers.add(ListLastIndexOfTester.class);
testers.add(ListListIteratorTester.class);
Reported by PMD.
Line: 78
testers.add(ListAddTester.class);
testers.add(ListCreationTester.class);
testers.add(ListEqualsTester.class);
testers.add(ListGetTester.class);
testers.add(ListHashCodeTester.class);
testers.add(ListIndexOfTester.class);
testers.add(ListLastIndexOfTester.class);
testers.add(ListListIteratorTester.class);
testers.add(ListRemoveAllTester.class);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapKeySetTester.java
24 issues
Line: 40
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testKeySet() {
for (Entry<K, V> entry : getSampleElements()) {
assertTrue(multimap().keySet().contains(entry.getKey()));
}
}
Reported by PMD.
Line: 42
public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testKeySet() {
for (Entry<K, V> entry : getSampleElements()) {
assertTrue(multimap().keySet().contains(entry.getKey()));
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 42
public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testKeySet() {
for (Entry<K, V> entry : getSampleElements()) {
assertTrue(multimap().keySet().contains(entry.getKey()));
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 46
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeySetContainsNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().keySet().contains(null));
}
Reported by PMD.
Line: 50
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeySetContainsNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().keySet().contains(null));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
Reported by PMD.
Line: 50
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeySetContainsNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().keySet().contains(null));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
Reported by PMD.
Line: 53
assertTrue(multimap().keySet().contains(null));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 55
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetRemovePropagatesToMultimap() {
int key0Count = multimap().get(k0()).size();
Reported by PMD.
Line: 55
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetRemovePropagatesToMultimap() {
int key0Count = multimap().get(k0()).size();
Reported by PMD.
Line: 58
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetRemovePropagatesToMultimap() {
int key0Count = multimap().get(k0()).size();
assertEquals(key0Count > 0, multimap().keySet().remove(k0()));
assertEquals(getNumElements() - key0Count, multimap().size());
assertGet(k0());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/ListMultimapRemoveTester.java
24 issues
Line: 41
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapRemoveTester<K, V> extends AbstractListMultimapTester<K, V> {
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testMultimapRemoveDeletesFirstOccurrence() {
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
Reported by PMD.
Line: 41
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListMultimapRemoveTester<K, V> extends AbstractListMultimapTester<K, V> {
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testMultimapRemoveDeletesFirstOccurrence() {
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
Reported by PMD.
Line: 47
public void testMultimapRemoveDeletesFirstOccurrence() {
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
List<V> list = multimap().get(k0());
multimap().remove(k0(), v0());
assertContentsInOrder(list, v1(), v0());
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 48
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
List<V> list = multimap().get(k0());
multimap().remove(k0(), v0());
assertContentsInOrder(list, v1(), v0());
}
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 52
assertContentsInOrder(list, v1(), v0());
}
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRemoveAtIndexFromGetPropagates() {
List<V> values = Arrays.asList(v0(), v1(), v0());
Reported by PMD.
Line: 62
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
List<V> expectedValues = copyToList(values);
multimap().get(k0()).remove(i);
expectedValues.remove(i);
assertGet(k0(), expectedValues);
}
}
Reported by PMD.
Line: 62
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
List<V> expectedValues = copyToList(values);
multimap().get(k0()).remove(i);
expectedValues.remove(i);
assertGet(k0(), expectedValues);
}
}
Reported by PMD.
Line: 63
List<V> expectedValues = copyToList(values);
multimap().get(k0()).remove(i);
expectedValues.remove(i);
assertGet(k0(), expectedValues);
}
}
Reported by PMD.
Line: 69
}
}
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRemoveAtIndexFromAsMapPropagates() {
List<V> values = Arrays.asList(v0(), v1(), v0());
Reported by PMD.
Line: 79
resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
List<V> expectedValues = copyToList(values);
List<V> asMapValue = (List<V>) multimap().asMap().get(k0());
asMapValue.remove(i);
expectedValues.remove(i);
assertGet(k0(), expectedValues);
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapKeySetTester.java
24 issues
Line: 40
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testKeySet() {
for (Entry<K, V> entry : getSampleElements()) {
assertTrue(multimap().keySet().contains(entry.getKey()));
}
}
Reported by PMD.
Line: 42
public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testKeySet() {
for (Entry<K, V> entry : getSampleElements()) {
assertTrue(multimap().keySet().contains(entry.getKey()));
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 42
public class MultimapKeySetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testKeySet() {
for (Entry<K, V> entry : getSampleElements()) {
assertTrue(multimap().keySet().contains(entry.getKey()));
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 46
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeySetContainsNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().keySet().contains(null));
}
Reported by PMD.
Line: 50
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeySetContainsNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().keySet().contains(null));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
Reported by PMD.
Line: 50
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeySetContainsNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().keySet().contains(null));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
Reported by PMD.
Line: 53
assertTrue(multimap().keySet().contains(null));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 55
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetRemovePropagatesToMultimap() {
int key0Count = multimap().get(k0()).size();
Reported by PMD.
Line: 55
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeySetContainsNullKeyAbsent() {
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetRemovePropagatesToMultimap() {
int key0Count = multimap().get(k0()).size();
Reported by PMD.
Line: 58
assertFalse(multimap().keySet().contains(null));
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeySetRemovePropagatesToMultimap() {
int key0Count = multimap().get(k0()).size();
assertEquals(key0Count > 0, multimap().keySet().remove(k0()));
assertEquals(getNumElements() - key0Count, multimap().size());
assertGet(k0());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/ListSetTester.java
24 issues
Line: 41
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListSetTester<E> extends AbstractListTester<E> {
@ListFeature.Require(SUPPORTS_SET)
@CollectionSize.Require(absent = ZERO)
public void testSet() {
doTestSet(e3());
}
Reported by PMD.
Line: 47
doTestSet(e3());
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
@ListFeature.Require(SUPPORTS_SET)
public void testSet_null() {
doTestSet(null);
}
Reported by PMD.
Line: 54
doTestSet(null);
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(ALLOWS_NULL_VALUES)
@ListFeature.Require(SUPPORTS_SET)
public void testSet_replacingNull() {
E[] elements = createSamplesArray();
int i = aValidIndex();
Reported by PMD.
Line: 60
public void testSet_replacingNull() {
E[] elements = createSamplesArray();
int i = aValidIndex();
elements[i] = null;
collection = getSubjectGenerator().create(elements);
doTestSet(e3());
}
Reported by PMD.
Line: 61
E[] elements = createSamplesArray();
int i = aValidIndex();
elements[i] = null;
collection = getSubjectGenerator().create(elements);
doTestSet(e3());
}
private void doTestSet(E newValue) {
Reported by PMD.
Line: 68
private void doTestSet(E newValue) {
int index = aValidIndex();
E initialValue = getList().get(index);
assertEquals(
"set(i, x) should return the old element at position i.",
initialValue,
getList().set(index, newValue));
assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
Reported by PMD.
Line: 72
assertEquals(
"set(i, x) should return the old element at position i.",
initialValue,
getList().set(index, newValue));
assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
}
@ListFeature.Require(SUPPORTS_SET)
Reported by PMD.
Line: 73
"set(i, x) should return the old element at position i.",
initialValue,
getList().set(index, newValue));
assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
}
@ListFeature.Require(SUPPORTS_SET)
public void testSet_indexTooLow() {
Reported by PMD.
Line: 74
initialValue,
getList().set(index, newValue));
assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index));
assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
}
@ListFeature.Require(SUPPORTS_SET)
public void testSet_indexTooLow() {
try {
Reported by PMD.
Line: 77
assertEquals("set() should not change the size of a list.", getNumElements(), getList().size());
}
@ListFeature.Require(SUPPORTS_SET)
public void testSet_indexTooLow() {
try {
getList().set(-1, e3());
fail("set(-1) should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException expected) {
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ForMapMultimapAsMapImplementsMapTest.java
24 issues
Line: 40
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
Map<String, Integer> map = Maps.newHashMap();
return Multimaps.forMap(map).asMap();
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Map<String, Integer> map = Maps.newHashMap();
Reported by PMD.
Line: 46
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("bar", 2);
map.put("cow", 3);
return Multimaps.forMap(map).asMap();
}
Reported by PMD.
Line: 47
protected Map<String, Collection<Integer>> makePopulatedMap() {
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("bar", 2);
map.put("cow", 3);
return Multimaps.forMap(map).asMap();
}
@Override
Reported by PMD.
Line: 48
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("bar", 2);
map.put("cow", 3);
return Multimaps.forMap(map).asMap();
}
@Override
public void testEntrySetRemoveAllNullFromEmpty() {
Reported by PMD.
Line: 49
map.put("foo", 1);
map.put("bar", 2);
map.put("cow", 3);
return Multimaps.forMap(map).asMap();
}
@Override
public void testEntrySetRemoveAllNullFromEmpty() {
try {
Reported by PMD.
Line: 52
return Multimaps.forMap(map).asMap();
}
@Override
public void testEntrySetRemoveAllNullFromEmpty() {
try {
super.testEntrySetRemoveAllNullFromEmpty();
} catch (RuntimeException tolerated) {
// GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
Reported by PMD.
Line: 56
public void testEntrySetRemoveAllNullFromEmpty() {
try {
super.testEntrySetRemoveAllNullFromEmpty();
} catch (RuntimeException tolerated) {
// GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
}
}
@Override
Reported by PMD.
Line: 56
public void testEntrySetRemoveAllNullFromEmpty() {
try {
super.testEntrySetRemoveAllNullFromEmpty();
} catch (RuntimeException tolerated) {
// GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
}
}
@Override
Reported by PMD.
Line: 61
}
}
@Override
public void testEntrySetRetainAllNullFromEmpty() {
try {
super.testEntrySetRetainAllNullFromEmpty();
} catch (RuntimeException tolerated) {
// GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE.
Reported by PMD.
Line: 65
public void testEntrySetRetainAllNullFromEmpty() {
try {
super.testEntrySetRetainAllNullFromEmpty();
} catch (RuntimeException tolerated) {
// GWT's HashMap.entrySet().retainAll(null) doesn't throws NPE.
}
}
@Override
Reported by PMD.
guava/src/com/google/common/primitives/ImmutableDoubleArray.java
24 issues
Line: 15
* the License.
*/
package com.google.common.primitives;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
/** Returns the empty array. */
public static ImmutableDoubleArray of() {
return EMPTY;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
/** Returns the empty array. */
public static ImmutableDoubleArray of() {
return EMPTY;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableDoubleArray implements Serializable {
private static final ImmutableDoubleArray EMPTY = new ImmutableDoubleArray(new double[0]);
/** Returns the empty array. */
public static ImmutableDoubleArray of() {
return EMPTY;
Reported by PMD.
Line: 172
if (values instanceof Collection) {
return copyOf((Collection<Double>) values);
}
return builder().addAll(values).build();
}
/** Returns an immutable array containing all the values from {@code stream}, in order. */
public static ImmutableDoubleArray copyOf(DoubleStream stream) {
// Note this uses very different growth behavior from copyOf(Iterable) and the builder.
Reported by PMD.
Line: 172
if (values instanceof Collection) {
return copyOf((Collection<Double>) values);
}
return builder().addAll(values).build();
}
/** Returns an immutable array containing all the values from {@code stream}, in order. */
public static ImmutableDoubleArray copyOf(DoubleStream stream) {
// Note this uses very different growth behavior from copyOf(Iterable) and the builder.
Reported by PMD.
Line: 215
*/
@CanIgnoreReturnValue
public static final class Builder {
private double[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new double[initialCapacity];
}
Reported by PMD.
Line: 216
@CanIgnoreReturnValue
public static final class Builder {
private double[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new double[initialCapacity];
}
Reported by PMD.
Line: 216
@CanIgnoreReturnValue
public static final class Builder {
private double[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new double[initialCapacity];
}
Reported by PMD.
Line: 276
*/
public Builder addAll(DoubleStream stream) {
Spliterator.OfDouble spliterator = stream.spliterator();
long size = spliterator.getExactSizeIfKnown();
if (size > 0) { // known *and* nonempty
ensureRoomFor(Ints.saturatedCast(size));
}
spliterator.forEachRemaining((DoubleConsumer) this::add);
return this;
Reported by PMD.
guava-tests/test/com/google/common/primitives/PrimitivesTest.java
24 issues
Line: 30
* @author Kevin Bourrillion
*/
public class PrimitivesTest extends TestCase {
public void testIsWrapperType() {
assertTrue(Primitives.isWrapperType(Void.class));
assertFalse(Primitives.isWrapperType(void.class));
}
public void testWrap() {
Reported by PMD.
Line: 30
* @author Kevin Bourrillion
*/
public class PrimitivesTest extends TestCase {
public void testIsWrapperType() {
assertTrue(Primitives.isWrapperType(Void.class));
assertFalse(Primitives.isWrapperType(void.class));
}
public void testWrap() {
Reported by PMD.
Line: 31
*/
public class PrimitivesTest extends TestCase {
public void testIsWrapperType() {
assertTrue(Primitives.isWrapperType(Void.class));
assertFalse(Primitives.isWrapperType(void.class));
}
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
Reported by PMD.
Line: 32
public class PrimitivesTest extends TestCase {
public void testIsWrapperType() {
assertTrue(Primitives.isWrapperType(Void.class));
assertFalse(Primitives.isWrapperType(void.class));
}
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
assertSame(Integer.class, Primitives.wrap(Integer.class));
Reported by PMD.
Line: 35
assertFalse(Primitives.isWrapperType(void.class));
}
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
assertSame(Integer.class, Primitives.wrap(Integer.class));
assertSame(String.class, Primitives.wrap(String.class));
}
Reported by PMD.
Line: 35
assertFalse(Primitives.isWrapperType(void.class));
}
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
assertSame(Integer.class, Primitives.wrap(Integer.class));
assertSame(String.class, Primitives.wrap(String.class));
}
Reported by PMD.
Line: 36
}
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
assertSame(Integer.class, Primitives.wrap(Integer.class));
assertSame(String.class, Primitives.wrap(String.class));
}
public void testUnwrap() {
Reported by PMD.
Line: 37
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
assertSame(Integer.class, Primitives.wrap(Integer.class));
assertSame(String.class, Primitives.wrap(String.class));
}
public void testUnwrap() {
assertSame(int.class, Primitives.unwrap(Integer.class));
Reported by PMD.
Line: 38
public void testWrap() {
assertSame(Integer.class, Primitives.wrap(int.class));
assertSame(Integer.class, Primitives.wrap(Integer.class));
assertSame(String.class, Primitives.wrap(String.class));
}
public void testUnwrap() {
assertSame(int.class, Primitives.unwrap(Integer.class));
assertSame(int.class, Primitives.unwrap(int.class));
Reported by PMD.
Line: 41
assertSame(String.class, Primitives.wrap(String.class));
}
public void testUnwrap() {
assertSame(int.class, Primitives.unwrap(Integer.class));
assertSame(int.class, Primitives.unwrap(int.class));
assertSame(String.class, Primitives.unwrap(String.class));
}
Reported by PMD.
guava/src/com/google/common/primitives/ImmutableIntArray.java
24 issues
Line: 15
* the License.
*/
package com.google.common.primitives;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
/** Returns the empty array. */
public static ImmutableIntArray of() {
return EMPTY;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
/** Returns the empty array. */
public static ImmutableIntArray of() {
return EMPTY;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableIntArray implements Serializable {
private static final ImmutableIntArray EMPTY = new ImmutableIntArray(new int[0]);
/** Returns the empty array. */
public static ImmutableIntArray of() {
return EMPTY;
Reported by PMD.
Line: 169
if (values instanceof Collection) {
return copyOf((Collection<Integer>) values);
}
return builder().addAll(values).build();
}
/** Returns an immutable array containing all the values from {@code stream}, in order. */
public static ImmutableIntArray copyOf(IntStream stream) {
// Note this uses very different growth behavior from copyOf(Iterable) and the builder.
Reported by PMD.
Line: 169
if (values instanceof Collection) {
return copyOf((Collection<Integer>) values);
}
return builder().addAll(values).build();
}
/** Returns an immutable array containing all the values from {@code stream}, in order. */
public static ImmutableIntArray copyOf(IntStream stream) {
// Note this uses very different growth behavior from copyOf(Iterable) and the builder.
Reported by PMD.
Line: 212
*/
@CanIgnoreReturnValue
public static final class Builder {
private int[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new int[initialCapacity];
}
Reported by PMD.
Line: 213
@CanIgnoreReturnValue
public static final class Builder {
private int[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new int[initialCapacity];
}
Reported by PMD.
Line: 213
@CanIgnoreReturnValue
public static final class Builder {
private int[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new int[initialCapacity];
}
Reported by PMD.
Line: 273
*/
public Builder addAll(IntStream stream) {
Spliterator.OfInt spliterator = stream.spliterator();
long size = spliterator.getExactSizeIfKnown();
if (size > 0) { // known *and* nonempty
ensureRoomFor(Ints.saturatedCast(size));
}
spliterator.forEachRemaining((IntConsumer) this::add);
return this;
Reported by PMD.
guava/src/com/google/common/primitives/ImmutableLongArray.java
24 issues
Line: 15
* the License.
*/
package com.google.common.primitives;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
/** Returns the empty array. */
public static ImmutableLongArray of() {
return EMPTY;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
/** Returns the empty array. */
public static ImmutableLongArray of() {
return EMPTY;
Reported by PMD.
Line: 92
@GwtCompatible
@Immutable
@ElementTypesAreNonnullByDefault
public final class ImmutableLongArray implements Serializable {
private static final ImmutableLongArray EMPTY = new ImmutableLongArray(new long[0]);
/** Returns the empty array. */
public static ImmutableLongArray of() {
return EMPTY;
Reported by PMD.
Line: 171
if (values instanceof Collection) {
return copyOf((Collection<Long>) values);
}
return builder().addAll(values).build();
}
/** Returns an immutable array containing all the values from {@code stream}, in order. */
public static ImmutableLongArray copyOf(LongStream stream) {
// Note this uses very different growth behavior from copyOf(Iterable) and the builder.
Reported by PMD.
Line: 171
if (values instanceof Collection) {
return copyOf((Collection<Long>) values);
}
return builder().addAll(values).build();
}
/** Returns an immutable array containing all the values from {@code stream}, in order. */
public static ImmutableLongArray copyOf(LongStream stream) {
// Note this uses very different growth behavior from copyOf(Iterable) and the builder.
Reported by PMD.
Line: 214
*/
@CanIgnoreReturnValue
public static final class Builder {
private long[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new long[initialCapacity];
}
Reported by PMD.
Line: 215
@CanIgnoreReturnValue
public static final class Builder {
private long[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new long[initialCapacity];
}
Reported by PMD.
Line: 215
@CanIgnoreReturnValue
public static final class Builder {
private long[] array;
private int count = 0; // <= array.length
Builder(int initialCapacity) {
array = new long[initialCapacity];
}
Reported by PMD.
Line: 275
*/
public Builder addAll(LongStream stream) {
Spliterator.OfLong spliterator = stream.spliterator();
long size = spliterator.getExactSizeIfKnown();
if (size > 0) { // known *and* nonempty
ensureRoomFor(Ints.saturatedCast(size));
}
spliterator.forEachRemaining((LongConsumer) this::add);
return this;
Reported by PMD.