The following issues were found
guava-tests/test/com/google/common/io/SourceSinkTester.java
10 issues
Line: 39
* @author Colin Decker
*/
@AndroidIncompatible // Android doesn't understand tests that lack default constructors.
public class SourceSinkTester<S, T, F extends SourceSinkFactory<S, T>> extends TestCase {
static final String LOREM_IPSUM =
"Lorem ipsum dolor sit amet, consectetur adipiscing "
+ "elit. Cras fringilla elit ac ipsum adipiscing vulputate. Maecenas in lorem nulla, ac "
+ "sollicitudin quam. Praesent neque elit, sodales quis vestibulum vel, pellentesque nec "
Reported by PMD.
Line: 74
.put("lorem ipsum", LOREM_IPSUM)
.build();
protected final F factory;
protected final T data;
protected final T expected;
private final String suiteName;
private final String caseDesc;
Reported by PMD.
Line: 75
.build();
protected final F factory;
protected final T data;
protected final T expected;
private final String suiteName;
private final String caseDesc;
Reported by PMD.
Line: 76
protected final F factory;
protected final T data;
protected final T expected;
private final String suiteName;
private final String caseDesc;
SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) {
Reported by PMD.
Line: 78
protected final T data;
protected final T expected;
private final String suiteName;
private final String caseDesc;
SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) {
super(method.getName());
this.factory = checkNotNull(factory);
Reported by PMD.
Line: 79
protected final T expected;
private final String suiteName;
private final String caseDesc;
SourceSinkTester(F factory, T data, String suiteName, String caseDesc, Method method) {
super(method.getName());
this.factory = checkNotNull(factory);
this.data = checkNotNull(data);
Reported by PMD.
Line: 104
}
}.readLines();
} catch (IOException e) {
throw new AssertionError();
}
}
@Override
public void tearDown() throws IOException {
Reported by PMD.
Line: 108
}
}
@Override
public void tearDown() throws IOException {
factory.tearDown();
}
static ImmutableList<Method> getTestMethods(Class<?> testClass) {
Reported by PMD.
Line: 118
for (Method method : testClass.getDeclaredMethods()) {
if (Modifier.isPublic(method.getModifiers())
&& method.getReturnType() == void.class
&& method.getParameterTypes().length == 0
&& method.getName().startsWith("test")) {
result.add(method);
}
}
return ImmutableList.copyOf(result);
Reported by PMD.
Line: 119
if (Modifier.isPublic(method.getModifiers())
&& method.getReturnType() == void.class
&& method.getParameterTypes().length == 0
&& method.getName().startsWith("test")) {
result.add(method);
}
}
return ImmutableList.copyOf(result);
}
Reported by PMD.
guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
10 issues
Line: 33
*/
public class PatternFilenameFilterTest extends TestCase {
public void testSyntaxException() {
try {
new PatternFilenameFilter("(");
fail("expected exception");
} catch (PatternSyntaxException expected) {
}
Reported by PMD.
Line: 36
public void testSyntaxException() {
try {
new PatternFilenameFilter("(");
fail("expected exception");
} catch (PatternSyntaxException expected) {
}
}
public void testAccept() {
Reported by PMD.
Line: 41
}
}
public void testAccept() {
File dir = new File("foo");
FilenameFilter filter = new PatternFilenameFilter("a+");
assertTrue(filter.accept(dir, "a"));
assertTrue(filter.accept(dir, "aaaa"));
assertFalse(filter.accept(dir, "b"));
Reported by PMD.
Line: 41
}
}
public void testAccept() {
File dir = new File("foo");
FilenameFilter filter = new PatternFilenameFilter("a+");
assertTrue(filter.accept(dir, "a"));
assertTrue(filter.accept(dir, "aaaa"));
assertFalse(filter.accept(dir, "b"));
Reported by PMD.
Line: 44
public void testAccept() {
File dir = new File("foo");
FilenameFilter filter = new PatternFilenameFilter("a+");
assertTrue(filter.accept(dir, "a"));
assertTrue(filter.accept(dir, "aaaa"));
assertFalse(filter.accept(dir, "b"));
// Show that dir is ignored
assertTrue(filter.accept(null, "a"));
Reported by PMD.
Line: 45
File dir = new File("foo");
FilenameFilter filter = new PatternFilenameFilter("a+");
assertTrue(filter.accept(dir, "a"));
assertTrue(filter.accept(dir, "aaaa"));
assertFalse(filter.accept(dir, "b"));
// Show that dir is ignored
assertTrue(filter.accept(null, "a"));
}
Reported by PMD.
Line: 46
FilenameFilter filter = new PatternFilenameFilter("a+");
assertTrue(filter.accept(dir, "a"));
assertTrue(filter.accept(dir, "aaaa"));
assertFalse(filter.accept(dir, "b"));
// Show that dir is ignored
assertTrue(filter.accept(null, "a"));
}
Reported by PMD.
Line: 49
assertFalse(filter.accept(dir, "b"));
// Show that dir is ignored
assertTrue(filter.accept(null, "a"));
}
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
Reported by PMD.
Line: 52
assertTrue(filter.accept(null, "a"));
}
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testConstructors(PatternFilenameFilter.class, Visibility.PACKAGE);
tester.testStaticMethods(PatternFilenameFilter.class, Visibility.PACKAGE); // currently none
Reported by PMD.
Line: 52
assertTrue(filter.accept(null, "a"));
}
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testConstructors(PatternFilenameFilter.class, Visibility.PACKAGE);
tester.testStaticMethods(PatternFilenameFilter.class, Visibility.PACKAGE); // currently none
Reported by PMD.
guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
10 issues
Line: 32
*/
public class StandardSystemPropertyTest extends TestCase {
public void testGetKeyMatchesString() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
String fieldName = property.name();
String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
assertEquals(expected, property.key());
}
Reported by PMD.
Line: 35
public void testGetKeyMatchesString() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
String fieldName = property.name();
String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
assertEquals(expected, property.key());
}
}
public void testGetValue() {
Reported by PMD.
Line: 36
for (StandardSystemProperty property : StandardSystemProperty.values()) {
String fieldName = property.name();
String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
assertEquals(expected, property.key());
}
}
public void testGetValue() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
Reported by PMD.
Line: 40
}
}
public void testGetValue() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
assertEquals(System.getProperty(property.key()), property.value());
}
}
Reported by PMD.
Line: 42
public void testGetValue() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
assertEquals(System.getProperty(property.key()), property.value());
}
}
public void testToString() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
Reported by PMD.
Line: 46
}
}
public void testToString() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
assertEquals(property.key() + "=" + property.value(), property.toString());
}
}
Reported by PMD.
Line: 48
public void testToString() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
assertEquals(property.key() + "=" + property.value(), property.toString());
}
}
public void testNoNullValues() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
Reported by PMD.
Line: 52
}
}
public void testNoNullValues() {
for (StandardSystemProperty property : StandardSystemProperty.values()) {
// Even though the contract in System.getProperties() specifies that a value will exist for
// all of the listed keys, for some reason the "java.compiler" key returns null in some JVMs.
if (property == JAVA_COMPILER) {
continue;
Reported by PMD.
Line: 64
if (property == JAVA_EXT_DIRS) {
continue;
}
assertWithMessage(property.toString()).that(property.value()).isNotNull();
}
}
}
Reported by PMD.
Line: 64
if (property == JAVA_EXT_DIRS) {
continue;
}
assertWithMessage(property.toString()).that(property.value()).isNotNull();
}
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java
10 issues
Line: 41
* @author Louis Wasserman
*/
public class ForwardingSortedMultisetTest extends TestCase {
static class StandardImplForwardingSortedMultiset<E> extends ForwardingSortedMultiset<E> {
private final SortedMultiset<E> backingMultiset;
StandardImplForwardingSortedMultiset(SortedMultiset<E> backingMultiset) {
this.backingMultiset = backingMultiset;
}
Reported by PMD.
Line: 42
*/
public class ForwardingSortedMultisetTest extends TestCase {
static class StandardImplForwardingSortedMultiset<E> extends ForwardingSortedMultiset<E> {
private final SortedMultiset<E> backingMultiset;
StandardImplForwardingSortedMultiset(SortedMultiset<E> backingMultiset) {
this.backingMultiset = backingMultiset;
}
Reported by PMD.
Line: 59
@Override
Iterator<Entry<E>> entryIterator() {
return backingMultiset.descendingMultiset().entrySet().iterator();
}
};
}
@Override
Reported by PMD.
Line: 59
@Override
Iterator<Entry<E>> entryIterator() {
return backingMultiset.descendingMultiset().entrySet().iterator();
}
};
}
@Override
Reported by PMD.
Line: 176
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingSortedMultisetTest.class);
suite.addTest(
SortedMultisetTestSuiteBuilder.using(
Reported by PMD.
Line: 191
@Override
public List<String> order(List<String> insertionOrder) {
return Ordering.natural().sortedCopy(insertionOrder);
}
})
.named("ForwardingSortedMultiset with standard impls")
.withFeatures(
CollectionSize.ANY,
Reported by PMD.
Line: 205
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
SortedMultiset.class,
new Function<SortedMultiset, SortedMultiset>() {
Reported by PMD.
Line: 206
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
SortedMultiset.class,
new Function<SortedMultiset, SortedMultiset>() {
@Override
Reported by PMD.
Line: 218
});
}
public void testEquals() {
SortedMultiset<String> set1 = ImmutableSortedMultiset.of("one");
SortedMultiset<String> set2 = ImmutableSortedMultiset.of("two");
new EqualsTester()
.addEqualityGroup(set1, wrap(set1), wrap(set1))
.addEqualityGroup(set2, wrap(set2))
Reported by PMD.
Line: 218
});
}
public void testEquals() {
SortedMultiset<String> set1 = ImmutableSortedMultiset.of("one");
SortedMultiset<String> set2 = ImmutableSortedMultiset.of("two");
new EqualsTester()
.addEqualityGroup(set1, wrap(set1), wrap(set1))
.addEqualityGroup(set2, wrap(set2))
Reported by PMD.
guava-tests/test/com/google/common/io/FlushablesTest.java
10 issues
Line: 36
* @author Michael Lancaster
*/
public class FlushablesTest extends TestCase {
private Flushable mockFlushable;
public void testFlush_clean() throws IOException {
// make sure that no exception is thrown regardless of value of
// 'swallowException' when the mock does not throw an exception.
setupFlushable(false);
Reported by PMD.
Line: 38
public class FlushablesTest extends TestCase {
private Flushable mockFlushable;
public void testFlush_clean() throws IOException {
// make sure that no exception is thrown regardless of value of
// 'swallowException' when the mock does not throw an exception.
setupFlushable(false);
doFlush(mockFlushable, false, false);
Reported by PMD.
Line: 38
public class FlushablesTest extends TestCase {
private Flushable mockFlushable;
public void testFlush_clean() throws IOException {
// make sure that no exception is thrown regardless of value of
// 'swallowException' when the mock does not throw an exception.
setupFlushable(false);
doFlush(mockFlushable, false, false);
Reported by PMD.
Line: 48
doFlush(mockFlushable, true, false);
}
public void testFlush_flushableWithEatenException() throws IOException {
// make sure that no exception is thrown if 'swallowException' is true
// when the mock does throw an exception on flush.
setupFlushable(true);
doFlush(mockFlushable, true, false);
}
Reported by PMD.
Line: 48
doFlush(mockFlushable, true, false);
}
public void testFlush_flushableWithEatenException() throws IOException {
// make sure that no exception is thrown if 'swallowException' is true
// when the mock does throw an exception on flush.
setupFlushable(true);
doFlush(mockFlushable, true, false);
}
Reported by PMD.
Line: 55
doFlush(mockFlushable, true, false);
}
public void testFlush_flushableWithThrownException() throws IOException {
// make sure that the exception is thrown if 'swallowException' is false
// when the mock does throw an exception on flush.
setupFlushable(true);
doFlush(mockFlushable, false, true);
}
Reported by PMD.
Line: 55
doFlush(mockFlushable, true, false);
}
public void testFlush_flushableWithThrownException() throws IOException {
// make sure that the exception is thrown if 'swallowException' is false
// when the mock does throw an exception on flush.
setupFlushable(true);
doFlush(mockFlushable, false, true);
}
Reported by PMD.
Line: 62
doFlush(mockFlushable, false, true);
}
public void testFlushQuietly_flushableWithEatenException() throws IOException {
// make sure that no exception is thrown by flushQuietly when the mock does
// throw an exception on flush.
setupFlushable(true);
Flushables.flushQuietly(mockFlushable);
}
Reported by PMD.
Line: 62
doFlush(mockFlushable, false, true);
}
public void testFlushQuietly_flushableWithEatenException() throws IOException {
// make sure that no exception is thrown by flushQuietly when the mock does
// throw an exception on flush.
setupFlushable(true);
Flushables.flushQuietly(mockFlushable);
}
Reported by PMD.
Line: 97
fail("Threw exception");
}
}
verify(flushable).flush();
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/NewCustomTableTest.java
10 issues
Line: 49
return table;
}
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
Reported by PMD.
Line: 50
}
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
Reported by PMD.
Line: 51
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
Reported by PMD.
Line: 51
public void testRowKeySetOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
Reported by PMD.
Line: 54
assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
}
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 56
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 56
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 56
public void testRowOrdering() {
table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
assertThat(table.row("foo").keySet()).containsExactly(2, 3).inOrder();
}
}
Reported by PMD.
Line: 36
@Override
protected Table<String, Integer, Character> create(Object... data) {
Supplier<TreeMap<Integer, Character>> factory =
new Supplier<TreeMap<Integer, Character>>() {
@Override
public TreeMap<Integer, Character> get() {
return Maps.newTreeMap();
}
Reported by PMD.
Line: 36
@Override
protected Table<String, Integer, Character> create(Object... data) {
Supplier<TreeMap<Integer, Character>> factory =
new Supplier<TreeMap<Integer, Character>>() {
@Override
public TreeMap<Integer, Character> get() {
return Maps.newTreeMap();
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/ListRetainAllTester.java
10 issues
Line: 41
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class ListRetainAllTester<E> extends AbstractListTester<E> {
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testRetainAll_duplicatesKept() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
Reported by PMD.
Line: 46
public void testRetainAll_duplicatesKept() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
assertFalse(
"containsDuplicates.retainAll(superset) should return false",
collection.retainAll(MinimalCollection.of(createSamplesArray())));
expectContents(array);
}
Reported by PMD.
Line: 53
expectContents(array);
}
@SuppressWarnings("unchecked")
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRetainAll_duplicatesRemoved() {
E[] array = createSamplesArray();
array[1] = e0();
Reported by PMD.
Line: 59
public void testRetainAll_duplicatesRemoved() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
assertTrue(
"containsDuplicates.retainAll(subset) should return true",
collection.retainAll(MinimalCollection.of(e2())));
expectContents(e2());
}
Reported by PMD.
Line: 66
expectContents(e2());
}
@SuppressWarnings("unchecked")
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRetainAll_countIgnored() {
resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
Reported by PMD.
Line: 69
@SuppressWarnings("unchecked")
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRetainAll_countIgnored() {
resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
assertContentsInOrder(getList(), e0(), e1(), e0());
}
}
Reported by PMD.
Line: 70
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRetainAll_countIgnored() {
resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
assertContentsInOrder(getList(), e0(), e1(), e0());
}
}
Reported by PMD.
Line: 71
@CollectionSize.Require(SEVERAL)
public void testRetainAll_countIgnored() {
resetContainer(getSubjectGenerator().create(e0(), e2(), e1(), e0()));
assertTrue(getList().retainAll(Arrays.asList(e0(), e1())));
assertContentsInOrder(getList(), e0(), e1(), e0());
}
}
Reported by PMD.
Line: 44
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testRetainAll_duplicatesKept() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
assertFalse(
"containsDuplicates.retainAll(superset) should return false",
collection.retainAll(MinimalCollection.of(createSamplesArray())));
Reported by PMD.
Line: 57
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRetainAll_duplicatesRemoved() {
E[] array = createSamplesArray();
array[1] = e0();
collection = getSubjectGenerator().create(array);
assertTrue(
"containsDuplicates.retainAll(subset) should return true",
collection.retainAll(MinimalCollection.of(e2())));
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapHashCodeTester.java
10 issues
Line: 39
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapHashCodeTester<K, V> extends AbstractMapTester<K, V> {
public void testHashCode() {
int expectedHashCode = 0;
for (Entry<K, V> entry : getSampleEntries()) {
expectedHashCode += hash(entry);
}
assertEquals(
Reported by PMD.
Line: 47
assertEquals(
"A Map's hashCode() should be the sum of those of its entries.",
expectedHashCode,
getMap().hashCode());
}
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testHashCode_containingNullKey() {
Reported by PMD.
Line: 50
getMap().hashCode());
}
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testHashCode_containingNullKey() {
Entry<K, V> entryWithNull = entry(null, v3());
runEntryWithNullTest(entryWithNull);
}
Reported by PMD.
Line: 57
runEntryWithNullTest(entryWithNull);
}
@CollectionSize.Require(absent = CollectionSize.ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testHashCode_containingNullValue() {
Entry<K, V> entryWithNull = entry(k3(), null);
runEntryWithNullTest(entryWithNull);
}
Reported by PMD.
Line: 67
private void runEntryWithNullTest(Entry<K, V> entryWithNull) {
Collection<Entry<K, V>> entries = getSampleEntries(getNumEntries() - 1);
entries.add(entryWithNull);
int expectedHashCode = 0;
for (Entry<K, V> entry : entries) {
expectedHashCode += hash(entry);
}
Reported by PMD.
Line: 74
expectedHashCode += hash(entry);
}
resetContainer(getSubjectGenerator().create(entries.toArray()));
assertEquals(
"A Map's hashCode() should be the sum of those of its entries (where "
+ "a null element in an entry counts as having a hash of zero).",
expectedHashCode,
getMap().hashCode());
Reported by PMD.
Line: 74
expectedHashCode += hash(entry);
}
resetContainer(getSubjectGenerator().create(entries.toArray()));
assertEquals(
"A Map's hashCode() should be the sum of those of its entries (where "
+ "a null element in an entry counts as having a hash of zero).",
expectedHashCode,
getMap().hashCode());
Reported by PMD.
Line: 79
"A Map's hashCode() should be the sum of those of its entries (where "
+ "a null element in an entry counts as having a hash of zero).",
expectedHashCode,
getMap().hashCode());
}
private static int hash(Entry<?, ?> e) {
return (e.getKey() == null ? 0 : e.getKey().hashCode())
^ (e.getValue() == null ? 0 : e.getValue().hashCode());
Reported by PMD.
Line: 83
}
private static int hash(Entry<?, ?> e) {
return (e.getKey() == null ? 0 : e.getKey().hashCode())
^ (e.getValue() == null ? 0 : e.getValue().hashCode());
}
}
Reported by PMD.
Line: 84
private static int hash(Entry<?, ?> e) {
return (e.getKey() == null ? 0 : e.getKey().hashCode())
^ (e.getValue() == null ? 0 : e.getValue().hashCode());
}
}
Reported by PMD.
guava-tests/benchmark/com/google/common/collect/SetContainsBenchmark.java
10 issues
Line: 35
// Start at 4.88 then multiply by 2*2^phi <evil cackle> - The goal is be uniform
// yet visit a variety of "values-relative-to-the-next-power-of-2"
@Param({"5", "30", "180", "1100", "6900", "43000", "260000"}) // "1600000", "9800000"
private int size;
// TODO(kevinb): look at exact (==) hits vs. equals() hits?
@Param({"0.2", "0.8"})
private double hitRate;
Reported by PMD.
Line: 39
// TODO(kevinb): look at exact (==) hits vs. equals() hits?
@Param({"0.2", "0.8"})
private double hitRate;
@Param("true")
private boolean isUserTypeFast;
// "" means no fixed seed
Reported by PMD.
Line: 42
private double hitRate;
@Param("true")
private boolean isUserTypeFast;
// "" means no fixed seed
@Param("")
private SpecialRandom random;
Reported by PMD.
Line: 46
// "" means no fixed seed
@Param("")
private SpecialRandom random;
@Param({"HashSetImpl", "ImmutableSetImpl"})
private SetImpl impl;
// the following must be set during setUp
Reported by PMD.
Line: 49
private SpecialRandom random;
@Param({"HashSetImpl", "ImmutableSetImpl"})
private SetImpl impl;
// the following must be set during setUp
private Element[] queries;
private Set<Element> setToTest;
Reported by PMD.
Line: 52
private SetImpl impl;
// the following must be set during setUp
private Element[] queries;
private Set<Element> setToTest;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
Reported by PMD.
Line: 53
// the following must be set during setUp
private Element[] queries;
private Set<Element> setToTest;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
new CollectionBenchmarkSampleData(isUserTypeFast, random, hitRate, size);
Reported by PMD.
Line: 55
private Element[] queries;
private Set<Element> setToTest;
@BeforeExperiment
void setUp() {
CollectionBenchmarkSampleData sampleData =
new CollectionBenchmarkSampleData(isUserTypeFast, random, hitRate, size);
this.setToTest = (Set<Element>) impl.create(sampleData.getValuesInSet());
Reported by PMD.
Line: 68
boolean contains(int reps) {
// Paranoia: acting on hearsay that accessing fields might be slow
// Should write a benchmark to test that!
Set<Element> set = setToTest;
Element[] queries = this.queries;
int mask = queries.length - 1;
boolean dummy = false;
Reported by PMD.
Line: 71
Set<Element> set = setToTest;
Element[] queries = this.queries;
int mask = queries.length - 1;
boolean dummy = false;
for (int i = 0; i < reps; i++) {
dummy ^= set.contains(queries[i & mask]);
}
Reported by PMD.
guava-tests/benchmark/com/google/common/collect/ImmutableListCreationBenchmark.java
10 issues
Line: 31
public class ImmutableListCreationBenchmark {
@Param({"10", "1000", "1000000"})
int size;
private static final Object OBJECT = new Object();
@Benchmark
int builderAdd(int reps) {
Reported by PMD.
Line: 44
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += builder.build().size();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 54
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
ImmutableList.Builder<Object> builder = new ImmutableList.Builder<>(size);
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += builder.build().size();
}
Reported by PMD.
Line: 58
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += builder.build().size();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 72
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
dummy += ImmutableList.copyOf(builder).size();
}
return dummy;
}
@Benchmark
Reported by PMD.
Line: 86
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
}
tmp += ImmutableList.copyOf(builder).size();
}
return tmp;
}
}
Reported by PMD.
Line: 37
@Benchmark
int builderAdd(int reps) {
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
ImmutableList.Builder<Object> builder = ImmutableList.builder();
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
Line: 51
@Benchmark
int preSizedBuilderAdd(int reps) {
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
ImmutableList.Builder<Object> builder = new ImmutableList.Builder<>(size);
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
Line: 65
@Benchmark
int copyArrayList(int reps) {
int size = this.size;
int dummy = 0;
for (int rep = 0; rep < reps; rep++) {
List<Object> builder = Lists.newArrayList();
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.
Line: 79
@Benchmark
int copyPreSizedArrayList(int reps) {
int size = this.size;
int tmp = 0;
for (int rep = 0; rep < reps; rep++) {
List<Object> builder = Lists.newArrayListWithCapacity(size);
for (int i = 0; i < size; i++) {
builder.add(OBJECT);
Reported by PMD.