PMD: No need to nest

- PMD: No need to just call super
- PMD: Simplify ternary expression to expression
- PMD: Ignore empty loop warning
- Fix import
This commit is contained in:
Gary Gregory 2022-11-06 11:32:13 -05:00
parent 5848c936b7
commit e84ff4dff0
5 changed files with 5 additions and 23 deletions

View File

@ -17,7 +17,6 @@
package org.apache.commons.collections4;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;

View File

@ -72,7 +72,7 @@ public final class IndexFilter {
if (number >= size) {
throw new IndexOutOfBoundsException(String.format("number too large %d >= %d", number, size));
}
return tracker.test(number) ? consumer.test(number) : true;
return !tracker.test(number) || consumer.test(number);
}
/**

View File

@ -87,10 +87,8 @@ public interface IndexProducer {
public boolean test(long word) {
int i = wordIdx;
while (word != 0) {
if ((word & 1) == 1) {
if (!consumer.test(i)) {
return false;
}
if ((word & 1) == 1 && !consumer.test(i)) {
return false;
}
word >>>= 1;
i++;

View File

@ -294,9 +294,8 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
@Override
public void clear() {
super.clear();
// drain the queue
while (queue.poll() != null) {
// empty
// Drain the queue
while (queue.poll() != null) { // NOPMD
}
}

View File

@ -20,8 +20,6 @@ package org.apache.commons.collections4.properties;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.Collection;
@ -150,18 +148,6 @@ public class PropertiesFactory extends AbstractPropertiesFactory<Properties> {
return Collections.emptySet();
}
@Override
public void list(final PrintStream out) {
// Implement as super
super.list(out);
}
@Override
public void list(final PrintWriter out) {
// Implement as super
super.list(out);
}
/**
* Throws {@link UnsupportedOperationException}.
* Caller should use try-with-resources statement.