The following issues were found
android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
55 issues
Line: 43
* @author Kevin Bourrillion
*/
public class ImmutableClassToInstanceMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ImmutableClassToInstanceMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 59
ImmutableClassToInstanceMap.builder();
for (Object object : elements) {
Entry<Class, Impl> entry = (Entry<Class, Impl>) object;
builder.put(entry.getKey(), entry.getValue());
}
return (Map) builder.build();
}
})
.named("ImmutableClassToInstanceMap")
Reported by PMD.
Line: 59
ImmutableClassToInstanceMap.builder();
for (Object object : elements) {
Entry<Class, Impl> entry = (Entry<Class, Impl>) object;
builder.put(entry.getKey(), entry.getValue());
}
return (Map) builder.build();
}
})
.named("ImmutableClassToInstanceMap")
Reported by PMD.
Line: 77
return suite;
}
public void testSerialization_empty() {
assertSame(
ImmutableClassToInstanceMap.of(),
SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
}
Reported by PMD.
Line: 78
}
public void testSerialization_empty() {
assertSame(
ImmutableClassToInstanceMap.of(),
SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
}
public void testCopyOf_map_empty() {
Reported by PMD.
Line: 83
SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
}
public void testCopyOf_map_empty() {
Map<Class<?>, Object> in = Collections.emptyMap();
ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
assertTrue(map.isEmpty());
assertSame(map, ImmutableClassToInstanceMap.of());
assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
Reported by PMD.
Line: 83
SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
}
public void testCopyOf_map_empty() {
Map<Class<?>, Object> in = Collections.emptyMap();
ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
assertTrue(map.isEmpty());
assertSame(map, ImmutableClassToInstanceMap.of());
assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
Reported by PMD.
Line: 86
public void testCopyOf_map_empty() {
Map<Class<?>, Object> in = Collections.emptyMap();
ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
assertTrue(map.isEmpty());
assertSame(map, ImmutableClassToInstanceMap.of());
assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
}
public void testOf_zero() {
Reported by PMD.
Line: 86
public void testCopyOf_map_empty() {
Map<Class<?>, Object> in = Collections.emptyMap();
ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
assertTrue(map.isEmpty());
assertSame(map, ImmutableClassToInstanceMap.of());
assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
}
public void testOf_zero() {
Reported by PMD.
Line: 87
Map<Class<?>, Object> in = Collections.emptyMap();
ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
assertTrue(map.isEmpty());
assertSame(map, ImmutableClassToInstanceMap.of());
assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
}
public void testOf_zero() {
assertTrue(ImmutableClassToInstanceMap.of().isEmpty());
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
55 issues
Line: 45
*/
@GwtIncompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
Reported by PMD.
Line: 47
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
Reported by PMD.
Line: 48
public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
Reported by PMD.
Line: 49
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 50
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 51
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (NavigableMap<K, V>) getMap();
Reported by PMD.
Line: 53
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (NavigableMap<K, V>) getMap();
entries =
Helpers.copyToList(
Reported by PMD.
Line: 59
navigableMap = (NavigableMap<K, V>) getMap();
entries =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
Reported by PMD.
Line: 60
entries =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
Reported by PMD.
Line: 60
entries =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
Reported by PMD.
guava-tests/test/com/google/common/collect/MultisetsImmutableEntryTest.java
55 issues
Line: 57
assertFalse(control("foo", 1).equals(entry("foo", 2)));
assertFalse(entry("foo", 1).equals(control("bar", 1)));
assertFalse(entry("foo", 1).equals(new Object()));
assertFalse(entry("foo", 1).equals(null));
}
public void testEqualsNull() {
assertEquals(control(NE, 1), entry(NE, 1));
assertFalse(control(NE, 1).equals(entry(NE, 2)));
Reported by PMD.
Line: 65
assertFalse(control(NE, 1).equals(entry(NE, 2)));
assertFalse(entry(NE, 1).equals(control("bar", 1)));
assertFalse(entry(NE, 1).equals(new Object()));
assertFalse(entry(NE, 1).equals(null));
}
public void testHashCode() {
assertEquals(control("foo", 1).hashCode(), entry("foo", 1).hashCode());
assertEquals(control("bar", 2).hashCode(), entry("bar", 2).hashCode());
Reported by PMD.
Line: 38
}
private static <E> Entry<E> control(E element, int count) {
return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
Reported by PMD.
Line: 38
}
private static <E> Entry<E> control(E element, int count) {
return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
Reported by PMD.
Line: 38
}
private static <E> Entry<E> control(E element, int count) {
return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
Reported by PMD.
Line: 41
return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
}
public void testToStringNull() {
Reported by PMD.
Line: 41
return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
}
public void testToStringNull() {
Reported by PMD.
Line: 42
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
}
public void testToStringNull() {
assertEquals("null", entry(NE, 1).toString());
Reported by PMD.
Line: 42
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
}
public void testToStringNull() {
assertEquals("null", entry(NE, 1).toString());
Reported by PMD.
Line: 42
}
public void testToString() {
assertEquals("foo", entry("foo", 1).toString());
assertEquals("bar x 2", entry("bar", 2).toString());
}
public void testToStringNull() {
assertEquals("null", entry(NE, 1).toString());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
55 issues
Line: 45
*/
@GwtIncompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
Reported by PMD.
Line: 47
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
Reported by PMD.
Line: 48
public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
Reported by PMD.
Line: 49
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 50
private NavigableMap<K, V> navigableMap;
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 51
private List<Entry<K, V>> entries;
private Entry<K, V> a;
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (NavigableMap<K, V>) getMap();
Reported by PMD.
Line: 53
private Entry<K, V> b;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (NavigableMap<K, V>) getMap();
entries =
Helpers.copyToList(
Reported by PMD.
Line: 59
navigableMap = (NavigableMap<K, V>) getMap();
entries =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
Reported by PMD.
Line: 60
entries =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
Reported by PMD.
Line: 60
entries =
Helpers.copyToList(
getSubjectGenerator()
.getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/CallablesTest.java
55 issues
Line: 38
@GwtCompatible(emulated = true)
public class CallablesTest extends TestCase {
public void testReturning() throws Exception {
assertNull(Callables.returning(null).call());
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
Reported by PMD.
Line: 38
@GwtCompatible(emulated = true)
public class CallablesTest extends TestCase {
public void testReturning() throws Exception {
assertNull(Callables.returning(null).call());
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
Reported by PMD.
Line: 39
public class CallablesTest extends TestCase {
public void testReturning() throws Exception {
assertNull(Callables.returning(null).call());
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
Reported by PMD.
Line: 39
public class CallablesTest extends TestCase {
public void testReturning() throws Exception {
assertNull(Callables.returning(null).call());
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
Reported by PMD.
Line: 43
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
assertSame(value, callable.call());
}
@GwtIncompatible
Reported by PMD.
Line: 43
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
assertSame(value, callable.call());
}
@GwtIncompatible
Reported by PMD.
Line: 45
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
assertSame(value, callable.call());
}
@GwtIncompatible
public void testAsAsyncCallable() throws Exception {
final String expected = "MyCallableString";
Reported by PMD.
Line: 45
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
assertSame(value, callable.call());
}
@GwtIncompatible
public void testAsAsyncCallable() throws Exception {
final String expected = "MyCallableString";
Reported by PMD.
Line: 48
assertSame(value, callable.call());
}
@GwtIncompatible
public void testAsAsyncCallable() throws Exception {
final String expected = "MyCallableString";
Callable<String> callable =
new Callable<String>() {
@Override
Reported by PMD.
Line: 62
AsyncCallable<String> asyncCallable =
Callables.asAsyncCallable(callable, MoreExecutors.newDirectExecutorService());
ListenableFuture<String> future = asyncCallable.call();
assertSame(expected, future.get());
}
@GwtIncompatible
public void testAsAsyncCallable_exception() throws Exception {
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapAsMapGetTester.java
55 issues
Line: 45
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapAsMapGetTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testPropagatesRemoveToMultimap() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k0(), v2()));
Collection<V> result = multimap().asMap().get(k0());
Reported by PMD.
Line: 47
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testPropagatesRemoveToMultimap() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k0(), v2()));
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
Reported by PMD.
Line: 50
public void testPropagatesRemoveToMultimap() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k0(), v2()));
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
assertEquals(2, multimap().size());
}
Reported by PMD.
Line: 50
public void testPropagatesRemoveToMultimap() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k0(), v2()));
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
assertEquals(2, multimap().size());
}
Reported by PMD.
Line: 51
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k0(), v2()));
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
assertEquals(2, multimap().size());
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 52
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k0(), v2()));
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
assertEquals(2, multimap().size());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 53
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
assertEquals(2, multimap().size());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testPropagatesRemoveLastElementToMultimap() {
Reported by PMD.
Line: 56
assertEquals(2, multimap().size());
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testPropagatesRemoveLastElementToMultimap() {
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertGet(k0());
Reported by PMD.
Line: 58
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testPropagatesRemoveLastElementToMultimap() {
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertGet(k0());
}
Reported by PMD.
Line: 59
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testPropagatesRemoveLastElementToMultimap() {
Collection<V> result = multimap().asMap().get(k0());
assertTrue(result.remove(v0()));
assertGet(k0());
}
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
guava-tests/test/com/google/common/io/SourceSinkFactories.java
55 issues
Line: 324
public ByteSource createSource(byte[] bytes) throws IOException {
checkNotNull(bytes);
File file = createFile();
OutputStream out = new FileOutputStream(file);
try {
out.write(bytes);
} finally {
out.close();
}
Reported by PMD.
Line: 351
public ByteSink createSink() throws IOException {
File file = createFile();
if (initialBytes != null) {
FileOutputStream out = new FileOutputStream(file);
try {
out.write(initialBytes);
} finally {
out.close();
}
Reported by PMD.
Line: 377
@Override
public byte[] getSinkContents() throws IOException {
File file = getFile();
InputStream in = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[100];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
Reported by PMD.
Line: 394
public CharSource createSource(String string) throws IOException {
checkNotNull(string);
File file = createFile();
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
try {
writer.write(string);
} finally {
writer.close();
}
Reported by PMD.
Line: 421
public CharSink createSink() throws IOException {
File file = createFile();
if (initialString != null) {
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
try {
writer.write(initialString);
} finally {
writer.close();
}
Reported by PMD.
Line: 441
@Override
public String getSinkContents() throws IOException {
File file = getFile();
Reader reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
StringBuilder builder = new StringBuilder();
CharBuffer buffer = CharBuffer.allocate(100);
while (reader.read(buffer) != -1) {
buffer.flip();
builder.append(buffer);
Reported by PMD.
Line: 312
public final void tearDown() throws IOException {
if (!fileThreadLocal.get().delete()) {
logger.warning("Unable to delete file: " + fileThreadLocal.get());
}
fileThreadLocal.remove();
}
}
Reported by PMD.
Line: 494
try {
java.nio.file.Files.delete(fileThreadLocal.get());
} catch (IOException e) {
logger.log(Level.WARNING, "Unable to delete file: " + fileThreadLocal.get(), e);
}
fileThreadLocal.remove();
}
}
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.io;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.SourceSinkFactory.ByteSinkFactory;
import static com.google.common.io.SourceSinkFactory.ByteSourceFactory;
import static com.google.common.io.SourceSinkFactory.CharSinkFactory;
Reported by PMD.
Line: 50
*
* @author Colin Decker
*/
public class SourceSinkFactories {
private SourceSinkFactories() {}
public static CharSourceFactory stringCharSourceFactory() {
return new StringSourceFactory();
Reported by PMD.
android/guava-tests/test/com/google/common/collect/TopKSelectorTest.java
54 issues
Line: 36
*/
public class TopKSelectorTest extends TestCase {
public void testNegativeK() {
try {
TopKSelector.least(-1);
fail();
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 39
public void testNegativeK() {
try {
TopKSelector.least(-1);
fail();
} catch (IllegalArgumentException expected) {
}
try {
TopKSelector.greatest(-1);
fail();
Reported by PMD.
Line: 39
public void testNegativeK() {
try {
TopKSelector.least(-1);
fail();
} catch (IllegalArgumentException expected) {
}
try {
TopKSelector.greatest(-1);
fail();
Reported by PMD.
Line: 44
}
try {
TopKSelector.greatest(-1);
fail();
} catch (IllegalArgumentException expected) {
}
try {
TopKSelector.least(-1, Ordering.natural());
fail();
Reported by PMD.
Line: 44
}
try {
TopKSelector.greatest(-1);
fail();
} catch (IllegalArgumentException expected) {
}
try {
TopKSelector.least(-1, Ordering.natural());
fail();
Reported by PMD.
Line: 49
}
try {
TopKSelector.least(-1, Ordering.natural());
fail();
} catch (IllegalArgumentException expected) {
}
try {
TopKSelector.greatest(-1, Ordering.natural());
fail();
Reported by PMD.
Line: 49
}
try {
TopKSelector.least(-1, Ordering.natural());
fail();
} catch (IllegalArgumentException expected) {
}
try {
TopKSelector.greatest(-1, Ordering.natural());
fail();
Reported by PMD.
Line: 54
}
try {
TopKSelector.greatest(-1, Ordering.natural());
fail();
} catch (IllegalArgumentException expected) {
}
}
public void testZeroK() {
Reported by PMD.
Line: 54
}
try {
TopKSelector.greatest(-1, Ordering.natural());
fail();
} catch (IllegalArgumentException expected) {
}
}
public void testZeroK() {
Reported by PMD.
Line: 59
}
}
public void testZeroK() {
TopKSelector<Integer> top = TopKSelector.least(0);
for (int i = 0; i < 10; i++) {
top.offer(i);
}
assertThat(top.topK()).isEmpty();
Reported by PMD.
guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
54 issues
Line: 43
*/
public class ImmutableTypeToInstanceMapTest extends TestCase {
@AndroidIncompatible // problem with suite builders on Android
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ImmutableTypeToInstanceMapTest.class);
suite.addTest(
Reported by PMD.
Line: 60
ImmutableTypeToInstanceMap.builder();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
builder.put(entry.getKey(), entry.getValue());
}
return (Map) builder.build();
}
})
.named("ImmutableTypeToInstanceMap")
Reported by PMD.
Line: 60
ImmutableTypeToInstanceMap.builder();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
builder.put(entry.getKey(), entry.getValue());
}
return (Map) builder.build();
}
})
.named("ImmutableTypeToInstanceMap")
Reported by PMD.
Line: 77
return suite;
}
public void testEmpty() {
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
Reported by PMD.
Line: 78
}
public void testEmpty() {
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
Reported by PMD.
Line: 78
}
public void testEmpty() {
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
Reported by PMD.
Line: 81
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
Reported by PMD.
Line: 81
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
Reported by PMD.
Line: 83
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
assertEquals(2, map.size());
Reported by PMD.
Line: 83
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
assertEquals(2, map.size());
Reported by PMD.
guava/src/com/google/common/collect/MinMaxPriorityQueue.java
54 issues
Line: 500
@VisibleForTesting
static boolean isEvenLevel(int index) {
int oneBased = ~~(index + 1); // for GWT
checkState(oneBased > 0, "negative index");
return (oneBased & EVEN_POWERS_OF_TWO) > (oneBased & ODD_POWERS_OF_TWO);
}
/**
Reported by PMD.
Line: 570
}
/** Bubbles a value from {@code index} up the appropriate heap if required. */
void bubbleUp(int index, E x) {
int crossOver = crossOverUp(index, x);
Heap heap;
if (crossOver == index) {
heap = this;
Reported by PMD.
Line: 588
* element ended up at.
*/
@CanIgnoreReturnValue
int bubbleUpAlternatingLevels(int index, E x) {
while (index > 2) {
int grandParentIndex = getGrandparentIndex(index);
E e = elementData(grandParentIndex);
if (ordering.compare(e, x) <= 0) {
break;
Reported by PMD.
Line: 721
* @return the position of the new hole (where the lowest grandchild moved from, that had no
* grandchild to replace it)
*/
int fillHoleAt(int index) {
int minGrandchildIndex;
while ((minGrandchildIndex = findMinGrandChild(index)) > 0) {
queue[index] = elementData(minGrandchildIndex);
index = minGrandchildIndex;
}
Reported by PMD.
Line: 869
* Advances nextCursor to the index of the first element after {@code c} that is not in {@code
* skipMe} and returns {@code size()} if there is no such element.
*/
private void nextNotInSkipMe(int c) {
if (nextCursor < c) {
if (skipMe != null) {
while (c < size() && foundAndRemovedExactReference(skipMe, elementData(c))) {
c++;
}
Reported by PMD.
Line: 104
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
* Creates a new min-max priority queue with default settings: natural order, no maximum size, no
* initial contents, and an initial expected size of 11.
*/
Reported by PMD.
Line: 104
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
* Creates a new min-max priority queue with default settings: natural order, no maximum size, no
* initial contents, and an initial expected size of 11.
*/
Reported by PMD.
Line: 173
*/
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
Reported by PMD.
Line: 174
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.
Line: 174
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.