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 4bb493225b409c4018696790b9beb510df15d7b0 Author: Gary D. Gregory <[email protected]> AuthorDate: Sun Feb 9 18:23:03 2025 -0500 Add Checkstyle MultipleVariableDeclarations --- src/conf/checkstyle.xml | 1 + .../org/apache/commons/collections4/map/AbstractReferenceMap.java | 6 ++++-- .../commons/collections4/trie/analyzer/StringKeyAnalyzer.java | 3 ++- src/test/java/org/apache/commons/collections4/MapPerformance.java | 3 ++- .../java/org/apache/commons/collections4/bag/AbstractBagTest.java | 8 ++++++-- .../commons/collections4/list/NodeCachingLinkedListTest.java | 6 ++---- .../commons/collections4/multiset/AbstractMultiSetTest.java | 8 ++++++-- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml index 4b56aa203..e5603d667 100644 --- a/src/conf/checkstyle.xml +++ b/src/conf/checkstyle.xml @@ -75,6 +75,7 @@ limitations under the License. <module name="LeftCurly"/> <module name="MethodParamPad"/> <module name="ModifierOrder"/> + <module name="MultipleVariableDeclarations" /> <module name="NeedBraces"/> <module name="NoWhitespaceBefore"/> <module name="NoWhitespaceBeforeCaseDefaultColon"/> 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 46f713509..913f42a75 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java @@ -105,8 +105,10 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V> // These Object fields provide hard references to the // current and next entry; this assures that if hasNext() // returns true, next() will actually return a valid element. - K currentKey, nextKey; - V currentValue, nextValue; + K currentKey; + K nextKey; + V currentValue; + V nextValue; int expectedModCount; diff --git a/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java b/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java index 5c5685c91..c74082c9a 100644 --- a/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java +++ b/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java @@ -75,7 +75,8 @@ public class StringKeyAnalyzer extends KeyAnalyzer<String> { // Look at each character, and if they're different // then figure out which bit makes the difference // and return it. - char k = 0, f = 0; + char k = 0; + char f = 0; for (int i = 0; i < length; i++) { final int index1 = beginIndex1 + i; final int index2 = beginIndex2 + i; diff --git a/src/test/java/org/apache/commons/collections4/MapPerformance.java b/src/test/java/org/apache/commons/collections4/MapPerformance.java index 73dd11267..33beec43d 100644 --- a/src/test/java/org/apache/commons/collections4/MapPerformance.java +++ b/src/test/java/org/apache/commons/collections4/MapPerformance.java @@ -88,7 +88,8 @@ public class MapPerformance { } private static void test(final Map<String, String> map, final String name) { - long startMillis = 0, endMillis = 0; + long startMillis = 0; + long endMillis = 0; // int total = 0; startMillis = System.currentTimeMillis(); for (int i = RUNS; i > 0; i--) { diff --git a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java index 8b0445090..ab22afef1 100644 --- a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java @@ -641,7 +641,9 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> { bag.add((T) "B"); bag.add((T) "C"); final Object[] array = bag.toArray(); - int a = 0, b = 0, c = 0; + int a = 0; + int b = 0; + int c = 0; for (final Object element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; @@ -666,7 +668,9 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> { bag.add((T) "B"); bag.add((T) "C"); final String[] array = bag.toArray(ArrayUtils.EMPTY_STRING_ARRAY); - int a = 0, b = 0, c = 0; + int a = 0; + int b = 0; + int c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; diff --git a/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java b/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java index 5f58416a2..6e027f9ff 100644 --- a/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java @@ -35,11 +35,9 @@ public class NodeCachingLinkedListTest<E> extends AbstractLinkedListTest<E> { final int loopCount = 4000000; - long startTime, endTime; - System.out.println("Testing relative execution time of commonly-used methods..."); - startTime = System.currentTimeMillis(); + long startTime = System.currentTimeMillis(); for (int x = loopCount; x > 0; x--) { // unrolled a few times to minimize effect of loop ll.addFirst(o1); @@ -63,7 +61,7 @@ public class NodeCachingLinkedListTest<E> extends AbstractLinkedListTest<E> { ll.add(o1); ll.remove(0); } - endTime = System.currentTimeMillis(); + long endTime = System.currentTimeMillis(); System.out.println("Time with LinkedList: " + (endTime - startTime) + " ms"); startTime = System.currentTimeMillis(); diff --git a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java index fbd897711..0f82c5924 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java @@ -675,7 +675,9 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T> multiset.add((T) "B"); multiset.add((T) "C"); final Object[] array = multiset.toArray(); - int a = 0, b = 0, c = 0; + int a = 0; + int b = 0; + int c = 0; for (final Object element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; @@ -700,7 +702,9 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T> multiset.add((T) "B"); multiset.add((T) "C"); final String[] array = multiset.toArray(ArrayUtils.EMPTY_STRING_ARRAY); - int a = 0, b = 0, c = 0; + int a = 0; + int b = 0; + int c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0;
