The following issues were found
guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java
40 issues
Line: 49
*/
public class ConcurrentHashMultisetBenchmark {
@Param({"1", "2", "4", "8"})
int threads;
@Param({"3", "30", "300"})
int size;
@Param MultisetSupplier implSupplier;
Reported by PMD.
Line: 52
int threads;
@Param({"3", "30", "300"})
int size;
@Param MultisetSupplier implSupplier;
private Multiset<Integer> multiset;
private ImmutableList<Integer> keys;
Reported by PMD.
Line: 54
@Param({"3", "30", "300"})
int size;
@Param MultisetSupplier implSupplier;
private Multiset<Integer> multiset;
private ImmutableList<Integer> keys;
private ExecutorService threadPool;
Reported by PMD.
Line: 56
@Param MultisetSupplier implSupplier;
private Multiset<Integer> multiset;
private ImmutableList<Integer> keys;
private ExecutorService threadPool;
@BeforeExperiment
void setUp() throws Exception {
Reported by PMD.
Line: 57
@Param MultisetSupplier implSupplier;
private Multiset<Integer> multiset;
private ImmutableList<Integer> keys;
private ExecutorService threadPool;
@BeforeExperiment
void setUp() throws Exception {
multiset = implSupplier.get();
Reported by PMD.
Line: 58
private Multiset<Integer> multiset;
private ImmutableList<Integer> keys;
private ExecutorService threadPool;
@BeforeExperiment
void setUp() throws Exception {
multiset = implSupplier.get();
ImmutableList.Builder<Integer> builder = ImmutableList.builder();
Reported by PMD.
Line: 60
private ImmutableList<Integer> keys;
private ExecutorService threadPool;
@BeforeExperiment
void setUp() throws Exception {
multiset = implSupplier.get();
ImmutableList.Builder<Integer> builder = ImmutableList.builder();
for (int i = 0; i < size; i++) {
builder.add(i);
Reported by PMD.
Line: 61
private ExecutorService threadPool;
@BeforeExperiment
void setUp() throws Exception {
multiset = implSupplier.get();
ImmutableList.Builder<Integer> builder = ImmutableList.builder();
for (int i = 0; i < size; i++) {
builder.add(i);
}
Reported by PMD.
Line: 168
* Duplication of the old version of ConcurrentHashMultiset (with some unused stuff removed, like
* serialization code) which used a map with boxed integers for the values.
*/
private static final class OldConcurrentHashMultiset<E> extends AbstractMultiset<E> {
/** The number of occurrences of each element. */
private final transient ConcurrentMap<E, Integer> countMap;
/**
* Creates a new, empty {@code OldConcurrentHashMultiset} using the default initial capacity,
Reported by PMD.
Line: 168
* Duplication of the old version of ConcurrentHashMultiset (with some unused stuff removed, like
* serialization code) which used a map with boxed integers for the values.
*/
private static final class OldConcurrentHashMultiset<E> extends AbstractMultiset<E> {
/** The number of occurrences of each element. */
private final transient ConcurrentMap<E, Integer> countMap;
/**
* Creates a new, empty {@code OldConcurrentHashMultiset} using the default initial capacity,
Reported by PMD.
guava-tests/test/com/google/common/collect/PeekingIteratorTest.java
39 issues
Line: 53
* #remove()}.
*/
private static class PeekingIteratorTester<T> extends IteratorTester<T> {
private Iterable<T> master;
private List<T> targetList;
public PeekingIteratorTester(Collection<T> master) {
super(master.size() + 3, MODIFIABLE, master, IteratorTester.KnownOrder.KNOWN_ORDER);
this.master = master;
Reported by PMD.
Line: 72
@Override
protected void verify(List<T> elements) {
// verify same objects were removed from reference and target
assertEquals(elements, targetList);
}
}
private <T> void actsLikeIteratorHelper(final List<T> list) {
// Check with modifiable copies of the list
Reported by PMD.
Line: 85
list.size() * 2 + 2, UNMODIFIABLE, list, IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<T> newTargetIterator() {
Iterator<T> iterator = Collections.unmodifiableList(list).iterator();
return Iterators.peekingIterator(iterator);
}
}.test();
}
Reported by PMD.
Line: 91
}.test();
}
public void testPeekingIteratorBehavesLikeIteratorOnEmptyIterable() {
actsLikeIteratorHelper(Collections.emptyList());
}
public void testPeekingIteratorBehavesLikeIteratorOnSingletonIterable() {
actsLikeIteratorHelper(Collections.singletonList(new Object()));
Reported by PMD.
Line: 91
}.test();
}
public void testPeekingIteratorBehavesLikeIteratorOnEmptyIterable() {
actsLikeIteratorHelper(Collections.emptyList());
}
public void testPeekingIteratorBehavesLikeIteratorOnSingletonIterable() {
actsLikeIteratorHelper(Collections.singletonList(new Object()));
Reported by PMD.
Line: 95
actsLikeIteratorHelper(Collections.emptyList());
}
public void testPeekingIteratorBehavesLikeIteratorOnSingletonIterable() {
actsLikeIteratorHelper(Collections.singletonList(new Object()));
}
// TODO(cpovirk): instead of skipping, use a smaller number of steps
@GwtIncompatible // works but takes 5 minutes to run
Reported by PMD.
Line: 95
actsLikeIteratorHelper(Collections.emptyList());
}
public void testPeekingIteratorBehavesLikeIteratorOnSingletonIterable() {
actsLikeIteratorHelper(Collections.singletonList(new Object()));
}
// TODO(cpovirk): instead of skipping, use a smaller number of steps
@GwtIncompatible // works but takes 5 minutes to run
Reported by PMD.
Line: 100
}
// TODO(cpovirk): instead of skipping, use a smaller number of steps
@GwtIncompatible // works but takes 5 minutes to run
public void testPeekingIteratorBehavesLikeIteratorOnThreeElementIterable() {
actsLikeIteratorHelper(Lists.newArrayList("A", "B", "C"));
}
@GwtIncompatible // works but takes 5 minutes to run
Reported by PMD.
Line: 101
// TODO(cpovirk): instead of skipping, use a smaller number of steps
@GwtIncompatible // works but takes 5 minutes to run
public void testPeekingIteratorBehavesLikeIteratorOnThreeElementIterable() {
actsLikeIteratorHelper(Lists.newArrayList("A", "B", "C"));
}
@GwtIncompatible // works but takes 5 minutes to run
public void testPeekingIteratorAcceptsNullElements() {
Reported by PMD.
Line: 105
actsLikeIteratorHelper(Lists.newArrayList("A", "B", "C"));
}
@GwtIncompatible // works but takes 5 minutes to run
public void testPeekingIteratorAcceptsNullElements() {
actsLikeIteratorHelper(Lists.newArrayList(null, "A", null));
}
public void testPeekOnEmptyList() {
Reported by PMD.
guava-tests/test/com/google/common/collect/MapsCollectionTest.java
39 issues
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.checkNotNull;
import static com.google.common.collect.testing.Helpers.mapEntry;
Reported by PMD.
Line: 62
*
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
Reported by PMD.
Line: 62
*
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
Reported by PMD.
Line: 62
*
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
Reported by PMD.
Line: 62
*
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
Reported by PMD.
Line: 63
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
Reported by PMD.
Line: 63
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
Reported by PMD.
Line: 63
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
Reported by PMD.
Line: 63
* @author Louis Wasserman
*/
public class MapsCollectionTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
Reported by PMD.
Line: 120
Set<String> set = Sets.newLinkedHashSet();
for (Object e : elements) {
Entry<?, ?> entry = (Entry<?, ?>) e;
checkNotNull(entry.getValue());
set.add((String) checkNotNull(entry.getKey()));
}
return Maps.asMap(
set,
new Function<String, Integer>() {
Reported by PMD.
guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
39 issues
Line: 37
*/
public class LittleEndianDataInputStreamTest extends TestCase {
private byte[] data;
@Override
protected void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 39
private byte[] data;
@Override
protected void setUp() throws Exception {
super.setUp();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
Reported by PMD.
Line: 69
out.writeDouble(Double.longBitsToDouble(0xDEADBEEFCAFEBABEL));
}
public void testReadFully() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data));
byte[] b = new byte[data.length];
in.readFully(b);
assertEquals(Bytes.asList(data), Bytes.asList(b));
}
Reported by PMD.
Line: 73
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data));
byte[] b = new byte[data.length];
in.readFully(b);
assertEquals(Bytes.asList(data), Bytes.asList(b));
}
public void testReadUnsignedByte_eof() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
try {
Reported by PMD.
Line: 76
assertEquals(Bytes.asList(data), Bytes.asList(b));
}
public void testReadUnsignedByte_eof() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
try {
in.readUnsignedByte();
fail();
} catch (EOFException expected) {
Reported by PMD.
Line: 80
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
try {
in.readUnsignedByte();
fail();
} catch (EOFException expected) {
}
}
public void testReadUnsignedShort_eof() throws IOException {
Reported by PMD.
Line: 80
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
try {
in.readUnsignedByte();
fail();
} catch (EOFException expected) {
}
}
public void testReadUnsignedShort_eof() throws IOException {
Reported by PMD.
Line: 85
}
}
public void testReadUnsignedShort_eof() throws IOException {
byte[] buf = {23};
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf));
try {
in.readUnsignedShort();
fail();
Reported by PMD.
Line: 90
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf));
try {
in.readUnsignedShort();
fail();
} catch (EOFException expected) {
}
}
public void testReadLine() throws IOException {
Reported by PMD.
Line: 90
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf));
try {
in.readUnsignedShort();
fail();
} catch (EOFException expected) {
}
}
public void testReadLine() throws IOException {
Reported by PMD.
guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java
39 issues
Line: 37
*/
@GwtCompatible
public class EquivalenceTesterTest extends TestCase {
private EquivalenceTester<Object> tester;
private MockEquivalence equivalenceMock;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 38
@GwtCompatible
public class EquivalenceTesterTest extends TestCase {
private EquivalenceTester<Object> tester;
private MockEquivalence equivalenceMock;
@Override
public void setUp() throws Exception {
super.setUp();
this.equivalenceMock = new MockEquivalence();
Reported by PMD.
Line: 40
private EquivalenceTester<Object> tester;
private MockEquivalence equivalenceMock;
@Override
public void setUp() throws Exception {
super.setUp();
this.equivalenceMock = new MockEquivalence();
this.tester = EquivalenceTester.of(equivalenceMock);
}
Reported by PMD.
Line: 48
}
/** Test null reference yields error */
public void testOf_NullPointerException() {
try {
EquivalenceTester.of(null);
fail("Should fail on null reference");
} catch (NullPointerException expected) {
}
Reported by PMD.
Line: 51
public void testOf_NullPointerException() {
try {
EquivalenceTester.of(null);
fail("Should fail on null reference");
} catch (NullPointerException expected) {
}
}
public void testTest_NoData() {
Reported by PMD.
Line: 52
try {
EquivalenceTester.of(null);
fail("Should fail on null reference");
} catch (NullPointerException expected) {
}
}
public void testTest_NoData() {
tester.test();
Reported by PMD.
Line: 52
try {
EquivalenceTester.of(null);
fail("Should fail on null reference");
} catch (NullPointerException expected) {
}
}
public void testTest_NoData() {
tester.test();
Reported by PMD.
Line: 56
}
}
public void testTest_NoData() {
tester.test();
}
public void testTest() {
Object group1Item1 = new TestObject(1, 1);
Reported by PMD.
Line: 56
}
}
public void testTest_NoData() {
tester.test();
}
public void testTest() {
Object group1Item1 = new TestObject(1, 1);
Reported by PMD.
Line: 60
tester.test();
}
public void testTest() {
Object group1Item1 = new TestObject(1, 1);
Object group1Item2 = new TestObject(1, 2);
Object group2Item1 = new TestObject(2, 1);
Object group2Item2 = new TestObject(2, 2);
Reported by PMD.
guava-tests/test/com/google/common/hash/Crc32cHashFunctionTest.java
39 issues
Line: 29
* @author Patrick Costello
* @author Kurt Alfred Kluever
*/
public class Crc32cHashFunctionTest extends TestCase {
public void testEmpty() {
assertCrc(0, new byte[0]);
}
public void testZeros() {
Reported by PMD.
Line: 30
* @author Kurt Alfred Kluever
*/
public class Crc32cHashFunctionTest extends TestCase {
public void testEmpty() {
assertCrc(0, new byte[0]);
}
public void testZeros() {
// Test 32 byte array of 0x00.
Reported by PMD.
Line: 34
assertCrc(0, new byte[0]);
}
public void testZeros() {
// Test 32 byte array of 0x00.
byte[] zeros = new byte[32];
assertCrc(0x8a9136aa, zeros);
}
Reported by PMD.
Line: 40
assertCrc(0x8a9136aa, zeros);
}
public void testZeros100() {
// Test 100 byte array of 0x00.
byte[] zeros = new byte[100];
assertCrc(0x07cb9ff6, zeros);
}
Reported by PMD.
Line: 46
assertCrc(0x07cb9ff6, zeros);
}
public void testFull() {
// Test 32 byte array of 0xFF.
byte[] fulls = new byte[32];
Arrays.fill(fulls, (byte) 0xFF);
assertCrc(0x62a8ab43, fulls);
}
Reported by PMD.
Line: 53
assertCrc(0x62a8ab43, fulls);
}
public void testFull100() {
// Test 100 byte array of 0xFF.
byte[] fulls = new byte[100];
Arrays.fill(fulls, (byte) 0xFF);
assertCrc(0xbc753add, fulls);
}
Reported by PMD.
Line: 60
assertCrc(0xbc753add, fulls);
}
public void testAscending() {
// Test 32 byte arrays of ascending.
byte[] ascending = new byte[32];
for (int i = 0; i < 32; i++) {
ascending[i] = (byte) i;
}
Reported by PMD.
Line: 69
assertCrc(0x46dd794e, ascending);
}
public void testDescending() {
// Test 32 byte arrays of descending.
byte[] descending = new byte[32];
for (int i = 0; i < 32; i++) {
descending[i] = (byte) (31 - i);
}
Reported by PMD.
Line: 78
assertCrc(0x113fdb5c, descending);
}
public void testDescending100() {
// Test 100 byte arrays of descending.
byte[] descending = new byte[100];
for (int i = 0; i < 100; i++) {
descending[i] = (byte) (99 - i);
}
Reported by PMD.
Line: 87
assertCrc(0xd022db97, descending);
}
public void testScsiReadCommand() {
// Test SCSI read command.
byte[] scsiReadCommand =
new byte[] {
0x01, (byte) 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
Reported by PMD.
android/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-testlib/src/com/google/common/collect/testing/Helpers.java
39 issues
Line: 456
protected NullsBefore(String justAfterNull) {
if (justAfterNull == null) {
throw new NullPointerException();
}
this.justAfterNull = justAfterNull;
}
Reported by PMD.
Line: 44
import junit.framework.AssertionFailedError;
@GwtCompatible(emulated = true)
public class Helpers {
// Clone of Objects.equal
static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
Reported by PMD.
Line: 44
import junit.framework.AssertionFailedError;
@GwtCompatible(emulated = true)
public class Helpers {
// Clone of Objects.equal
static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
Reported by PMD.
Line: 44
import junit.framework.AssertionFailedError;
@GwtCompatible(emulated = true)
public class Helpers {
// Clone of Objects.equal
static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
Reported by PMD.
Line: 44
import junit.framework.AssertionFailedError;
@GwtCompatible(emulated = true)
public class Helpers {
// Clone of Objects.equal
static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
Reported by PMD.
Line: 44
import junit.framework.AssertionFailedError;
@GwtCompatible(emulated = true)
public class Helpers {
// Clone of Objects.equal
static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
Reported by PMD.
Line: 47
public class Helpers {
// Clone of Objects.equal
static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
// Clone of Lists.newArrayList
public static <E> List<E> copyToList(Iterable<? extends E> elements) {
List<E> list = new ArrayList<E>();
Reported by PMD.
Line: 74
// Would use Maps.immutableEntry
public static <K, V> Entry<K, V> mapEntry(K key, V value) {
return Collections.singletonMap(key, value).entrySet().iterator().next();
}
private static boolean isEmpty(Iterable<?> iterable) {
return iterable instanceof Collection
? ((Collection<?>) iterable).isEmpty()
Reported by PMD.
Line: 74
// Would use Maps.immutableEntry
public static <K, V> Entry<K, V> mapEntry(K key, V value) {
return Collections.singletonMap(key, value).entrySet().iterator().next();
}
private static boolean isEmpty(Iterable<?> iterable) {
return iterable instanceof Collection
? ((Collection<?>) iterable).isEmpty()
Reported by PMD.
Line: 74
// Would use Maps.immutableEntry
public static <K, V> Entry<K, V> mapEntry(K key, V value) {
return Collections.singletonMap(key, value).entrySet().iterator().next();
}
private static boolean isEmpty(Iterable<?> iterable) {
return iterable instanceof Collection
? ((Collection<?>) iterable).isEmpty()
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapKeysTester.java
39 issues
Line: 44
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapKeysTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(SEVERAL)
public void testKeys() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k1(), v0()));
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(k0()));
Reported by PMD.
Line: 45
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapKeysTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(SEVERAL)
public void testKeys() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k1(), v0()));
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(k0()));
assertEquals(1, keys.count(k1()));
Reported by PMD.
Line: 48
public void testKeys() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k1(), v0()));
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(k0()));
assertEquals(1, keys.count(k1()));
assertEquals(3, keys.size());
assertContainsAllOf(keys, k0(), k1());
assertContainsAllOf(
Reported by PMD.
Line: 49
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k1(), v0()));
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(k0()));
assertEquals(1, keys.count(k1()));
assertEquals(3, keys.size());
assertContainsAllOf(keys, k0(), k1());
assertContainsAllOf(
keys.entrySet(), Multisets.immutableEntry(k0(), 2), Multisets.immutableEntry(k1(), 1));
Reported by PMD.
Line: 50
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k1(), v0()));
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(k0()));
assertEquals(1, keys.count(k1()));
assertEquals(3, keys.size());
assertContainsAllOf(keys, k0(), k1());
assertContainsAllOf(
keys.entrySet(), Multisets.immutableEntry(k0(), 2), Multisets.immutableEntry(k1(), 1));
}
Reported by PMD.
Line: 51
Multiset<K> keys = multimap().keys();
assertEquals(2, keys.count(k0()));
assertEquals(1, keys.count(k1()));
assertEquals(3, keys.size());
assertContainsAllOf(keys, k0(), k1());
assertContainsAllOf(
keys.entrySet(), Multisets.immutableEntry(k0(), 2), Multisets.immutableEntry(k1(), 1));
}
Reported by PMD.
Line: 54
assertEquals(3, keys.size());
assertContainsAllOf(keys, k0(), k1());
assertContainsAllOf(
keys.entrySet(), Multisets.immutableEntry(k0(), 2), Multisets.immutableEntry(k1(), 1));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeysCountAbsentNullKey() {
assertEquals(0, multimap().keys().count(null));
Reported by PMD.
Line: 57
keys.entrySet(), Multisets.immutableEntry(k0(), 2), Multisets.immutableEntry(k1(), 1));
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeysCountAbsentNullKey() {
assertEquals(0, multimap().keys().count(null));
}
@CollectionSize.Require(SEVERAL)
Reported by PMD.
Line: 59
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeysCountAbsentNullKey() {
assertEquals(0, multimap().keys().count(null));
}
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeysWithNullKey() {
Reported by PMD.
Line: 59
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testKeysCountAbsentNullKey() {
assertEquals(0, multimap().keys().count(null));
}
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeysWithNullKey() {
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableList.java
39 issues
Line: 648
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.checkPositionIndex;
Reported by PMD.
Line: 61
@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 the empty immutable list. This list behaves and performs comparably to {@link
* Collections#emptyList}, and is preferable mainly for consistency and maintainability of your
* code.
Reported by PMD.
Line: 62
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
/**
* Returns the empty immutable list. This list behaves and performs comparably to {@link
* Collections#emptyList}, and is preferable mainly for consistency and maintainability of your
* code.
*
Reported by PMD.
Line: 71
* <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: 164
*
* @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: 174
*
* @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: 191
* @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: 247
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.
Line: 247
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.