The following issues were found
guava-testlib/src/com/google/common/collect/testing/google/MultimapPutAllMultimapTester.java
41 issues
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapPutAllMultimapTester<K, V>
extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutUnsupported() {
try {
multimap().putAll(getSubjectGenerator().create(Helpers.mapEntry(k3(), v3())));
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
Reported by PMD.
Line: 43
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutUnsupported() {
try {
multimap().putAll(getSubjectGenerator().create(Helpers.mapEntry(k3(), v3())));
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 43
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutUnsupported() {
try {
multimap().putAll(getSubjectGenerator().create(Helpers.mapEntry(k3(), v3())));
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 49
}
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
Reported by PMD.
Line: 50
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
Reported by PMD.
Line: 51
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 52
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Reported by PMD.
Line: 52
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Reported by PMD.
Line: 56
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Multimap<K, V> source =
getSubjectGenerator().create(Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k3(), v3()));
assertTrue(multimap().putAll(source));
assertTrue(multimap().containsEntry(k0(), v3()));
Reported by PMD.
Line: 57
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Multimap<K, V> source =
getSubjectGenerator().create(Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k3(), v3()));
assertTrue(multimap().putAll(source));
assertTrue(multimap().containsEntry(k0(), v3()));
assertTrue(multimap().containsEntry(k3(), v3()));
Reported by PMD.
guava-tests/benchmark/com/google/common/math/ApacheBenchmark.java
41 issues
Line: 36
*
* @author Louis Wasserman
*/
public class ApacheBenchmark {
private enum Impl {
GUAVA {
@Override
public double factorialDouble(int n) {
return DoubleMath.factorial(n);
Reported by PMD.
Line: 36
*
* @author Louis Wasserman
*/
public class ApacheBenchmark {
private enum Impl {
GUAVA {
@Override
public double factorialDouble(int n) {
return DoubleMath.factorial(n);
Reported by PMD.
Line: 62
@Override
public boolean noAddOverflow(int a, int b) {
try {
int unused = IntMath.checkedAdd(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 72
@Override
public boolean noAddOverflow(long a, long b) {
try {
long unused = LongMath.checkedAdd(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 82
@Override
public boolean noMulOverflow(int a, int b) {
try {
int unused = IntMath.checkedMultiply(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 92
@Override
public boolean noMulOverflow(long a, long b) {
try {
long unused = LongMath.checkedMultiply(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 117
public abstract boolean noMulOverflow(long a, long b);
}
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
Reported by PMD.
Line: 118
}
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
private final long[][] longsToAdd = new long[ARRAY_SIZE][2];
Reported by PMD.
Line: 119
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
private final long[][] longsToAdd = new long[ARRAY_SIZE][2];
private final long[][] longsToMul = new long[ARRAY_SIZE][2];
Reported by PMD.
Line: 120
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
private final long[][] longsToAdd = new long[ARRAY_SIZE][2];
private final long[][] longsToMul = new long[ARRAY_SIZE][2];
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
41 issues
Line: 44
*/
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionToArrayTester<E> extends AbstractCollectionTester<E> {
public void testToArray_noArgs() {
Object[] array = collection.toArray();
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
Reported by PMD.
Line: 45
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionToArrayTester<E> extends AbstractCollectionTester<E> {
public void testToArray_noArgs() {
Object[] array = collection.toArray();
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
/**
Reported by PMD.
Line: 57
* <p>For maximum effect, the collection under test should be created from an element array of a
* type other than {@code Object[]}.
*/
public void testToArray_isPlainObjectArray() {
Object[] array = collection.toArray();
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
Reported by PMD.
Line: 59
*/
public void testToArray_isPlainObjectArray() {
Object[] array = collection.toArray();
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
Reported by PMD.
Line: 62
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
Reported by PMD.
Line: 62
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
Reported by PMD.
Line: 63
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
expectArrayContentsAnyOrder(createSamplesArray(), array);
Reported by PMD.
Line: 66
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
@CollectionFeature.Require(KNOWN_ORDER)
Reported by PMD.
Line: 66
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
@CollectionFeature.Require(KNOWN_ORDER)
Reported by PMD.
Line: 71
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
@CollectionFeature.Require(KNOWN_ORDER)
public void testToArray_emptyArray_ordered() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
Reported by PMD.
guava-tests/test/com/google/common/io/CharSourceTester.java
41 issues
Line: 45
* @author Colin Decker
*/
@AndroidIncompatible // Android doesn't understand tests that lack default constructors.
public class CharSourceTester extends SourceSinkTester<CharSource, String, CharSourceFactory> {
private static final ImmutableList<Method> testMethods = getTestMethods(CharSourceTester.class);
static TestSuite tests(String name, CharSourceFactory factory, boolean testAsByteSource) {
TestSuite suite = new TestSuite(name);
Reported by PMD.
Line: 55
if (testAsByteSource) {
suite.addTest(
suiteForBytes(
factory, entry.getValue().getBytes(Charsets.UTF_8), name, entry.getKey(), true));
} else {
suite.addTest(suiteForString(factory, entry.getValue(), name, entry.getKey()));
}
}
return suite;
Reported by PMD.
Line: 77
CharSourceFactory factory, String string, String name, String desc) {
TestSuite suite = new TestSuite(name + " [" + desc + "]");
for (Method method : testMethods) {
suite.addTest(new CharSourceTester(factory, string, name, desc, method));
}
return suite;
}
private final ImmutableList<String> expectedLines;
Reported by PMD.
Line: 82
return suite;
}
private final ImmutableList<String> expectedLines;
private CharSource source;
public CharSourceTester(
CharSourceFactory factory, String string, String suiteName, String caseDesc, Method method) {
Reported by PMD.
Line: 84
private final ImmutableList<String> expectedLines;
private CharSource source;
public CharSourceTester(
CharSourceFactory factory, String string, String suiteName, String caseDesc, Method method) {
super(factory, string, suiteName, caseDesc, method);
this.expectedLines = getLines(expected);
Reported by PMD.
Line: 92
this.expectedLines = getLines(expected);
}
@Override
protected void setUp() throws Exception {
this.source = factory.createSource(data);
}
public void testOpenStream() throws IOException {
Reported by PMD.
Line: 97
this.source = factory.createSource(data);
}
public void testOpenStream() throws IOException {
Reader reader = source.openStream();
StringWriter writer = new StringWriter();
char[] buf = new char[64];
int read;
Reported by PMD.
Line: 98
}
public void testOpenStream() throws IOException {
Reader reader = source.openStream();
StringWriter writer = new StringWriter();
char[] buf = new char[64];
int read;
while ((read = reader.read(buf)) != -1) {
Reported by PMD.
Line: 103
StringWriter writer = new StringWriter();
char[] buf = new char[64];
int read;
while ((read = reader.read(buf)) != -1) {
writer.write(buf, 0, read);
}
reader.close();
writer.close();
Reported by PMD.
Line: 103
StringWriter writer = new StringWriter();
char[] buf = new char[64];
int read;
while ((read = reader.read(buf)) != -1) {
writer.write(buf, 0, read);
}
reader.close();
writer.close();
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapPutAllMultimapTester.java
41 issues
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapPutAllMultimapTester<K, V>
extends AbstractMultimapTester<K, V, Multimap<K, V>> {
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutUnsupported() {
try {
multimap().putAll(getSubjectGenerator().create(Helpers.mapEntry(k3(), v3())));
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
Reported by PMD.
Line: 43
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutUnsupported() {
try {
multimap().putAll(getSubjectGenerator().create(Helpers.mapEntry(k3(), v3())));
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 43
@MapFeature.Require(absent = SUPPORTS_PUT)
public void testPutUnsupported() {
try {
multimap().putAll(getSubjectGenerator().create(Helpers.mapEntry(k3(), v3())));
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
}
Reported by PMD.
Line: 49
}
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
Reported by PMD.
Line: 50
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
Reported by PMD.
Line: 51
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
Reported by PMD.
Line: 52
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Reported by PMD.
Line: 52
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Reported by PMD.
Line: 56
assertEquals(multimap(), target);
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Multimap<K, V> source =
getSubjectGenerator().create(Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k3(), v3()));
assertTrue(multimap().putAll(source));
assertTrue(multimap().containsEntry(k0(), v3()));
Reported by PMD.
Line: 57
}
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAll() {
Multimap<K, V> source =
getSubjectGenerator().create(Helpers.mapEntry(k0(), v3()), Helpers.mapEntry(k3(), v3()));
assertTrue(multimap().putAll(source));
assertTrue(multimap().containsEntry(k0(), v3()));
assertTrue(multimap().containsEntry(k3(), v3()));
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionToArrayTester.java
41 issues
Line: 44
*/
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionToArrayTester<E> extends AbstractCollectionTester<E> {
public void testToArray_noArgs() {
Object[] array = collection.toArray();
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
Reported by PMD.
Line: 45
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class CollectionToArrayTester<E> extends AbstractCollectionTester<E> {
public void testToArray_noArgs() {
Object[] array = collection.toArray();
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
/**
Reported by PMD.
Line: 57
* <p>For maximum effect, the collection under test should be created from an element array of a
* type other than {@code Object[]}.
*/
public void testToArray_isPlainObjectArray() {
Object[] array = collection.toArray();
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
Reported by PMD.
Line: 59
*/
public void testToArray_isPlainObjectArray() {
Object[] array = collection.toArray();
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
Reported by PMD.
Line: 62
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
Reported by PMD.
Line: 62
assertEquals(Object[].class, array.getClass());
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
Reported by PMD.
Line: 63
}
public void testToArray_emptyArray() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
expectArrayContentsAnyOrder(createSamplesArray(), array);
Reported by PMD.
Line: 66
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
@CollectionFeature.Require(KNOWN_ORDER)
Reported by PMD.
Line: 66
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length);
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
@CollectionFeature.Require(KNOWN_ORDER)
Reported by PMD.
Line: 71
expectArrayContentsAnyOrder(createSamplesArray(), array);
}
@CollectionFeature.Require(KNOWN_ORDER)
public void testToArray_emptyArray_ordered() {
E[] empty = getSubjectGenerator().createArray(0);
E[] array = collection.toArray(empty);
assertEquals(
"toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/SortedMapInterfaceTest.java
41 issues
Line: 44
}
@Override
protected abstract SortedMap<K, V> makeEmptyMap() throws UnsupportedOperationException;
@Override
protected abstract SortedMap<K, V> makePopulatedMap() throws UnsupportedOperationException;
@Override
Reported by PMD.
Line: 47
protected abstract SortedMap<K, V> makeEmptyMap() throws UnsupportedOperationException;
@Override
protected abstract SortedMap<K, V> makePopulatedMap() throws UnsupportedOperationException;
@Override
protected SortedMap<K, V> makeEitherMap() {
try {
return makePopulatedMap();
Reported by PMD.
Line: 58
}
}
public void testTailMapWriteThrough() {
final SortedMap<K, V> map;
try {
map = makePopulatedMap();
} catch (UnsupportedOperationException e) {
return;
Reported by PMD.
Line: 58
}
}
public void testTailMapWriteThrough() {
final SortedMap<K, V> map;
try {
map = makePopulatedMap();
} catch (UnsupportedOperationException e) {
return;
Reported by PMD.
Line: 65
} catch (UnsupportedOperationException e) {
return;
}
if (map.size() < 2 || !supportsPut) {
return;
}
Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
Entry<K, V> firstEntry = iterator.next();
Entry<K, V> secondEntry = iterator.next();
Reported by PMD.
Line: 68
if (map.size() < 2 || !supportsPut) {
return;
}
Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
Entry<K, V> firstEntry = iterator.next();
Entry<K, V> secondEntry = iterator.next();
K key = secondEntry.getKey();
SortedMap<K, V> subMap = map.tailMap(key);
V value = getValueNotInPopulatedMap();
Reported by PMD.
Line: 68
if (map.size() < 2 || !supportsPut) {
return;
}
Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
Entry<K, V> firstEntry = iterator.next();
Entry<K, V> secondEntry = iterator.next();
K key = secondEntry.getKey();
SortedMap<K, V> subMap = map.tailMap(key);
V value = getValueNotInPopulatedMap();
Reported by PMD.
Line: 71
Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
Entry<K, V> firstEntry = iterator.next();
Entry<K, V> secondEntry = iterator.next();
K key = secondEntry.getKey();
SortedMap<K, V> subMap = map.tailMap(key);
V value = getValueNotInPopulatedMap();
subMap.put(key, value);
assertEquals(secondEntry.getValue(), value);
assertEquals(map.get(key), value);
Reported by PMD.
Line: 72
Entry<K, V> firstEntry = iterator.next();
Entry<K, V> secondEntry = iterator.next();
K key = secondEntry.getKey();
SortedMap<K, V> subMap = map.tailMap(key);
V value = getValueNotInPopulatedMap();
subMap.put(key, value);
assertEquals(secondEntry.getValue(), value);
assertEquals(map.get(key), value);
try {
Reported by PMD.
Line: 74
K key = secondEntry.getKey();
SortedMap<K, V> subMap = map.tailMap(key);
V value = getValueNotInPopulatedMap();
subMap.put(key, value);
assertEquals(secondEntry.getValue(), value);
assertEquals(map.get(key), value);
try {
subMap.put(firstEntry.getKey(), value);
fail("Expected IllegalArgumentException");
Reported by PMD.
android/guava-tests/benchmark/com/google/common/math/ApacheBenchmark.java
41 issues
Line: 36
*
* @author Louis Wasserman
*/
public class ApacheBenchmark {
private enum Impl {
GUAVA {
@Override
public double factorialDouble(int n) {
return DoubleMath.factorial(n);
Reported by PMD.
Line: 36
*
* @author Louis Wasserman
*/
public class ApacheBenchmark {
private enum Impl {
GUAVA {
@Override
public double factorialDouble(int n) {
return DoubleMath.factorial(n);
Reported by PMD.
Line: 62
@Override
public boolean noAddOverflow(int a, int b) {
try {
int unused = IntMath.checkedAdd(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 72
@Override
public boolean noAddOverflow(long a, long b) {
try {
long unused = LongMath.checkedAdd(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 82
@Override
public boolean noMulOverflow(int a, int b) {
try {
int unused = IntMath.checkedMultiply(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 92
@Override
public boolean noMulOverflow(long a, long b) {
try {
long unused = LongMath.checkedMultiply(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
Reported by PMD.
Line: 117
public abstract boolean noMulOverflow(long a, long b);
}
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
Reported by PMD.
Line: 118
}
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
private final long[][] longsToAdd = new long[ARRAY_SIZE][2];
Reported by PMD.
Line: 119
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
private final long[][] longsToAdd = new long[ARRAY_SIZE][2];
private final long[][] longsToMul = new long[ARRAY_SIZE][2];
Reported by PMD.
Line: 120
private final int[] factorials = new int[ARRAY_SIZE];
private final int[][] binomials = new int[ARRAY_SIZE][2];
private final int[][] nonnegInt = new int[ARRAY_SIZE][2];
private final long[][] nonnegLong = new long[ARRAY_SIZE][2];
private final int[][] intsToAdd = new int[ARRAY_SIZE][2];
private final int[][] intsToMul = new int[ARRAY_SIZE][2];
private final long[][] longsToAdd = new long[ARRAY_SIZE][2];
private final long[][] longsToMul = new long[ARRAY_SIZE][2];
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ComparatorsTest.java
41 issues
Line: 36
*/
@GwtCompatible
public class ComparatorsTest extends TestCase {
@SuppressWarnings("unchecked") // dang varargs
public void testLexicographical() {
Comparator<String> comparator = Ordering.natural();
Comparator<Iterable<String>> lexy = Comparators.lexicographical(comparator);
ImmutableList<String> empty = ImmutableList.of();
Reported by PMD.
Line: 37
@GwtCompatible
public class ComparatorsTest extends TestCase {
@SuppressWarnings("unchecked") // dang varargs
public void testLexicographical() {
Comparator<String> comparator = Ordering.natural();
Comparator<Iterable<String>> lexy = Comparators.lexicographical(comparator);
ImmutableList<String> empty = ImmutableList.of();
ImmutableList<String> a = ImmutableList.of("a");
Reported by PMD.
Line: 56
.testEquals();
}
public void testIsInOrder() {
assertFalse(Comparators.isInOrder(asList(5, 3, 0, 9), Ordering.natural()));
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
Reported by PMD.
Line: 56
.testEquals();
}
public void testIsInOrder() {
assertFalse(Comparators.isInOrder(asList(5, 3, 0, 9), Ordering.natural()));
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
Reported by PMD.
Line: 57
}
public void testIsInOrder() {
assertFalse(Comparators.isInOrder(asList(5, 3, 0, 9), Ordering.natural()));
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.singleton(1), Ordering.natural()));
Reported by PMD.
Line: 58
public void testIsInOrder() {
assertFalse(Comparators.isInOrder(asList(5, 3, 0, 9), Ordering.natural()));
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.singleton(1), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.<Integer>emptyList(), Ordering.natural()));
Reported by PMD.
Line: 59
public void testIsInOrder() {
assertFalse(Comparators.isInOrder(asList(5, 3, 0, 9), Ordering.natural()));
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.singleton(1), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.<Integer>emptyList(), Ordering.natural()));
}
Reported by PMD.
Line: 60
assertFalse(Comparators.isInOrder(asList(5, 3, 0, 9), Ordering.natural()));
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.singleton(1), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.<Integer>emptyList(), Ordering.natural()));
}
Reported by PMD.
Line: 61
assertFalse(Comparators.isInOrder(asList(0, 5, 3, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.singleton(1), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.<Integer>emptyList(), Ordering.natural()));
}
public void testIsInStrictOrder() {
Reported by PMD.
Line: 62
assertTrue(Comparators.isInOrder(asList(0, 3, 5, 9), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 0, 3, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(asList(0, 3), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.singleton(1), Ordering.natural()));
assertTrue(Comparators.isInOrder(Collections.<Integer>emptyList(), Ordering.natural()));
}
public void testIsInStrictOrder() {
assertFalse(Comparators.isInStrictOrder(asList(5, 3, 0, 9), Ordering.natural()));
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/testers/MapRemoveTester.java
40 issues
Line: 46
@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 MapRemoveTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = getMap().size();
assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
Reported by PMD.
Line: 47
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapRemoveTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = getMap().size();
assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
assertEquals(
Reported by PMD.
Line: 49
public class MapRemoveTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = getMap().size();
assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
assertEquals(
"remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
expectMissing(e0());
Reported by PMD.
Line: 50
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = getMap().size();
assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
assertEquals(
"remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
expectMissing(e0());
}
Reported by PMD.
Line: 51
@CollectionSize.Require(absent = ZERO)
public void testRemove_present() {
int initialSize = getMap().size();
assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
assertEquals(
"remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
expectMissing(e0());
}
Reported by PMD.
Line: 53
int initialSize = getMap().size();
assertEquals("remove(present) should return the associated value", v0(), getMap().remove(k0()));
assertEquals(
"remove(present) should decrease a map's size by one.", initialSize - 1, getMap().size());
expectMissing(e0());
}
@MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_REMOVE})
@CollectionSize.Require(SEVERAL)
Reported by PMD.
Line: 57
expectMissing(e0());
}
@MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_REMOVE})
@CollectionSize.Require(SEVERAL)
public void testRemovePresentConcurrentWithEntrySetIteration() {
try {
Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
getMap().remove(k0());
Reported by PMD.
Line: 61
@CollectionSize.Require(SEVERAL)
public void testRemovePresentConcurrentWithEntrySetIteration() {
try {
Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
getMap().remove(k0());
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
// success
Reported by PMD.
Line: 61
@CollectionSize.Require(SEVERAL)
public void testRemovePresentConcurrentWithEntrySetIteration() {
try {
Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
getMap().remove(k0());
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
// success
Reported by PMD.
Line: 62
public void testRemovePresentConcurrentWithEntrySetIteration() {
try {
Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator();
getMap().remove(k0());
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
// success
}
Reported by PMD.