Fix two PMD issues, but comment others where if's were added for readability

This commit is contained in:
Bruno P. Kinoshita 2017-09-13 00:44:46 +12:00
parent 55e8eac25d
commit 9ae946c7da
9 changed files with 16 additions and 21 deletions

View File

@ -193,12 +193,12 @@ public class PrototypeFactory {
if (bais != null) { if (bais != null) {
bais.close(); bais.close();
} }
} catch (final IOException ex) { } catch (final IOException ex) { //NOPMD
// ignore // ignore
} }
try { try {
baos.close(); baos.close();
} catch (final IOException ex) { } catch (final IOException ex) { //NOPMD
// ignore // ignore
} }
} }

View File

@ -96,10 +96,8 @@ public class FilterIterator<E> implements Iterator<E> {
*/ */
@Override @Override
public E next() { public E next() {
if (!nextObjectSet) { if (!nextObjectSet && !setNextObject()) {
if (!setNextObject()) { throw new NoSuchElementException();
throw new NoSuchElementException();
}
} }
nextObjectSet = false; nextObjectSet = false;
return nextObject; return nextObject;

View File

@ -132,10 +132,8 @@ public class FilterListIterator<E> implements ListIterator<E> {
@Override @Override
public E next() { public E next() {
if (!nextObjectSet) { if (!nextObjectSet && !setNextObject()) {
if (!setNextObject()) { throw new NoSuchElementException();
throw new NoSuchElementException();
}
} }
nextIndex++; nextIndex++;
final E temp = nextObject; final E temp = nextObject;
@ -150,10 +148,8 @@ public class FilterListIterator<E> implements ListIterator<E> {
@Override @Override
public E previous() { public E previous() {
if (!previousObjectSet) { if (!previousObjectSet && !setPreviousObject()) {
if (!setPreviousObject()) { throw new NoSuchElementException();
throw new NoSuchElementException();
}
} }
nextIndex--; nextIndex--;
final E temp = previousObject; final E temp = previousObject;

View File

@ -116,7 +116,7 @@ public class PermutationIterator<E> implements Iterator<List<E>> {
for (int i = 0; i < keys.length; i++) { for (int i = 0; i < keys.length; i++) {
if ((direction[i] && i < keys.length - 1 && keys[i] > keys[i + 1]) || if ((direction[i] && i < keys.length - 1 && keys[i] > keys[i + 1]) ||
(!direction[i] && i > 0 && keys[i] > keys[i - 1])) { (!direction[i] && i > 0 && keys[i] > keys[i - 1])) {
if (keys[i] > largestKey) { if (keys[i] > largestKey) { // NOPMD
largestKey = keys[i]; largestKey = keys[i];
indexOfLargestMobileInteger = i; indexOfLargestMobileInteger = i;
} }

View File

@ -48,7 +48,7 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
* @return the previous value * @return the previous value
*/ */
@Override @Override
public V setValue(final V value) { public V setValue(final V value) { // NOPMD
return super.setValue(value); return super.setValue(value);
} }

View File

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

View File

@ -309,7 +309,7 @@ public class MultiValueMap<K, V> extends AbstractMapDecorator<K, Object> impleme
* @see #iterator() * @see #iterator()
*/ */
@Override @Override
public Set<Entry<K, Object>> entrySet() { public Set<Entry<K, Object>> entrySet() { // NOPMD
return super.entrySet(); return super.entrySet();
} }

View File

@ -201,7 +201,7 @@ public class SequencesComparator<T> {
} }
// Second step // Second step
if (delta % 2 != 0 && delta - d <= k && k <= delta + d) { if (delta % 2 != 0 && delta - d <= k && k <= delta + d) {
if (vUp[i-delta] <= vDown[i]) { if (vUp[i-delta] <= vDown[i]) { // NOPMD
return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2); return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2);
} }
} }
@ -227,7 +227,7 @@ public class SequencesComparator<T> {
} }
// Second step // Second step
if (delta % 2 == 0 && -d <= k && k <= d ) { if (delta % 2 == 0 && -d <= k && k <= d ) {
if (vUp[i] <= vDown[i + delta]) { if (vUp[i] <= vDown[i + delta]) { // NOPMD
return buildSnake(vUp[i], k + start1 - start2, end1, end2); return buildSnake(vUp[i], k + start1 - start2, end1, end2);
} }
} }

View File

@ -177,7 +177,7 @@ abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K, V> {
// This is a very special and rare case. // This is a very special and rare case.
/* REPLACE OLD KEY+VALUE */ /* REPLACE OLD KEY+VALUE */
if (found != root) { if (found != root) { // NOPMD
incrementModCount(); incrementModCount();
return found.setKeyValue(key, value); return found.setKeyValue(key, value);
} }