The following issues were found
android/guava/src/com/google/common/collect/FilteredKeyMultimap.java
13 issues
Line: 44
@GwtCompatible
@ElementTypesAreNonnullByDefault
class FilteredKeyMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super K> keyPredicate;
FilteredKeyMultimap(Multimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
this.unfiltered = checkNotNull(unfiltered);
Reported by PMD.
Line: 45
@ElementTypesAreNonnullByDefault
class FilteredKeyMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super K> keyPredicate;
FilteredKeyMultimap(Multimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
this.unfiltered = checkNotNull(unfiltered);
this.keyPredicate = checkNotNull(keyPredicate);
Reported by PMD.
Line: 45
@ElementTypesAreNonnullByDefault
class FilteredKeyMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super K> keyPredicate;
FilteredKeyMultimap(Multimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
this.unfiltered = checkNotNull(unfiltered);
this.keyPredicate = checkNotNull(keyPredicate);
Reported by PMD.
Line: 46
class FilteredKeyMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements FilteredMultimap<K, V> {
final Multimap<K, V> unfiltered;
final Predicate<? super K> keyPredicate;
FilteredKeyMultimap(Multimap<K, V> unfiltered, Predicate<? super K> keyPredicate) {
this.unfiltered = checkNotNull(unfiltered);
this.keyPredicate = checkNotNull(keyPredicate);
}
Reported by PMD.
Line: 66
@Override
public int size() {
int size = 0;
for (Collection<V> collection : asMap().values()) {
size += collection.size();
}
return size;
}
Reported by PMD.
Line: 97
@Override
public void clear() {
keySet().clear();
}
@Override
Set<K> createKeySet() {
return Sets.filter(unfiltered.keySet(), keyPredicate);
Reported by PMD.
Line: 118
static class AddRejectingSet<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingSet<V> {
@ParametricNullness final K key;
AddRejectingSet(@ParametricNullness K key) {
this.key = key;
}
Reported by PMD.
Line: 126
@Override
public boolean add(@ParametricNullness V element) {
throw new IllegalArgumentException("Key does not satisfy predicate: " + key);
}
@Override
public boolean addAll(Collection<? extends V> collection) {
checkNotNull(collection);
Reported by PMD.
Line: 143
static class AddRejectingList<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingList<V> {
@ParametricNullness final K key;
AddRejectingList(@ParametricNullness K key) {
this.key = key;
}
Reported by PMD.
Line: 203
public boolean remove(@CheckForNull Object o) {
if (o instanceof Entry) {
Entry<?, ?> entry = (Entry<?, ?>) o;
if (unfiltered.containsKey(entry.getKey())
// if this holds, then we know entry.getKey() is a K
&& keyPredicate.apply((K) entry.getKey())) {
return unfiltered.remove(entry.getKey(), entry.getValue());
}
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/PerCollectionSizeTestSuiteBuilder.java
13 issues
Line: 64
Set<Feature<?>> features = Helpers.copyToSet(getFeatures());
List<Class<? extends AbstractTester>> testers = getTesters();
logger.fine(" Testing: " + name);
// Split out all the specified sizes.
Set<Feature<?>> sizesToTest = Helpers.<Feature<?>>copyToSet(CollectionSize.values());
sizesToTest.retainAll(features);
features.removeAll(sizesToTest);
Reported by PMD.
Line: 75
sizesToTest.retainAll(
Arrays.asList(CollectionSize.ZERO, CollectionSize.ONE, CollectionSize.SEVERAL));
logger.fine(" Sizes: " + formatFeatureSet(sizesToTest));
if (sizesToTest.isEmpty()) {
throw new IllegalStateException(
name
+ ": no CollectionSizes specified (check the argument to "
Reported by PMD.
Line: 68
// Split out all the specified sizes.
Set<Feature<?>> sizesToTest = Helpers.<Feature<?>>copyToSet(CollectionSize.values());
sizesToTest.retainAll(features);
features.removeAll(sizesToTest);
FeatureUtil.addImpliedFeatures(sizesToTest);
sizesToTest.retainAll(
Arrays.asList(CollectionSize.ZERO, CollectionSize.ONE, CollectionSize.SEVERAL));
Reported by PMD.
Line: 69
// Split out all the specified sizes.
Set<Feature<?>> sizesToTest = Helpers.<Feature<?>>copyToSet(CollectionSize.values());
sizesToTest.retainAll(features);
features.removeAll(sizesToTest);
FeatureUtil.addImpliedFeatures(sizesToTest);
sizesToTest.retainAll(
Arrays.asList(CollectionSize.ZERO, CollectionSize.ONE, CollectionSize.SEVERAL));
Reported by PMD.
Line: 72
features.removeAll(sizesToTest);
FeatureUtil.addImpliedFeatures(sizesToTest);
sizesToTest.retainAll(
Arrays.asList(CollectionSize.ZERO, CollectionSize.ONE, CollectionSize.SEVERAL));
logger.fine(" Sizes: " + formatFeatureSet(sizesToTest));
if (sizesToTest.isEmpty()) {
Reported by PMD.
Line: 77
logger.fine(" Sizes: " + formatFeatureSet(sizesToTest));
if (sizesToTest.isEmpty()) {
throw new IllegalStateException(
name
+ ": no CollectionSizes specified (check the argument to "
+ "FeatureSpecificTestSuiteBuilder.withFeatures().)");
}
Reported by PMD.
Line: 88
for (Feature<?> collectionSize : sizesToTest) {
String oneSizeName =
Platform.format(
"%s [collection size: %s]", name, collectionSize.toString().toLowerCase());
OneSizeGenerator<T, E> oneSizeGenerator =
new OneSizeGenerator<>(getSubjectGenerator(), (CollectionSize) collectionSize);
Set<Feature<?>> oneSizeFeatures = Helpers.copyToSet(features);
oneSizeFeatures.add(collectionSize);
Set<Method> oneSizeSuppressedTests = getSuppressedTests();
Reported by PMD.
Line: 88
for (Feature<?> collectionSize : sizesToTest) {
String oneSizeName =
Platform.format(
"%s [collection size: %s]", name, collectionSize.toString().toLowerCase());
OneSizeGenerator<T, E> oneSizeGenerator =
new OneSizeGenerator<>(getSubjectGenerator(), (CollectionSize) collectionSize);
Set<Feature<?>> oneSizeFeatures = Helpers.copyToSet(features);
oneSizeFeatures.add(collectionSize);
Set<Method> oneSizeSuppressedTests = getSuppressedTests();
Reported by PMD.
Line: 90
Platform.format(
"%s [collection size: %s]", name, collectionSize.toString().toLowerCase());
OneSizeGenerator<T, E> oneSizeGenerator =
new OneSizeGenerator<>(getSubjectGenerator(), (CollectionSize) collectionSize);
Set<Feature<?>> oneSizeFeatures = Helpers.copyToSet(features);
oneSizeFeatures.add(collectionSize);
Set<Method> oneSizeSuppressedTests = getSuppressedTests();
OneSizeTestSuiteBuilder<T, E> oneSizeBuilder =
Reported by PMD.
Line: 92
OneSizeGenerator<T, E> oneSizeGenerator =
new OneSizeGenerator<>(getSubjectGenerator(), (CollectionSize) collectionSize);
Set<Feature<?>> oneSizeFeatures = Helpers.copyToSet(features);
oneSizeFeatures.add(collectionSize);
Set<Method> oneSizeSuppressedTests = getSuppressedTests();
OneSizeTestSuiteBuilder<T, E> oneSizeBuilder =
new OneSizeTestSuiteBuilder<T, E>(testers)
.named(oneSizeName)
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/SafeTreeMap.java
13 issues
Line: 70
private SafeTreeMap(NavigableMap<K, V> delegate) {
this.delegate = delegate;
if (delegate == null) {
throw new NullPointerException();
}
for (K k : keySet()) {
checkValid(k);
}
}
Reported by PMD.
Line: 39
* @author Louis Wasserman
*/
@GwtIncompatible
public final class SafeTreeMap<K, V> implements Serializable, NavigableMap<K, V> {
@SuppressWarnings("unchecked")
private static final Comparator<Object> NATURAL_ORDER =
new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
Reported by PMD.
Line: 49
}
};
private final NavigableMap<K, V> delegate;
public SafeTreeMap() {
this(new TreeMap<K, V>());
}
Reported by PMD.
Line: 106
public boolean containsKey(Object key) {
try {
return delegate.containsKey(checkValid(key));
} catch (NullPointerException | ClassCastException e) {
return false;
}
}
@Override
Reported by PMD.
Line: 106
public boolean containsKey(Object key) {
try {
return delegate.containsKey(checkValid(key));
} catch (NullPointerException | ClassCastException e) {
return false;
}
}
@Override
Reported by PMD.
Line: 136
@Override
public boolean contains(Object object) {
try {
return delegate().contains(object);
} catch (NullPointerException | ClassCastException e) {
return false;
}
}
Reported by PMD.
Line: 137
public boolean contains(Object object) {
try {
return delegate().contains(object);
} catch (NullPointerException | ClassCastException e) {
return false;
}
}
@Override
Reported by PMD.
Line: 137
public boolean contains(Object object) {
try {
return delegate().contains(object);
} catch (NullPointerException | ClassCastException e) {
return false;
}
}
@Override
Reported by PMD.
Line: 144
@Override
public Iterator<Entry<K, V>> iterator() {
return delegate().iterator();
}
@Override
public int size() {
return delegate().size();
Reported by PMD.
Line: 149
@Override
public int size() {
return delegate().size();
}
@Override
public boolean remove(Object o) {
return delegate().remove(o);
Reported by PMD.
android/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
13 issues
Line: 32
*/
public class TypeParameterTest extends TestCase {
public <T> void testCaptureTypeParameter() throws Exception {
TypeVariable<?> variable = new TypeParameter<T>() {}.typeVariable;
TypeVariable<?> expected =
TypeParameterTest.class.getDeclaredMethod("testCaptureTypeParameter")
.getTypeParameters()[0];
assertEquals(expected, variable);
Reported by PMD.
Line: 35
public <T> void testCaptureTypeParameter() throws Exception {
TypeVariable<?> variable = new TypeParameter<T>() {}.typeVariable;
TypeVariable<?> expected =
TypeParameterTest.class.getDeclaredMethod("testCaptureTypeParameter")
.getTypeParameters()[0];
assertEquals(expected, variable);
}
public void testConcreteTypeRejected() {
Reported by PMD.
Line: 35
public <T> void testCaptureTypeParameter() throws Exception {
TypeVariable<?> variable = new TypeParameter<T>() {}.typeVariable;
TypeVariable<?> expected =
TypeParameterTest.class.getDeclaredMethod("testCaptureTypeParameter")
.getTypeParameters()[0];
assertEquals(expected, variable);
}
public void testConcreteTypeRejected() {
Reported by PMD.
Line: 37
TypeVariable<?> expected =
TypeParameterTest.class.getDeclaredMethod("testCaptureTypeParameter")
.getTypeParameters()[0];
assertEquals(expected, variable);
}
public void testConcreteTypeRejected() {
try {
new TypeParameter<String>() {};
Reported by PMD.
Line: 40
assertEquals(expected, variable);
}
public void testConcreteTypeRejected() {
try {
new TypeParameter<String>() {};
fail();
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 43
public void testConcreteTypeRejected() {
try {
new TypeParameter<String>() {};
fail();
} catch (IllegalArgumentException expected) {
}
}
public <A, B> void testEquals() throws Exception {
Reported by PMD.
Line: 43
public void testConcreteTypeRejected() {
try {
new TypeParameter<String>() {};
fail();
} catch (IllegalArgumentException expected) {
}
}
public <A, B> void testEquals() throws Exception {
Reported by PMD.
Line: 48
}
}
public <A, B> void testEquals() throws Exception {
Method method = TypeParameterTest.class.getDeclaredMethod("testEquals");
new EqualsTester()
.addEqualityGroup(new TypeParameter<A>() {}, new TypeParameter<A>() {})
.addEqualityGroup(new TypeParameter<B>() {})
.testEquals();
Reported by PMD.
Line: 48
}
}
public <A, B> void testEquals() throws Exception {
Method method = TypeParameterTest.class.getDeclaredMethod("testEquals");
new EqualsTester()
.addEqualityGroup(new TypeParameter<A>() {}, new TypeParameter<A>() {})
.addEqualityGroup(new TypeParameter<B>() {})
.testEquals();
Reported by PMD.
Line: 49
}
public <A, B> void testEquals() throws Exception {
Method method = TypeParameterTest.class.getDeclaredMethod("testEquals");
new EqualsTester()
.addEqualityGroup(new TypeParameter<A>() {}, new TypeParameter<A>() {})
.addEqualityGroup(new TypeParameter<B>() {})
.testEquals();
}
Reported by PMD.
android/guava/src/com/google/common/collect/TopKSelector.java
13 issues
Line: 58
@GwtCompatible
@ElementTypesAreNonnullByDefault
final class TopKSelector<
T extends @Nullable Object> {
/**
* Returns a {@code TopKSelector} that collects the lowest {@code k} elements added to it,
* relative to the natural ordering of the elements, and returns them via {@link #topK} in
* ascending order.
Reported by PMD.
Line: 101
*/
public static <T extends @Nullable Object> TopKSelector<T> greatest(
int k, Comparator<? super T> comparator) {
return new TopKSelector<T>(Ordering.from(comparator).reverse(), k);
}
private final int k;
private final Comparator<? super T> comparator;
Reported by PMD.
Line: 104
return new TopKSelector<T>(Ordering.from(comparator).reverse(), k);
}
private final int k;
private final Comparator<? super T> comparator;
/*
* We are currently considering the elements in buffer in the range [0, bufferSize) as candidates
* for the top k elements. Whenever the buffer is filled, we quickselect the top k elements to the
Reported by PMD.
Line: 105
}
private final int k;
private final Comparator<? super T> comparator;
/*
* We are currently considering the elements in buffer in the range [0, bufferSize) as candidates
* for the top k elements. Whenever the buffer is filled, we quickselect the top k elements to the
* range [0, k) and ignore the remaining elements.
Reported by PMD.
Line: 112
* for the top k elements. Whenever the buffer is filled, we quickselect the top k elements to the
* range [0, k) and ignore the remaining elements.
*/
private final @Nullable T[] buffer;
private int bufferSize;
/**
* The largest of the lowest k elements we've seen so far relative to this comparator. If
* bufferSize ≥ k, then we can ignore any elements greater than this value.
Reported by PMD.
Line: 113
* range [0, k) and ignore the remaining elements.
*/
private final @Nullable T[] buffer;
private int bufferSize;
/**
* The largest of the lowest k elements we've seen so far relative to this comparator. If
* bufferSize ≥ k, then we can ignore any elements greater than this value.
*/
Reported by PMD.
Line: 119
* The largest of the lowest k elements we've seen so far relative to this comparator. If
* bufferSize ≥ k, then we can ignore any elements greater than this value.
*/
@CheckForNull private T threshold;
private TopKSelector(Comparator<? super T> comparator, int k) {
this.comparator = checkNotNull(comparator, "comparator");
this.k = k;
checkArgument(k >= 0, "k (%s) must be >= 0", k);
Reported by PMD.
Line: 128
checkArgument(k <= Integer.MAX_VALUE / 2, "k (%s) must be <= Integer.MAX_VALUE / 2", k);
this.buffer = (T[]) new Object[IntMath.checkedMultiply(k, 2)];
this.bufferSize = 0;
this.threshold = null;
}
/**
* Adds {@code elem} as a candidate for the top {@code k} elements. This operation takes amortized
* O(1) time.
Reported by PMD.
Line: 166
int left = 0;
int right = 2 * k - 1;
int minThresholdPosition = 0;
// The leftmost position at which the greatest of the k lower elements
// -- the new value of threshold -- might be found.
int iterations = 0;
int maxIterations = IntMath.log2(right - left, RoundingMode.CEILING) * 3;
Reported by PMD.
Line: 170
// The leftmost position at which the greatest of the k lower elements
// -- the new value of threshold -- might be found.
int iterations = 0;
int maxIterations = IntMath.log2(right - left, RoundingMode.CEILING) * 3;
while (left < right) {
int pivotIndex = (left + right + 1) >>> 1;
int pivotNewIndex = partition(left, right, pivotIndex);
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/FuturesGetDoneTest.java
13 issues
Line: 31
/** Unit tests for {@link Futures#getDone}. */
@GwtCompatible
public class FuturesGetDoneTest extends TestCase {
public void testSuccessful() throws ExecutionException {
assertThat(getDone(immediateFuture("a"))).isEqualTo("a");
}
public void testSuccessfulNull() throws ExecutionException {
assertThat(getDone(immediateFuture((String) null))).isEqualTo(null);
Reported by PMD.
Line: 32
@GwtCompatible
public class FuturesGetDoneTest extends TestCase {
public void testSuccessful() throws ExecutionException {
assertThat(getDone(immediateFuture("a"))).isEqualTo("a");
}
public void testSuccessfulNull() throws ExecutionException {
assertThat(getDone(immediateFuture((String) null))).isEqualTo(null);
}
Reported by PMD.
Line: 35
assertThat(getDone(immediateFuture("a"))).isEqualTo("a");
}
public void testSuccessfulNull() throws ExecutionException {
assertThat(getDone(immediateFuture((String) null))).isEqualTo(null);
}
public void testFailed() {
Exception failureCause = new Exception();
Reported by PMD.
Line: 39
assertThat(getDone(immediateFuture((String) null))).isEqualTo(null);
}
public void testFailed() {
Exception failureCause = new Exception();
try {
getDone(immediateFailedFuture(failureCause));
fail();
} catch (ExecutionException expected) {
Reported by PMD.
Line: 43
Exception failureCause = new Exception();
try {
getDone(immediateFailedFuture(failureCause));
fail();
} catch (ExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(failureCause);
}
}
Reported by PMD.
Line: 45
getDone(immediateFailedFuture(failureCause));
fail();
} catch (ExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(failureCause);
}
}
public void testCancelled() throws ExecutionException {
try {
Reported by PMD.
Line: 45
getDone(immediateFailedFuture(failureCause));
fail();
} catch (ExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(failureCause);
}
}
public void testCancelled() throws ExecutionException {
try {
Reported by PMD.
Line: 49
}
}
public void testCancelled() throws ExecutionException {
try {
getDone(immediateCancelledFuture());
fail();
} catch (CancellationException expected) {
}
Reported by PMD.
Line: 52
public void testCancelled() throws ExecutionException {
try {
getDone(immediateCancelledFuture());
fail();
} catch (CancellationException expected) {
}
}
public void testPending() throws ExecutionException {
Reported by PMD.
Line: 52
public void testCancelled() throws ExecutionException {
try {
getDone(immediateCancelledFuture());
fail();
} catch (CancellationException expected) {
}
}
public void testPending() throws ExecutionException {
Reported by PMD.
guava/src/com/google/common/escape/UnicodeEscaper.java
13 issues
Line: 160
* @throws NullPointerException if {@code string} is null
* @throws IllegalArgumentException if invalid surrogate characters are encountered
*/
protected final String escapeSlow(String s, int index) {
int end = s.length();
// Get a destination buffer and setup some loop variables.
char[] dest = Platform.charBufferFromThreadLocal();
int destIndex = 0;
Reported by PMD.
Line: 248
* @return the Unicode code point for the given index or the negated value of the trailing high
* surrogate character at the end of the sequence
*/
protected static int codePointAt(CharSequence seq, int index, int end) {
checkNotNull(seq);
if (index < end) {
char c1 = seq.charAt(index++);
if (c1 < Character.MIN_HIGH_SURROGATE || c1 > Character.MAX_LOW_SURROGATE) {
// Fast path (first test is probably all we need to do)
Reported by PMD.
Line: 56
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class UnicodeEscaper extends Escaper {
/** The amount of padding (chars) to use when growing the escape buffer. */
private static final int DEST_PAD = 32;
/** Constructor for use by subclasses. */
protected UnicodeEscaper() {}
Reported by PMD.
Line: 56
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class UnicodeEscaper extends Escaper {
/** The amount of padding (chars) to use when growing the escape buffer. */
private static final int DEST_PAD = 32;
/** Constructor for use by subclasses. */
protected UnicodeEscaper() {}
Reported by PMD.
Line: 160
* @throws NullPointerException if {@code string} is null
* @throws IllegalArgumentException if invalid surrogate characters are encountered
*/
protected final String escapeSlow(String s, int index) {
int end = s.length();
// Get a destination buffer and setup some loop variables.
char[] dest = Platform.charBufferFromThreadLocal();
int destIndex = 0;
Reported by PMD.
Line: 160
* @throws NullPointerException if {@code string} is null
* @throws IllegalArgumentException if invalid surrogate characters are encountered
*/
protected final String escapeSlow(String s, int index) {
int end = s.length();
// Get a destination buffer and setup some loop variables.
char[] dest = Platform.charBufferFromThreadLocal();
int destIndex = 0;
Reported by PMD.
Line: 160
* @throws NullPointerException if {@code string} is null
* @throws IllegalArgumentException if invalid surrogate characters are encountered
*/
protected final String escapeSlow(String s, int index) {
int end = s.length();
// Get a destination buffer and setup some loop variables.
char[] dest = Platform.charBufferFromThreadLocal();
int destIndex = 0;
Reported by PMD.
Line: 248
* @return the Unicode code point for the given index or the negated value of the trailing high
* surrogate character at the end of the sequence
*/
protected static int codePointAt(CharSequence seq, int index, int end) {
checkNotNull(seq);
if (index < end) {
char c1 = seq.charAt(index++);
if (c1 < Character.MIN_HIGH_SURROGATE || c1 > Character.MAX_LOW_SURROGATE) {
// Fast path (first test is probably all we need to do)
Reported by PMD.
Line: 164
int end = s.length();
// Get a destination buffer and setup some loop variables.
char[] dest = Platform.charBufferFromThreadLocal();
int destIndex = 0;
int unescapedChunkStart = 0;
while (index < end) {
int cp = codePointAt(s, index, end);
Reported by PMD.
Line: 165
// Get a destination buffer and setup some loop variables.
char[] dest = Platform.charBufferFromThreadLocal();
int destIndex = 0;
int unescapedChunkStart = 0;
while (index < end) {
int cp = codePointAt(s, index, end);
if (cp < 0) {
Reported by PMD.
guava/src/com/google/common/math/LinearTransformation.java
13 issues
Line: 62
*/
public static final class LinearTransformationBuilder {
private final double x1;
private final double y1;
private LinearTransformationBuilder(double x1, double y1) {
this.x1 = x1;
this.y1 = y1;
Reported by PMD.
Line: 63
public static final class LinearTransformationBuilder {
private final double x1;
private final double y1;
private LinearTransformationBuilder(double x1, double y1) {
this.x1 = x1;
this.y1 = y1;
}
Reported by PMD.
Line: 163
private static final class RegularLinearTransformation extends LinearTransformation {
final double slope;
final double yIntercept;
@CheckForNull @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
Reported by PMD.
Line: 163
private static final class RegularLinearTransformation extends LinearTransformation {
final double slope;
final double yIntercept;
@CheckForNull @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
Reported by PMD.
Line: 164
private static final class RegularLinearTransformation extends LinearTransformation {
final double slope;
final double yIntercept;
@CheckForNull @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
this.slope = slope;
Reported by PMD.
Line: 166
final double slope;
final double yIntercept;
@CheckForNull @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
this.slope = slope;
this.yIntercept = yIntercept;
this.inverse = null; // to be lazily initialized
Reported by PMD.
Line: 166
final double slope;
final double yIntercept;
@CheckForNull @LazyInit LinearTransformation inverse;
RegularLinearTransformation(double slope, double yIntercept) {
this.slope = slope;
this.yIntercept = yIntercept;
this.inverse = null; // to be lazily initialized
Reported by PMD.
Line: 171
RegularLinearTransformation(double slope, double yIntercept) {
this.slope = slope;
this.yIntercept = yIntercept;
this.inverse = null; // to be lazily initialized
}
RegularLinearTransformation(double slope, double yIntercept, LinearTransformation inverse) {
this.slope = slope;
this.yIntercept = yIntercept;
Reported by PMD.
Line: 212
}
private LinearTransformation createInverse() {
if (slope != 0.0) {
return new RegularLinearTransformation(1.0 / slope, -1.0 * yIntercept / slope, this);
} else {
return new VerticalLinearTransformation(yIntercept, this);
}
}
Reported by PMD.
Line: 222
private static final class VerticalLinearTransformation extends LinearTransformation {
final double x;
@CheckForNull @LazyInit LinearTransformation inverse;
VerticalLinearTransformation(double x) {
this.x = x;
Reported by PMD.
guava/src/com/google/common/util/concurrent/TimeoutFuture.java
13 issues
Line: 76
* write-barriers).
*/
@CheckForNull private ListenableFuture<V> delegateRef;
@CheckForNull private ScheduledFuture<?> timer;
private TimeoutFuture(ListenableFuture<V> delegate) {
this.delegateRef = Preconditions.checkNotNull(delegate);
}
Reported by PMD.
Line: 77
*/
@CheckForNull private ListenableFuture<V> delegateRef;
@CheckForNull private ScheduledFuture<?> timer;
private TimeoutFuture(ListenableFuture<V> delegate) {
this.delegateRef = Preconditions.checkNotNull(delegate);
}
Reported by PMD.
Line: 85
/** A runnable that is called when the delegate or the timer completes. */
private static final class Fire<V extends @Nullable Object> implements Runnable {
@CheckForNull TimeoutFuture<V> timeoutFutureRef;
Fire(TimeoutFuture<V> timeoutFuture) {
this.timeoutFutureRef = timeoutFuture;
}
Reported by PMD.
Line: 116
* important for other reasons: run() can still be invoked concurrently in different threads,
* even with the above null checks.)
*/
timeoutFutureRef = null;
if (delegate.isDone()) {
timeoutFuture.setFuture(delegate);
} else {
try {
ScheduledFuture<?> timer = timeoutFuture.timer;
Reported by PMD.
Line: 117
* even with the above null checks.)
*/
timeoutFutureRef = null;
if (delegate.isDone()) {
timeoutFuture.setFuture(delegate);
} else {
try {
ScheduledFuture<?> timer = timeoutFuture.timer;
timeoutFuture.timer = null; // Don't include already elapsed delay in delegate.toString()
Reported by PMD.
Line: 122
} else {
try {
ScheduledFuture<?> timer = timeoutFuture.timer;
timeoutFuture.timer = null; // Don't include already elapsed delay in delegate.toString()
String message = "Timed out";
// This try-finally block ensures that we complete the timeout future, even if attempting
// to produce the message throws (probably StackOverflowError from delegate.toString())
try {
if (timer != null) {
Reported by PMD.
Line: 128
// to produce the message throws (probably StackOverflowError from delegate.toString())
try {
if (timer != null) {
long overDelayMs = Math.abs(timer.getDelay(TimeUnit.MILLISECONDS));
if (overDelayMs > 10) { // Not all timing drift is worth reporting
message += " (timeout delayed by " + overDelayMs + " ms after scheduled time)";
}
}
message += ": " + delegate;
Reported by PMD.
Line: 129
try {
if (timer != null) {
long overDelayMs = Math.abs(timer.getDelay(TimeUnit.MILLISECONDS));
if (overDelayMs > 10) { // Not all timing drift is worth reporting
message += " (timeout delayed by " + overDelayMs + " ms after scheduled time)";
}
}
message += ": " + delegate;
} finally {
Reported by PMD.
Line: 133
message += " (timeout delayed by " + overDelayMs + " ms after scheduled time)";
}
}
message += ": " + delegate;
} finally {
timeoutFuture.setException(new TimeoutFutureException(message));
}
} finally {
delegate.cancel(true);
Reported by PMD.
Line: 144
}
}
private static final class TimeoutFutureException extends TimeoutException {
private TimeoutFutureException(String message) {
super(message);
}
@Override
Reported by PMD.
guava/src/com/google/common/io/CharStreams.java
13 issues
Line: 265
* @throws IOException if an I/O error occurs
*/
@Beta
public static void skipFully(Reader reader, long n) throws IOException {
checkNotNull(reader);
while (n > 0) {
long amt = reader.skip(n);
if (amt == 0) {
throw new EOFException();
Reported by PMD.
Line: 50
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class CharStreams {
// 2K chars (4K bytes)
private static final int DEFAULT_BUF_SIZE = 0x800;
/** Creates a new {@code CharBuffer} for buffering reads or writes. */
Reported by PMD.
Line: 122
char[] buf = new char[DEFAULT_BUF_SIZE];
int nRead;
long total = 0;
while ((nRead = from.read(buf)) != -1) {
to.append(buf, 0, nRead);
total += nRead;
}
return total;
}
Reported by PMD.
Line: 150
char[] buf = new char[DEFAULT_BUF_SIZE];
int nRead;
long total = 0;
while ((nRead = from.read(buf)) != -1) {
to.write(buf, 0, nRead);
total += nRead;
}
return total;
}
Reported by PMD.
Line: 203
List<String> result = new ArrayList<>();
LineReader lineReader = new LineReader(r);
String line;
while ((line = lineReader.readLine()) != null) {
result.add(line);
}
return result;
}
Reported by PMD.
Line: 228
LineReader lineReader = new LineReader(readable);
String line;
while ((line = lineReader.readLine()) != null) {
if (!processor.processLine(line)) {
break;
}
}
return processor.getResult();
Reported by PMD.
Line: 248
long total = 0;
long read;
CharBuffer buf = createBuffer();
while ((read = readable.read(buf)) != -1) {
total += read;
Java8Compatibility.clear(buf);
}
return total;
}
Reported by PMD.
Line: 286
return NullWriter.INSTANCE;
}
private static final class NullWriter extends Writer {
private static final NullWriter INSTANCE = new NullWriter();
@Override
public void write(int c) {}
Reported by PMD.
Line: 122
char[] buf = new char[DEFAULT_BUF_SIZE];
int nRead;
long total = 0;
while ((nRead = from.read(buf)) != -1) {
to.append(buf, 0, nRead);
total += nRead;
}
return total;
}
Reported by PMD.
Line: 150
char[] buf = new char[DEFAULT_BUF_SIZE];
int nRead;
long total = 0;
while ((nRead = from.read(buf)) != -1) {
to.write(buf, 0, nRead);
total += nRead;
}
return total;
}
Reported by PMD.