The following issues were found
guava-tests/test/com/google/common/html/HtmlEscapersTest.java
28 issues
Line: 30
@GwtCompatible
public class HtmlEscapersTest extends TestCase {
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
Reported by PMD.
Line: 30
@GwtCompatible
public class HtmlEscapersTest extends TestCase {
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
Reported by PMD.
Line: 31
public class HtmlEscapersTest extends TestCase {
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
Reported by PMD.
Line: 31
public class HtmlEscapersTest extends TestCase {
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
Reported by PMD.
Line: 32
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
assertEquals("<tab>", htmlEscaper().escape("<tab>"));
Reported by PMD.
Line: 32
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
assertEquals("<tab>", htmlEscaper().escape("<tab>"));
Reported by PMD.
Line: 33
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
assertEquals("<tab>", htmlEscaper().escape("<tab>"));
Reported by PMD.
Line: 33
public void testHtmlEscaper() throws Exception {
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
assertEquals("<tab>", htmlEscaper().escape("<tab>"));
Reported by PMD.
Line: 34
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
assertEquals("<tab>", htmlEscaper().escape("<tab>"));
// Test simple escape of '&'.
Reported by PMD.
Line: 34
assertEquals("xxx", htmlEscaper().escape("xxx"));
assertEquals(""test"", htmlEscaper().escape("\"test\""));
assertEquals("'test'", htmlEscaper().escape("\'test'"));
assertEquals("test & test & test", htmlEscaper().escape("test & test & test"));
assertEquals("test << 1", htmlEscaper().escape("test << 1"));
assertEquals("test >> 1", htmlEscaper().escape("test >> 1"));
assertEquals("<tab>", htmlEscaper().escape("<tab>"));
// Test simple escape of '&'.
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/CollectionRemoveAllTester.java
27 issues
Line: 47
@SuppressWarnings("unchecked") // too many "unchecked generic array creations"
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionRemoveAllTester<E> extends AbstractCollectionTester<E> {
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAll_emptyCollection() {
assertFalse(
"removeAll(emptyCollection) should return false",
collection.removeAll(MinimalCollection.of()));
Reported by PMD.
Line: 48
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionRemoveAllTester<E> extends AbstractCollectionTester<E> {
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAll_emptyCollection() {
assertFalse(
"removeAll(emptyCollection) should return false",
collection.removeAll(MinimalCollection.of()));
expectUnchanged();
Reported by PMD.
Line: 56
expectUnchanged();
}
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAll_nonePresent() {
assertFalse(
"removeAll(disjointCollection) should return false",
collection.removeAll(MinimalCollection.of(e3())));
expectUnchanged();
Reported by PMD.
Line: 64
expectUnchanged();
}
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_allPresent() {
assertTrue(
"removeAll(intersectingCollection) should return true",
collection.removeAll(MinimalCollection.of(e0())));
Reported by PMD.
Line: 73
expectMissing(e0());
}
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_somePresent() {
assertTrue(
"removeAll(intersectingCollection) should return true",
collection.removeAll(MinimalCollection.of(e0(), e3())));
Reported by PMD.
Line: 82
expectMissing(e0());
}
@CollectionFeature.Require({SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(SEVERAL)
public void testRemoveAllSomePresentConcurrentWithIteration() {
try {
Iterator<E> iterator = collection.iterator();
assertTrue(collection.removeAll(MinimalCollection.of(e0(), e3())));
Reported by PMD.
Line: 96
}
/** Trigger the {@code other.size() >= this.size()} case in {@link AbstractSet#removeAll()}. */
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemoveAll_somePresentLargeCollectionToRemove() {
assertTrue(
"removeAll(largeIntersectingCollection) should return true",
collection.removeAll(MinimalCollection.of(e0(), e0(), e0(), e3(), e3(), e3())));
Reported by PMD.
Line: 105
expectMissing(e0());
}
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRemoveAll_unsupportedEmptyCollection() {
try {
assertFalse(
"removeAll(emptyCollection) should return false or throw "
+ "UnsupportedOperationException",
Reported by PMD.
Line: 112
"removeAll(emptyCollection) should return false or throw "
+ "UnsupportedOperationException",
collection.removeAll(MinimalCollection.of()));
} catch (UnsupportedOperationException tolerated) {
}
expectUnchanged();
}
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
Reported by PMD.
Line: 117
expectUnchanged();
}
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRemoveAll_unsupportedNonePresent() {
try {
assertFalse(
"removeAll(disjointCollection) should return false or throw "
+ "UnsupportedOperationException",
Reported by PMD.
guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
27 issues
Line: 34
public class FileBackedOutputStreamTest extends IoTestCase {
public void testThreshold() throws Exception {
testThreshold(0, 100, true, false);
testThreshold(10, 100, true, false);
testThreshold(100, 100, true, false);
testThreshold(1000, 100, true, false);
testThreshold(0, 100, false, false);
Reported by PMD.
Line: 45
testThreshold(1000, 100, false, false);
}
private void testThreshold(
int fileThreshold, int dataSize, boolean singleByte, boolean resetOnFinalize)
throws IOException {
byte[] data = newPreFilledByteArray(dataSize);
FileBackedOutputStream out = new FileBackedOutputStream(fileThreshold, resetOnFinalize);
ByteSource source = out.asByteSource();
Reported by PMD.
Line: 49
int fileThreshold, int dataSize, boolean singleByte, boolean resetOnFinalize)
throws IOException {
byte[] data = newPreFilledByteArray(dataSize);
FileBackedOutputStream out = new FileBackedOutputStream(fileThreshold, resetOnFinalize);
ByteSource source = out.asByteSource();
int chunk1 = Math.min(dataSize, fileThreshold);
int chunk2 = dataSize - chunk1;
// Write just enough to not trip the threshold
Reported by PMD.
Line: 57
// Write just enough to not trip the threshold
if (chunk1 > 0) {
write(out, data, 0, chunk1, singleByte);
assertTrue(ByteSource.wrap(data).slice(0, chunk1).contentEquals(source));
}
File file = out.getFile();
assertNull(file);
// Write data to go over the threshold
Reported by PMD.
Line: 57
// Write just enough to not trip the threshold
if (chunk1 > 0) {
write(out, data, 0, chunk1, singleByte);
assertTrue(ByteSource.wrap(data).slice(0, chunk1).contentEquals(source));
}
File file = out.getFile();
assertNull(file);
// Write data to go over the threshold
Reported by PMD.
Line: 72
out.close();
// Check that source returns the right data
assertTrue(Arrays.equals(data, source.read()));
// Make sure that reset deleted the file
out.reset();
if (file != null) {
assertFalse(file.exists());
Reported by PMD.
Line: 82
}
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
write(out, data, 0, 100, true);
final File file = out.getFile();
Reported by PMD.
Line: 82
}
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
write(out, data, 0, 100, true);
final File file = out.getFile();
Reported by PMD.
Line: 84
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
write(out, data, 0, 100, true);
final File file = out.getFile();
assertEquals(100, file.length());
assertTrue(file.exists());
Reported by PMD.
Line: 88
write(out, data, 0, 100, true);
final File file = out.getFile();
assertEquals(100, file.length());
assertTrue(file.exists());
out.close();
// Make sure that finalize deletes the file
out = null;
Reported by PMD.
guava-testlib/src/com/google/common/testing/AbstractPackageSanityTests.java
27 issues
Line: 151
private static final Chopper TEST_SUFFIX =
suffix("Test").or(suffix("Tests")).or(suffix("TestCase")).or(suffix("TestSuite"));
private final Logger logger = Logger.getLogger(getClass().getName());
private final ClassSanityTester tester = new ClassSanityTester();
private Visibility visibility = Visibility.PACKAGE;
private Predicate<Class<?>> classFilter =
new Predicate<Class<?>>() {
@Override
Reported by PMD.
Line: 386
cls = classInfo.load();
} catch (NoClassDefFoundError e) {
// In case there were linking problems, this is probably not a class we care to test anyway.
logger.log(Level.SEVERE, "Cannot load class " + classInfo + ", skipping...", e);
continue;
}
if (!cls.isInterface()) {
classes.add(cls);
}
Reported by PMD.
Line: 122
new Predicate<Class<?>>() {
@Override
public boolean apply(Class<?> c) {
return c.getSimpleName().contains("_");
}
};
/* The names of the expected method that tests null checks. */
private static final ImmutableList<String> NULL_TEST_METHOD_NAMES =
Reported by PMD.
Line: 151
private static final Chopper TEST_SUFFIX =
suffix("Test").or(suffix("Tests")).or(suffix("TestCase")).or(suffix("TestSuite"));
private final Logger logger = Logger.getLogger(getClass().getName());
private final ClassSanityTester tester = new ClassSanityTester();
private Visibility visibility = Visibility.PACKAGE;
private Predicate<Class<?>> classFilter =
new Predicate<Class<?>>() {
@Override
Reported by PMD.
Line: 152
suffix("Test").or(suffix("Tests")).or(suffix("TestCase")).or(suffix("TestSuite"));
private final Logger logger = Logger.getLogger(getClass().getName());
private final ClassSanityTester tester = new ClassSanityTester();
private Visibility visibility = Visibility.PACKAGE;
private Predicate<Class<?>> classFilter =
new Predicate<Class<?>>() {
@Override
public boolean apply(Class<?> cls) {
Reported by PMD.
Line: 153
private final Logger logger = Logger.getLogger(getClass().getName());
private final ClassSanityTester tester = new ClassSanityTester();
private Visibility visibility = Visibility.PACKAGE;
private Predicate<Class<?>> classFilter =
new Predicate<Class<?>>() {
@Override
public boolean apply(Class<?> cls) {
return visibility.isVisible(cls.getModifiers());
Reported by PMD.
Line: 154
private final Logger logger = Logger.getLogger(getClass().getName());
private final ClassSanityTester tester = new ClassSanityTester();
private Visibility visibility = Visibility.PACKAGE;
private Predicate<Class<?>> classFilter =
new Predicate<Class<?>>() {
@Override
public boolean apply(Class<?> cls) {
return visibility.isVisible(cls.getModifiers());
}
Reported by PMD.
Line: 199
* C} will be excluded from automated serialization test performed by this method.
*/
@Test
public void testSerializable() throws Exception {
// TODO: when we use @BeforeClass, we can pay the cost of class path scanning only once.
for (Class<?> classToTest :
findClassesToTest(loadClassesInPackage(), SERIALIZABLE_TEST_METHOD_NAMES)) {
if (Serializable.class.isAssignableFrom(classToTest)) {
try {
Reported by PMD.
Line: 213
SerializableTester.reserialize(instance);
}
}
} catch (Throwable e) {
throw sanityError(classToTest, SERIALIZABLE_TEST_METHOD_NAMES, "serializable test", e);
}
}
}
}
Reported by PMD.
Line: 244
* excluded from the automated null tests performed by this method.
*/
@Test
public void testNulls() throws Exception {
for (Class<?> classToTest : findClassesToTest(loadClassesInPackage(), NULL_TEST_METHOD_NAMES)) {
try {
tester.doTestNulls(classToTest, visibility);
} catch (Throwable e) {
throw sanityError(classToTest, NULL_TEST_METHOD_NAMES, "nulls test", e);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/SetMultimapAsMapTester.java
27 issues
Line: 47
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
public void testAsMapValuesImplementSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
assertTrue(valueCollection instanceof Set);
}
}
Reported by PMD.
Line: 48
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
public void testAsMapValuesImplementSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
assertTrue(valueCollection instanceof Set);
}
}
public void testAsMapGetImplementsSet() {
Reported by PMD.
Line: 48
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SetMultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, SetMultimap<K, V>> {
public void testAsMapValuesImplementSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
assertTrue(valueCollection instanceof Set);
}
}
public void testAsMapGetImplementsSet() {
Reported by PMD.
Line: 53
}
}
public void testAsMapGetImplementsSet() {
for (K key : multimap().keySet()) {
assertTrue(multimap().asMap().get(key) instanceof Set);
}
}
Reported by PMD.
Line: 54
}
public void testAsMapGetImplementsSet() {
for (K key : multimap().keySet()) {
assertTrue(multimap().asMap().get(key) instanceof Set);
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 55
public void testAsMapGetImplementsSet() {
for (K key : multimap().keySet()) {
assertTrue(multimap().asMap().get(key) instanceof Set);
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsSet() {
Reported by PMD.
Line: 55
public void testAsMapGetImplementsSet() {
for (K key : multimap().keySet()) {
assertTrue(multimap().asMap().get(key) instanceof Set);
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsSet() {
Reported by PMD.
Line: 59
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsSet() {
List<K> keys = new ArrayList<K>(multimap().keySet());
for (K key : keys) {
resetCollection();
assertTrue(multimap().asMap().remove(key) instanceof Set);
Reported by PMD.
Line: 61
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsSet() {
List<K> keys = new ArrayList<K>(multimap().keySet());
for (K key : keys) {
resetCollection();
assertTrue(multimap().asMap().remove(key) instanceof Set);
}
}
Reported by PMD.
Line: 64
List<K> keys = new ArrayList<K>(multimap().keySet());
for (K key : keys) {
resetCollection();
assertTrue(multimap().asMap().remove(key) instanceof Set);
}
}
@CollectionSize.Require(SEVERAL)
public void testEquals() {
Reported by PMD.
guava-tests/test/com/google/common/cache/ForwardingCacheTest.java
27 issues
Line: 34
* @author Charles Fry
*/
public class ForwardingCacheTest extends TestCase {
private Cache<String, Boolean> forward;
private Cache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
public void setUp() throws Exception {
Reported by PMD.
Line: 35
*/
public class ForwardingCacheTest extends TestCase {
private Cache<String, Boolean> forward;
private Cache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 37
private Cache<String, Boolean> forward;
private Cache<String, Boolean> mock;
@SuppressWarnings({"unchecked", "DoNotMock"}) // mock
@Override
public void setUp() throws Exception {
super.setUp();
/*
* Class parameters must be raw, so we can't create a proxy with generic
Reported by PMD.
Line: 56
};
}
public void testGetIfPresent() throws ExecutionException {
when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getIfPresent("key"));
}
public void testGetAllPresent() throws ExecutionException {
Reported by PMD.
Line: 57
}
public void testGetIfPresent() throws ExecutionException {
when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getIfPresent("key"));
}
public void testGetAllPresent() throws ExecutionException {
when(mock.getAllPresent(ImmutableList.of("key")))
Reported by PMD.
Line: 57
}
public void testGetIfPresent() throws ExecutionException {
when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getIfPresent("key"));
}
public void testGetAllPresent() throws ExecutionException {
when(mock.getAllPresent(ImmutableList.of("key")))
Reported by PMD.
Line: 58
public void testGetIfPresent() throws ExecutionException {
when(mock.getIfPresent("key")).thenReturn(Boolean.TRUE);
assertSame(Boolean.TRUE, forward.getIfPresent("key"));
}
public void testGetAllPresent() throws ExecutionException {
when(mock.getAllPresent(ImmutableList.of("key")))
.thenReturn(ImmutableMap.of("key", Boolean.TRUE));
Reported by PMD.
Line: 61
assertSame(Boolean.TRUE, forward.getIfPresent("key"));
}
public void testGetAllPresent() throws ExecutionException {
when(mock.getAllPresent(ImmutableList.of("key")))
.thenReturn(ImmutableMap.of("key", Boolean.TRUE));
assertEquals(
ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
}
Reported by PMD.
Line: 62
}
public void testGetAllPresent() throws ExecutionException {
when(mock.getAllPresent(ImmutableList.of("key")))
.thenReturn(ImmutableMap.of("key", Boolean.TRUE));
assertEquals(
ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
}
Reported by PMD.
Line: 64
public void testGetAllPresent() throws ExecutionException {
when(mock.getAllPresent(ImmutableList.of("key")))
.thenReturn(ImmutableMap.of("key", Boolean.TRUE));
assertEquals(
ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
}
public void testInvalidate() {
forward.invalidate("key");
Reported by PMD.
android/guava/src/com/google/common/collect/AbstractTable.java
27 issues
Line: 39
@ElementTypesAreNonnullByDefault
abstract class AbstractTable<
R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
implements Table<R, C, V> {
@Override
public boolean containsRow(@CheckForNull Object rowKey) {
return Maps.safeContainsKey(rowMap(), rowKey);
}
Reported by PMD.
Line: 53
@Override
public Set<R> rowKeySet() {
return rowMap().keySet();
}
@Override
public Set<C> columnKeySet() {
return columnMap().keySet();
Reported by PMD.
Line: 58
@Override
public Set<C> columnKeySet() {
return columnMap().keySet();
}
@Override
public boolean containsValue(@CheckForNull Object value) {
for (Map<C, V> row : rowMap().values()) {
Reported by PMD.
Line: 63
@Override
public boolean containsValue(@CheckForNull Object value) {
for (Map<C, V> row : rowMap().values()) {
if (row.containsValue(value)) {
return true;
}
}
return false;
Reported by PMD.
Line: 91
@Override
public void clear() {
Iterators.clear(cellSet().iterator());
}
@CanIgnoreReturnValue
@Override
@CheckForNull
Reported by PMD.
Line: 107
@CheckForNull
public V put(
@ParametricNullness R rowKey, @ParametricNullness C columnKey, @ParametricNullness V value) {
return row(rowKey).put(columnKey, value);
}
@Override
public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
for (Table.Cell<? extends R, ? extends C, ? extends V> cell : table.cellSet()) {
Reported by PMD.
Line: 117
}
}
@LazyInit @CheckForNull private transient Set<Cell<R, C, V>> cellSet;
@Override
public Set<Cell<R, C, V>> cellSet() {
Set<Cell<R, C, V>> result = cellSet;
return (result == null) ? cellSet = createCellSet() : result;
Reported by PMD.
Line: 137
public boolean contains(@CheckForNull Object o) {
if (o instanceof Cell) {
Cell<?, ?, ?> cell = (Cell<?, ?, ?>) o;
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
return row != null
&& Collections2.safeContains(
row.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue()));
}
return false;
Reported by PMD.
Line: 140
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
return row != null
&& Collections2.safeContains(
row.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue()));
}
return false;
}
@Override
Reported by PMD.
Line: 140
Map<C, V> row = Maps.safeGet(rowMap(), cell.getRowKey());
return row != null
&& Collections2.safeContains(
row.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue()));
}
return false;
}
@Override
Reported by PMD.
android/guava/src/com/google/common/collect/Ordering.java
27 issues
Line: 149
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class Ordering<T extends @Nullable Object> implements Comparator<T> {
// Natural order
/**
* Returns a serializable ordering that uses the natural order of the values. The ordering throws
* a {@link NullPointerException} when passed a null parameter.
Reported by PMD.
Line: 149
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class Ordering<T extends @Nullable Object> implements Comparator<T> {
// Natural order
/**
* Returns a serializable ordering that uses the natural order of the values. The ordering throws
* a {@link NullPointerException} when passed a null parameter.
Reported by PMD.
Line: 162
* <p><b>Java 8 users:</b> use {@link Comparator#naturalOrder} instead.
*/
@GwtCompatible(serializable = true)
@SuppressWarnings("unchecked") // TODO(kevinb): right way to explain this??
public static <C extends Comparable> Ordering<C> natural() {
return (Ordering<C>) NaturalOrdering.INSTANCE;
}
// Static factories
Reported by PMD.
Line: 327
@VisibleForTesting
static class ArbitraryOrdering extends Ordering<@Nullable Object> {
private final AtomicInteger counter = new AtomicInteger(0);
private final ConcurrentMap<Object, Integer> uids =
Platform.tryWeakKeys(new MapMaker()).makeMap();
private Integer getUid(Object obj) {
Integer uid = uids.get(obj);
Reported by PMD.
Line: 328
static class ArbitraryOrdering extends Ordering<@Nullable Object> {
private final AtomicInteger counter = new AtomicInteger(0);
private final ConcurrentMap<Object, Integer> uids =
Platform.tryWeakKeys(new MapMaker()).makeMap();
private Integer getUid(Object obj) {
Integer uid = uids.get(obj);
if (uid == null) {
Reported by PMD.
Line: 348
@Override
public int compare(@CheckForNull Object left, @CheckForNull Object right) {
if (left == right) {
return 0;
} else if (left == null) {
return -1;
} else if (right == null) {
return 1;
Reported by PMD.
Line: 362
}
// identityHashCode collision (rare, but not as rare as you'd think)
int result = getUid(left).compareTo(getUid(right));
if (result == 0) {
throw new AssertionError(); // extremely, extremely unlikely.
}
return result;
}
Reported by PMD.
Line: 738
public <E extends T> List<E> leastOf(Iterable<E> iterable, int k) {
if (iterable instanceof Collection) {
Collection<E> collection = (Collection<E>) iterable;
if (collection.size() <= 2L * k) {
// In this case, just dumping the collection to an array and sorting is
// faster than using the implementation for Iterator, which is
// specialized for k much smaller than n.
@SuppressWarnings("unchecked") // c only contains E's and doesn't escape
Reported by PMD.
Line: 744
// specialized for k much smaller than n.
@SuppressWarnings("unchecked") // c only contains E's and doesn't escape
E[] array = (E[]) collection.toArray();
Arrays.sort(array, this);
if (array.length > k) {
array = Arrays.copyOf(array, k);
}
return Collections.unmodifiableList(Arrays.asList(array));
Reported by PMD.
Line: 744
// specialized for k much smaller than n.
@SuppressWarnings("unchecked") // c only contains E's and doesn't escape
E[] array = (E[]) collection.toArray();
Arrays.sort(array, this);
if (array.length > k) {
array = Arrays.copyOf(array, k);
}
return Collections.unmodifiableList(Arrays.asList(array));
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapContainsKeyTester.java
27 issues
Line: 37
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapContainsKeyTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
public void testContainsKeyYes() {
assertTrue(multimap().containsKey(k0()));
}
public void testContainsKeyNo() {
Reported by PMD.
Line: 39
public class MultimapContainsKeyTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@CollectionSize.Require(absent = ZERO)
public void testContainsKeyYes() {
assertTrue(multimap().containsKey(k0()));
}
public void testContainsKeyNo() {
assertFalse(multimap().containsKey(k3()));
}
Reported by PMD.
Line: 42
assertTrue(multimap().containsKey(k0()));
}
public void testContainsKeyNo() {
assertFalse(multimap().containsKey(k3()));
}
public void testContainsKeysFromKeySet() {
for (K k : multimap().keySet()) {
Reported by PMD.
Line: 43
}
public void testContainsKeyNo() {
assertFalse(multimap().containsKey(k3()));
}
public void testContainsKeysFromKeySet() {
for (K k : multimap().keySet()) {
assertTrue(multimap().containsKey(k));
Reported by PMD.
Line: 46
assertFalse(multimap().containsKey(k3()));
}
public void testContainsKeysFromKeySet() {
for (K k : multimap().keySet()) {
assertTrue(multimap().containsKey(k));
}
}
Reported by PMD.
Line: 47
}
public void testContainsKeysFromKeySet() {
for (K k : multimap().keySet()) {
assertTrue(multimap().containsKey(k));
}
}
public void testContainsKeyAgreesWithGet() {
Reported by PMD.
Line: 48
public void testContainsKeysFromKeySet() {
for (K k : multimap().keySet()) {
assertTrue(multimap().containsKey(k));
}
}
public void testContainsKeyAgreesWithGet() {
for (K k : sampleKeys()) {
Reported by PMD.
Line: 52
}
}
public void testContainsKeyAgreesWithGet() {
for (K k : sampleKeys()) {
assertEquals(!multimap().get(k).isEmpty(), multimap().containsKey(k));
}
}
Reported by PMD.
Line: 54
public void testContainsKeyAgreesWithGet() {
for (K k : sampleKeys()) {
assertEquals(!multimap().get(k).isEmpty(), multimap().containsKey(k));
}
}
public void testContainsKeyAgreesWithAsMap() {
for (K k : sampleKeys()) {
Reported by PMD.
Line: 54
public void testContainsKeyAgreesWithGet() {
for (K k : sampleKeys()) {
assertEquals(!multimap().get(k).isEmpty(), multimap().containsKey(k));
}
}
public void testContainsKeyAgreesWithAsMap() {
for (K k : sampleKeys()) {
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
27 issues
Line: 46
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends @Nullable Object>
extends AggregateFutureState<OutputT> {
private static final Logger logger = Logger.getLogger(AggregateFuture.class.getName());
/**
* The input futures. After {@link #init}, this field is read only by {@link #afterDone()} (to
* propagate cancellation) and {@link #toString()}. To access the futures' <i>values</i>, {@code
Reported by PMD.
Line: 59
* In certain circumstances, this field might theoretically not be visible to an afterDone() call
* triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
*/
@CheckForNull private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
private final boolean allMustSucceed;
private final boolean collectsValues;
AggregateFuture(
Reported by PMD.
Line: 61
*/
@CheckForNull private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
private final boolean allMustSucceed;
private final boolean collectsValues;
AggregateFuture(
ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures,
boolean allMustSucceed,
Reported by PMD.
Line: 62
@CheckForNull private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
private final boolean allMustSucceed;
private final boolean collectsValues;
AggregateFuture(
ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures,
boolean allMustSucceed,
boolean collectsValues) {
Reported by PMD.
Line: 141
for (final ListenableFuture<? extends InputT> future : futures) {
final int index = i++;
future.addListener(
new Runnable() {
@Override
public void run() {
try {
if (future.isCancelled()) {
// Clear futures prior to cancelling children. This sets our own state but lets
Reported by PMD.
Line: 148
if (future.isCancelled()) {
// Clear futures prior to cancelling children. This sets our own state but lets
// the input futures keep running, as some of them may be used elsewhere.
futures = null;
cancel(false);
} else {
collectValueFromNonCancelledFuture(index, future);
}
} finally {
Reported by PMD.
Line: 256
* TODO(cpovirk): Think about whether we could/should use Verify to check the return value of
* addCausalChain.
*/
boolean unused = addCausalChain(seen, requireNonNull(tryInternalFastPathGetFailure()));
}
}
/**
* Collects the result (success or failure) of one input future. The input must not have been
Reported by PMD.
Line: 270
collectOneValue(index, getDone(future));
} catch (ExecutionException e) {
handleException(e.getCause());
} catch (Throwable t) {
handleException(t);
}
}
private void decrementCountAndMaybeComplete(
Reported by PMD.
Line: 331
* either case, no one needs to read `futures` for cancellation purposes later. (And
* cancellation purposes are the main reason to access `futures`, as discussed in its docs.)
*/
this.futures = null;
}
enum ReleaseResourcesReason {
OUTPUT_FUTURE_DONE,
ALL_INPUT_FUTURES_PROCESSED,
Reported by PMD.
Line: 82
releaseResources(OUTPUT_FUTURE_DONE); // nulls out `futures`
if (isCancelled() & localFutures != null) {
boolean wasInterrupted = wasInterrupted();
for (Future<?> future : localFutures) {
future.cancel(wasInterrupted);
}
}
/*
Reported by PMD.