The following issues were found
android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java
54 issues
Line: 38
*/
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
Reported by PMD.
Line: 38
*/
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
Reported by PMD.
Line: 40
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
public void testExecutorSuccess() {
Reported by PMD.
Line: 42
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
public void testExecutorSuccess() {
CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
SettableFuture<String> f = SettableFuture.create();
Reported by PMD.
Line: 45
f.set("foo");
}
public void testExecutorSuccess() {
CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
Reported by PMD.
Line: 50
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
assertEquals(1, ex.runCount);
}
// Error cases
public void testSameThreadExecutionException() {
Reported by PMD.
Line: 51
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
assertEquals(1, ex.runCount);
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Reported by PMD.
Line: 55
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
Reported by PMD.
Line: 55
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
Reported by PMD.
Line: 60
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
}
public void testCancel() {
SettableFuture<String> f = SettableFuture.create();
FutureCallback<String> callback =
Reported by PMD.
guava-testlib/test/com/google/common/testing/FakeTickerTest.java
53 issues
Line: 36
* @author Jige Yu
*/
@GwtCompatible(emulated = true)
public class FakeTickerTest extends TestCase {
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(new FakeTicker());
Reported by PMD.
Line: 38
@GwtCompatible(emulated = true)
public class FakeTickerTest extends TestCase {
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(new FakeTicker());
}
Reported by PMD.
Line: 39
public class FakeTickerTest extends TestCase {
@GwtIncompatible // NullPointerTester
public void testNullPointerExceptions() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(new FakeTicker());
}
@GwtIncompatible // java.time.Duration
Reported by PMD.
Line: 44
tester.testAllPublicInstanceMethods(new FakeTicker());
}
@GwtIncompatible // java.time.Duration
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
Reported by PMD.
Line: 45
}
@GwtIncompatible // java.time.Duration
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
Reported by PMD.
Line: 47
@GwtIncompatible // java.time.Duration
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
ticker.advance(java.time.Duration.ofMillis(1));
Reported by PMD.
Line: 48
public void testAdvance() {
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
ticker.advance(java.time.Duration.ofMillis(1));
assertEquals(2000010L, ticker.read());
Reported by PMD.
Line: 49
FakeTicker ticker = new FakeTicker();
assertEquals(0, ticker.read());
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
ticker.advance(java.time.Duration.ofMillis(1));
assertEquals(2000010L, ticker.read());
}
Reported by PMD.
Line: 51
assertSame(ticker, ticker.advance(10));
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
ticker.advance(java.time.Duration.ofMillis(1));
assertEquals(2000010L, ticker.read());
}
public void testAutoIncrementStep_returnsSameInstance() {
Reported by PMD.
Line: 52
assertEquals(10, ticker.read());
ticker.advance(1, TimeUnit.MILLISECONDS);
assertEquals(1000010L, ticker.read());
ticker.advance(java.time.Duration.ofMillis(1));
assertEquals(2000010L, ticker.read());
}
public void testAutoIncrementStep_returnsSameInstance() {
FakeTicker ticker = new FakeTicker();
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/SortedMapNavigationTester.java
53 issues
Line: 46
*/
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
Reported by PMD.
Line: 48
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 49
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 50
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (SortedMap<K, V>) getMap();
Reported by PMD.
Line: 52
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (SortedMap<K, V>) getMap();
List<Entry<K, V>> entries =
Helpers.copyToList(
Reported by PMD.
Line: 58
navigableMap = (SortedMap<K, V>) getMap();
List<Entry<K, V>> 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: 59
List<Entry<K, V>> 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: 59
List<Entry<K, V>> 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: 63
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
if (entries.size() >= 3) {
c = entries.get(2);
}
}
Reported by PMD.
Line: 63
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
if (entries.size() >= 3) {
c = entries.get(2);
}
}
Reported by PMD.
guava-tests/test/com/google/common/collect/EnumMultisetTest.java
53 issues
Line: 45
* @author Jared Levy
*/
@GwtCompatible(emulated = true)
public class EnumMultisetTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 47
@GwtCompatible(emulated = true)
public class EnumMultisetTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
Reported by PMD.
Line: 51
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
Reported by PMD.
Line: 51
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
Reported by PMD.
Line: 51
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
Reported by PMD.
Line: 89
FEMALE
}
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
Reported by PMD.
Line: 89
FEMALE
}
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
Reported by PMD.
Line: 91
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
assertEquals(1, ms.count(Color.YELLOW));
assertEquals(2, ms.count(Color.RED));
Reported by PMD.
Line: 92
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
assertEquals(1, ms.count(Color.YELLOW));
assertEquals(2, ms.count(Color.RED));
}
Reported by PMD.
Line: 93
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
assertEquals(1, ms.count(Color.YELLOW));
assertEquals(2, ms.count(Color.RED));
}
Reported by PMD.
guava-tests/test/com/google/common/graph/GraphPropertiesTest.java
53 issues
Line: 31
/** Tests for {@link Graphs#hasCycle(Graph)} and {@link Graphs#hasCycle(Network)}. */
// TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Reported by PMD.
Line: 32
// TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Reported by PMD.
Line: 33
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
Reported by PMD.
Line: 34
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
Reported by PMD.
Line: 36
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
@Before
public void init() {
Reported by PMD.
Line: 37
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
Reported by PMD.
Line: 38
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
Reported by PMD.
Line: 43
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
MutableGraph<Integer> mutableUndirectedGraph =
GraphBuilder.undirected().allowsSelfLoops(true).build();
graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
directedGraph = mutableDirectedGraph;
undirectedGraph = mutableUndirectedGraph;
Reported by PMD.
Line: 43
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
MutableGraph<Integer> mutableUndirectedGraph =
GraphBuilder.undirected().allowsSelfLoops(true).build();
graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
directedGraph = mutableDirectedGraph;
undirectedGraph = mutableUndirectedGraph;
Reported by PMD.
Line: 45
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
MutableGraph<Integer> mutableUndirectedGraph =
GraphBuilder.undirected().allowsSelfLoops(true).build();
graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
directedGraph = mutableDirectedGraph;
undirectedGraph = mutableUndirectedGraph;
MutableNetwork<Integer, String> mutableDirectedNetwork =
Reported by PMD.
android/guava-tests/test/com/google/common/collect/EnumMultisetTest.java
53 issues
Line: 45
* @author Jared Levy
*/
@GwtCompatible(emulated = true)
public class EnumMultisetTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Reported by PMD.
Line: 47
@GwtCompatible(emulated = true)
public class EnumMultisetTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
Reported by PMD.
Line: 51
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
Reported by PMD.
Line: 51
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
Reported by PMD.
Line: 51
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MultisetTestSuiteBuilder.using(enumMultisetGenerator())
.withFeatures(
CollectionSize.ANY,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
Reported by PMD.
Line: 89
FEMALE
}
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
Reported by PMD.
Line: 89
FEMALE
}
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
Reported by PMD.
Line: 91
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
assertEquals(1, ms.count(Color.YELLOW));
assertEquals(2, ms.count(Color.RED));
Reported by PMD.
Line: 92
public void testClassCreate() {
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
assertEquals(1, ms.count(Color.YELLOW));
assertEquals(2, ms.count(Color.RED));
}
Reported by PMD.
Line: 93
Multiset<Color> ms = EnumMultiset.create(Color.class);
ms.add(Color.RED);
ms.add(Color.YELLOW);
ms.add(Color.RED);
assertEquals(0, ms.count(Color.BLUE));
assertEquals(1, ms.count(Color.YELLOW));
assertEquals(2, ms.count(Color.RED));
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/SortedMapNavigationTester.java
53 issues
Line: 46
*/
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
Reported by PMD.
Line: 48
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 49
public class SortedMapNavigationTester<K, V> extends AbstractMapTester<K, V> {
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 50
private SortedMap<K, V> navigableMap;
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (SortedMap<K, V>) getMap();
Reported by PMD.
Line: 52
private Entry<K, V> a;
private Entry<K, V> c;
@Override
public void setUp() throws Exception {
super.setUp();
navigableMap = (SortedMap<K, V>) getMap();
List<Entry<K, V>> entries =
Helpers.copyToList(
Reported by PMD.
Line: 58
navigableMap = (SortedMap<K, V>) getMap();
List<Entry<K, V>> 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: 59
List<Entry<K, V>> 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: 59
List<Entry<K, V>> 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: 63
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
if (entries.size() >= 3) {
c = entries.get(2);
}
}
Reported by PMD.
Line: 63
Collections.sort(entries, Helpers.<K, V>entryComparator(navigableMap.comparator()));
// some tests assume SEVERAL == 3
if (entries.size() >= 1) {
a = entries.get(0);
if (entries.size() >= 3) {
c = entries.get(2);
}
}
Reported by PMD.
guava/src/com/google/common/collect/ImmutableMap.java
53 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
Reported by PMD.
Line: 69
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
* and values are the result of applying the provided mapping functions to the input elements.
* Entries appear in the result {@code ImmutableMap} in encounter order.
Reported by PMD.
Line: 69
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
* and values are the result of applying the provided mapping functions to the input elements.
* Entries appear in the result {@code ImmutableMap} in encounter order.
Reported by PMD.
Line: 115
*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
public static <K, V> ImmutableMap<K, V> of() {
return (ImmutableMap<K, V>) RegularImmutableMap.EMPTY;
}
/**
Reported by PMD.
Line: 162
*
* @throws IllegalArgumentException if duplicate keys are provided
*/
public static <K, V> ImmutableMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
return RegularImmutableMap.fromEntries(
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
Reported by PMD.
Line: 387
entries = Arrays.copyOf(entries, size);
}
Arrays.sort(
entries, 0, size, Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
}
switch (size) {
case 0:
return of();
case 1:
Reported by PMD.
Line: 395
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
entriesUsed = true;
return RegularImmutableMap.fromEntryArray(size, entries);
}
}
Reported by PMD.
Line: 395
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
entriesUsed = true;
return RegularImmutableMap.fromEntryArray(size, entries);
}
}
Reported by PMD.
Line: 412
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
entriesUsed = true;
return JdkBackedImmutableMap.create(size, entries);
}
}
Reported by PMD.
android/guava-tests/test/com/google/common/graph/GraphPropertiesTest.java
53 issues
Line: 31
/** Tests for {@link Graphs#hasCycle(Graph)} and {@link Graphs#hasCycle(Network)}. */
// TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Reported by PMD.
Line: 32
// TODO(user): Consider moving this to GraphsTest.
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Reported by PMD.
Line: 33
@RunWith(JUnit4.class)
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
Reported by PMD.
Line: 34
public class GraphPropertiesTest {
ImmutableList<MutableGraph<Integer>> graphsToTest;
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
Reported by PMD.
Line: 36
Graph<Integer> directedGraph;
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
@Before
public void init() {
Reported by PMD.
Line: 37
Graph<Integer> undirectedGraph;
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
Reported by PMD.
Line: 38
ImmutableList<MutableNetwork<Integer, String>> networksToTest;
Network<Integer, String> directedNetwork;
Network<Integer, String> undirectedNetwork;
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
Reported by PMD.
Line: 43
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
MutableGraph<Integer> mutableUndirectedGraph =
GraphBuilder.undirected().allowsSelfLoops(true).build();
graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
directedGraph = mutableDirectedGraph;
undirectedGraph = mutableUndirectedGraph;
Reported by PMD.
Line: 43
@Before
public void init() {
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
MutableGraph<Integer> mutableUndirectedGraph =
GraphBuilder.undirected().allowsSelfLoops(true).build();
graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
directedGraph = mutableDirectedGraph;
undirectedGraph = mutableUndirectedGraph;
Reported by PMD.
Line: 45
MutableGraph<Integer> mutableDirectedGraph =
GraphBuilder.directed().allowsSelfLoops(true).build();
MutableGraph<Integer> mutableUndirectedGraph =
GraphBuilder.undirected().allowsSelfLoops(true).build();
graphsToTest = ImmutableList.of(mutableDirectedGraph, mutableUndirectedGraph);
directedGraph = mutableDirectedGraph;
undirectedGraph = mutableUndirectedGraph;
MutableNetwork<Integer, String> mutableDirectedNetwork =
Reported by PMD.
android/guava/src/com/google/common/collect/FilteredEntryMultimap.java
53 issues
Line: 48
@GwtCompatible
@ElementTypesAreNonnullByDefault
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
this.unfiltered = checkNotNull(unfiltered);
Reported by PMD.
Line: 49
@ElementTypesAreNonnullByDefault
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
this.unfiltered = checkNotNull(unfiltered);
this.predicate = checkNotNull(predicate);
Reported by PMD.
Line: 49
@ElementTypesAreNonnullByDefault
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
this.unfiltered = checkNotNull(unfiltered);
this.predicate = checkNotNull(predicate);
Reported by PMD.
Line: 50
class FilteredEntryMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super Entry<K, V>> predicate;
FilteredEntryMultimap(Multimap<K, V> unfiltered, Predicate<? super Entry<K, V>> predicate) {
this.unfiltered = checkNotNull(unfiltered);
this.predicate = checkNotNull(predicate);
}
Reported by PMD.
Line: 69
@Override
public int size() {
return entries().size();
}
private boolean satisfies(@ParametricNullness K key, @ParametricNullness V value) {
return predicate.apply(Maps.immutableEntry(key, value));
}
Reported by PMD.
Line: 77
}
final class ValuePredicate implements Predicate<V> {
@ParametricNullness private final K key;
ValuePredicate(@ParametricNullness K key) {
this.key = key;
}
Reported by PMD.
Line: 100
@Override
public boolean containsKey(@CheckForNull Object key) {
return asMap().get(key) != null;
}
@Override
public Collection<V> removeAll(@CheckForNull Object key) {
return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection());
Reported by PMD.
Line: 105
@Override
public Collection<V> removeAll(@CheckForNull Object key) {
return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection());
}
Collection<V> unmodifiableEmptyCollection() {
// These return false, rather than throwing a UOE, on remove calls.
return (unfiltered instanceof SetMultimap)
Reported by PMD.
Line: 117
@Override
public void clear() {
entries().clear();
}
@Override
public Collection<V> get(@ParametricNullness final K key) {
return filterCollection(unfiltered.get(key), new ValuePredicate(key));
Reported by PMD.
Line: 147
@Override
Set<K> createKeySet() {
return asMap().keySet();
}
boolean removeEntriesIf(Predicate<? super Entry<K, Collection<V>>> predicate) {
Iterator<Entry<K, Collection<V>>> entryIterator = unfiltered.asMap().entrySet().iterator();
boolean changed = false;
Reported by PMD.