You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/06 16:32:18 UTC

[commons-collections] branch master updated (8e300bdec -> e84ff4dff)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git


    from 8e300bdec PMD: Use direct access
     new 17db5ba53 Simplify ignorance of caught exception
     new 5848c936b PMD: Use direct access
     new e84ff4dff PMD: No need to nest

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/collections4/IteratorUtils.java     |  4 +---
 .../apache/commons/collections4/bloomfilter/Hasher.java    |  2 +-
 .../commons/collections4/bloomfilter/IndexFilter.java      |  2 +-
 .../commons/collections4/bloomfilter/IndexProducer.java    |  6 ++----
 .../commons/collections4/list/AbstractLinkedList.java      |  6 +++---
 .../commons/collections4/map/AbstractReferenceMap.java     |  5 ++---
 .../commons/collections4/properties/PropertiesFactory.java | 14 --------------
 7 files changed, 10 insertions(+), 29 deletions(-)


[commons-collections] 02/03: PMD: Use direct access

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 5848c936b7ddc4a85e2a171ddf350e3adb933ada
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 6 11:16:28 2022 -0500

    PMD: Use direct access
---
 .../java/org/apache/commons/collections4/bloomfilter/Hasher.java    | 2 +-
 .../org/apache/commons/collections4/list/AbstractLinkedList.java    | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/Hasher.java b/src/main/java/org/apache/commons/collections4/bloomfilter/Hasher.java
index f6cec587a..d8b3a43aa 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/Hasher.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/Hasher.java
@@ -58,7 +58,7 @@ public interface Hasher {
     default IndexProducer uniqueIndices(final Shape shape) {
         return consumer -> {
             Objects.requireNonNull(consumer, "consumer");
-            return Hasher.this.indices(shape).forEachIndex(IndexFilter.create(shape, consumer));
+            return indices(shape).forEachIndex(IndexFilter.create(shape, consumer));
         };
     }
 }
diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java
index f27650335..4125451ea 100644
--- a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java
+++ b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java
@@ -994,7 +994,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
             parent.add(index + offset, obj);
             expectedModCount = parent.modCount;
             size++;
-            LinkedSubList.this.modCount++;
+            modCount++;
         }
 
         @Override
@@ -1004,7 +1004,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
             final E result = parent.remove(index + offset);
             expectedModCount = parent.modCount;
             size--;
-            LinkedSubList.this.modCount++;
+            modCount++;
             return result;
         }
 
@@ -1025,7 +1025,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
             parent.addAll(offset + index, coll);
             expectedModCount = parent.modCount;
             size += cSize;
-            LinkedSubList.this.modCount++;
+            modCount++;
             return true;
         }
 


[commons-collections] 03/03: PMD: No need to nest

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit e84ff4dff079d843f0aa710afe298091ab9adfa9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 6 11:32:13 2022 -0500

    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
---
 .../org/apache/commons/collections4/IteratorUtils.java     |  1 -
 .../commons/collections4/bloomfilter/IndexFilter.java      |  2 +-
 .../commons/collections4/bloomfilter/IndexProducer.java    |  6 ++----
 .../commons/collections4/map/AbstractReferenceMap.java     |  5 ++---
 .../commons/collections4/properties/PropertiesFactory.java | 14 --------------
 5 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
index 625054b4f..42c9a49f2 100644
--- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java
+++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
@@ -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;
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java
index f589a0cc7..c7e6ca186 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java
@@ -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);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/IndexProducer.java b/src/main/java/org/apache/commons/collections4/bloomfilter/IndexProducer.java
index 8668b81fe..dbaf0908c 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/IndexProducer.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/IndexProducer.java
@@ -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++;
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
index ac59468f7..295ef67c9 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
@@ -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
         }
     }
 
diff --git a/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java b/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java
index 965989a3b..fa7d1a71f 100644
--- a/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java
+++ b/src/main/java/org/apache/commons/collections4/properties/PropertiesFactory.java
@@ -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.


[commons-collections] 01/03: Simplify ignorance of caught exception

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 17db5ba533474e2ca8e52d9ef9fe867cbaab06ae
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 6 11:13:29 2022 -0500

    Simplify ignorance of caught exception
---
 src/main/java/org/apache/commons/collections4/IteratorUtils.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
index 7e30f4240..625054b4f 100644
--- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java
+++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
@@ -1113,8 +1113,7 @@ public class IteratorUtils {
                     return it;
                 }
             }
-        } catch (final RuntimeException | NoSuchMethodException | IllegalAccessException |
-            InvocationTargetException e) { // NOPMD
+        } catch (final RuntimeException | ReflectiveOperationException ignore) { // NOPMD
             // ignore
         }
         return singletonIterator(obj);