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-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new e299a18  Make final var when is possible. (#816)
e299a18 is described below

commit e299a185d42cd1b33ab21123f85de117a68c3d49
Author: Arturo Bernal <arturobern...@gmail.com>
AuthorDate: Wed Nov 17 14:31:50 2021 +0100

    Make final var when is possible. (#816)
---
 pom.xml                                            |  3 +
 .../java/org/apache/commons/lang3/ArrayUtils.java  |  2 +-
 .../apache/commons/lang3/reflect/MethodUtils.java  |  2 +-
 .../apache/commons/lang3/reflect/TypeUtils.java    |  2 +-
 .../org/apache/commons/lang3/time/DateUtils.java   |  4 +-
 .../apache/commons/lang3/ArrayUtilsAddTest.java    |  2 +-
 .../org/apache/commons/lang3/StringUtilsTest.java  | 24 ++++----
 .../apache/commons/lang3/math/FractionTest.java    |  4 +-
 .../commons/lang3/reflect/TypeUtilsTest.java       |  2 +-
 .../commons/lang3/time/DateUtilsRoundingTest.java  | 67 ++++++++++++++++------
 10 files changed, 72 insertions(+), 40 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1a44fc7..60e2cff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -517,6 +517,9 @@
     <contributor>
       <name>Jin Xu</name>
     </contributor>
+    <contributor>
+      <name>Arturo Bernal</name>
+    </contributor>
   </contributors>
 
   <dependencyManagement>
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java 
b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index c97e2e2..7f835bd 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -764,7 +764,7 @@ public class ArrayUtils {
      */
     @Deprecated
     public static <T> T[] add(final T[] array, final int index, final T 
element) {
-        Class<T> clss;
+        final Class<T> clss;
         if (array != null) {
             clss = getComponentType(array);
         } else if (element != null) {
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java 
b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 90d1d6a..31cec04 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -208,7 +208,7 @@ public class MethodUtils {
         args = ArrayUtils.nullToEmpty(args);
 
         final String messagePrefix;
-        Method method;
+        final Method method;
 
         if (forceAccess) {
             messagePrefix = "No such method: ";
diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java 
b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
index c887b8a..bb35fa2 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
@@ -630,7 +630,7 @@ public class TypeUtils {
 
             // find the interface closest to the super class
             for (final Type midType : interfaceTypes) {
-                Class<?> midClass;
+                final Class<?> midClass;
 
                 if (midType instanceof ParameterizedType) {
                     midClass = getRawType((ParameterizedType) midType);
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java 
b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index 028851a..13eec34 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -1129,8 +1129,8 @@ public class DateUtils {
         if (focus == null) {
             throw nullDateIllegalArgumentException();
         }
-        Calendar start;
-        Calendar end;
+        final Calendar start;
+        final Calendar end;
         int startCutoff = Calendar.SUNDAY;
         int endCutoff = Calendar.SATURDAY;
         switch (rangeStyle) {
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java 
b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
index 60dc090..a2653ef 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
@@ -653,7 +653,7 @@ public class ArrayUtilsAddTest {
 
     @Test
     public void testJira567() {
-        Number[] n;
+        final Number[] n;
         // Valid array construction
         n = ArrayUtils.addAll(new Number[]{Integer.valueOf(1)}, new 
Long[]{Long.valueOf(2)});
         assertEquals(2, n.length);
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index e501982..6d3e0db 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -2760,7 +2760,7 @@ public class StringUtilsTest {
 
         // Match example in javadoc
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"a", "", "b", "c"};
             results = StringUtils.splitPreserveAllTokens("a..b.c", '.');
             assertEquals(expectedResults.length, results.length);
@@ -2789,7 +2789,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "de fg"};
             results = StringUtils.splitPreserveAllTokens("ab de fg", null, 2);
             assertEquals(expectedResults.length, results.length);
@@ -2799,7 +2799,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "  de fg"};
             results = StringUtils.splitPreserveAllTokens("ab   de fg", null, 
2);
             assertEquals(expectedResults.length, results.length);
@@ -2809,7 +2809,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "::de:fg"};
             results = StringUtils.splitPreserveAllTokens("ab:::de:fg", ":", 2);
             assertEquals(expectedResults.length, results.length);
@@ -2819,7 +2819,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "", " de fg"};
             results = StringUtils.splitPreserveAllTokens("ab   de fg", null, 
3);
             assertEquals(expectedResults.length, results.length);
@@ -2829,7 +2829,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "", "", "de fg"};
             results = StringUtils.splitPreserveAllTokens("ab   de fg", null, 
4);
             assertEquals(expectedResults.length, results.length);
@@ -2840,7 +2840,7 @@ public class StringUtilsTest {
 
         {
             final String[] expectedResults = {"ab", "cd:ef"};
-            String[] results;
+            final String[] results;
             results = StringUtils.splitPreserveAllTokens("ab:cd:ef", ":", 2);
             assertEquals(expectedResults.length, results.length);
             for (int i = 0; i < expectedResults.length; i++) {
@@ -2849,7 +2849,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", ":cd:ef"};
             results = StringUtils.splitPreserveAllTokens("ab::cd:ef", ":", 2);
             assertEquals(expectedResults.length, results.length);
@@ -2859,7 +2859,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "", ":cd:ef"};
             results = StringUtils.splitPreserveAllTokens("ab:::cd:ef", ":", 3);
             assertEquals(expectedResults.length, results.length);
@@ -2869,7 +2869,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"ab", "", "", "cd:ef"};
             results = StringUtils.splitPreserveAllTokens("ab:::cd:ef", ":", 4);
             assertEquals(expectedResults.length, results.length);
@@ -2879,7 +2879,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"", "ab", "", "", "cd:ef"};
             results = StringUtils.splitPreserveAllTokens(":ab:::cd:ef", ":", 
5);
             assertEquals(expectedResults.length, results.length);
@@ -2889,7 +2889,7 @@ public class StringUtilsTest {
         }
 
         {
-            String[] results;
+            final String[] results;
             final String[] expectedResults = {"", "", "ab", "", "", "cd:ef"};
             results = StringUtils.splitPreserveAllTokens("::ab:::cd:ef", ":", 
6);
             assertEquals(expectedResults.length, results.length);
diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java 
b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
index 7ede98c..a496ecf 100644
--- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
@@ -164,7 +164,7 @@ public class FractionTest  {
 
     @Test
     public void testCompareTo() {
-        Fraction f1;
+        final Fraction f1;
         Fraction f2;
 
         f1 = Fraction.getFraction(3, 5);
@@ -237,7 +237,7 @@ public class FractionTest  {
 
     @Test
     public void testConversions() {
-        Fraction f;
+        final Fraction f;
 
         f = Fraction.getFraction(3, 7, 8);
         assertEquals(3, f.intValue());
diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
index ce2fbbc..60fe209 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
@@ -750,7 +750,7 @@ public class TypeUtilsTest<B> {
         // int[] ina = ia;
         assertFalse(TypeUtils.isAssignable(Integer[].class, int[].class));
         final int[] ina = null;
-        Object[] oa;
+        final Object[] oa;
         // oa = ina;
         assertFalse(TypeUtils.isAssignable(int[].class, Object[].class));
         oa = new Integer[0];
diff --git 
a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java 
b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
index e12d58d..1089da9 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
@@ -80,7 +80,10 @@ public class DateUtilsRoundingTest {
         assertEquals(roundedUpDate, DateUtils.round(firstRoundUpDate, 
calendarField));
 
         //Calendar-initiations
-        Calendar roundedUpCalendar, roundedDownCalendar, 
lastRoundDownCalendar, firstRoundUpCalendar;
+        final Calendar roundedUpCalendar;
+        Calendar roundedDownCalendar;
+        Calendar lastRoundDownCalendar;
+        final Calendar firstRoundUpCalendar;
         roundedDownCalendar = Calendar.getInstance();
         roundedUpCalendar = Calendar.getInstance();
         lastRoundDownCalendar = Calendar.getInstance();
@@ -127,7 +130,9 @@ public class DateUtilsRoundingTest {
         assertNotEquals(truncatedDate, DateUtils.truncate(nextTruncateDate, 
calendarField), fdf.format(lastTruncateDate) + " is not an extreme when 
truncating as Date with CalendarField-value " + calendarField);
 
         //Calendar-initiations
-        Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar;
+        final Calendar truncatedCalendar;
+        Calendar lastTruncateCalendar;
+        final Calendar nextTruncateCalendar;
         truncatedCalendar = Calendar.getInstance();
         lastTruncateCalendar = Calendar.getInstance();
         nextTruncateCalendar = Calendar.getInstance();
@@ -217,7 +222,8 @@ public class DateUtilsRoundingTest {
     public void testRoundAmPm() throws Exception {
         final int calendarField = Calendar.AM_PM;
         Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date minDate;
+        final Date maxDate;
 
         //AM
         roundedUpDate = dateTimeParser.parse("June 1, 2008 12:00:00.000");
@@ -248,8 +254,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundDate() throws Exception {
         final int calendarField = Calendar.DATE;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedUpDate = dateTimeParser.parse("June 2, 2008 0:00:00.000");
         roundedDownDate = targetDateDate;
@@ -273,8 +282,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundDayOfMonth() throws Exception {
         final int calendarField = Calendar.DAY_OF_MONTH;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        final Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedUpDate = dateTimeParser.parse("June 2, 2008 0:00:00.000");
         roundedDownDate = targetDayOfMonthDate;
@@ -298,8 +310,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundHour() throws Exception {
         final int calendarField = Calendar.HOUR;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        final Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedUpDate = dateTimeParser.parse("June 1, 2008 9:00:00.000");
         roundedDownDate = targetHourDate;
@@ -323,8 +338,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundHourOfDay() throws Exception {
         final int calendarField = Calendar.HOUR_OF_DAY;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        final Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedUpDate = dateTimeParser.parse("June 1, 2008 9:00:00.000");
         roundedDownDate = targetHourOfDayDate;
@@ -348,8 +366,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundMilliSecond() throws Exception {
         final int calendarField = Calendar.MILLISECOND;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        final Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedDownDate = lastRoundedDownDate = targetMilliSecondDate;
         roundedUpDate = dateTimeParser.parse("June 1, 2008 8:15:14.232");
@@ -371,8 +392,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundMinute() throws Exception {
         final int calendarField = Calendar.MINUTE;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        final Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedUpDate = dateTimeParser.parse("June 1, 2008 8:16:00.000");
         roundedDownDate = targetMinuteDate;
@@ -397,7 +421,8 @@ public class DateUtilsRoundingTest {
     public void testRoundMonth() throws Exception {
         final int calendarField = Calendar.MONTH;
         Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date minDate;
+        final Date maxDate;
 
         //month with 28 days
         roundedUpDate = dateTimeParser.parse("March 1, 2007 0:00:00.000");
@@ -440,8 +465,11 @@ public class DateUtilsRoundingTest {
     @Test
     public void testRoundSecond() throws Exception {
         final int calendarField = Calendar.SECOND;
-        Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date roundedUpDate;
+        final Date roundedDownDate;
+        final Date lastRoundedDownDate;
+        final Date minDate;
+        final Date maxDate;
 
         roundedUpDate = dateTimeParser.parse("June 1, 2008 8:15:15.000");
         roundedDownDate = targetSecondDate;
@@ -466,7 +494,8 @@ public class DateUtilsRoundingTest {
     public void testRoundSemiMonth() throws Exception {
         final int calendarField = DateUtils.SEMI_MONTH;
         Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
-        Date minDate, maxDate;
+        final Date minDate;
+        final Date maxDate;
 
         //month with 28 days (1)
         roundedUpDate = dateTimeParser.parse("February 16, 2007 0:00:00.000");

Reply via email to