diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index 95bf83964..5cf8b67b8 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -7041,18 +7041,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7116,18 +7116,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7191,18 +7191,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7266,18 +7266,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7341,18 +7341,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7416,18 +7416,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7491,18 +7491,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7566,18 +7566,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } @@ -7641,18 +7641,18 @@ public class ArrayUtils { // For algorithm explanations and proof of O(n) time complexity and O(1) space complexity // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { - final int n_offset = n - offset; + final int nOffset = n - offset; - if (offset > n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); + if (offset > nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + n - nOffset, nOffset); n = offset; - offset -= n_offset; - } else if (offset < n_offset) { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + offset -= nOffset; + } else if (offset < nOffset) { + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); startIndexInclusive += offset; - n = n_offset; + n = nOffset; } else { - swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset); + swap(array, startIndexInclusive, startIndexInclusive + nOffset, offset); break; } } diff --git a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java index 39782f1e2..e182d7ee8 100644 --- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java +++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java @@ -214,13 +214,13 @@ public class RandomStringUtils { throw new IllegalArgumentException("Parameter end (" + end + ") must be greater than start (" + start + ")"); } - final int zero_digit_ascii = 48; - final int first_letter_ascii = 65; + final int zeroDigitAscii = 48; + final int firstLetterAscii = 65; - if (chars == null && (numbers && end <= zero_digit_ascii - || letters && end <= first_letter_ascii)) { - throw new IllegalArgumentException("Parameter end (" + end + ") must be greater then (" + zero_digit_ascii + ") for generating digits " + - "or greater then (" + first_letter_ascii + ") for generating letters."); + if (chars == null && (numbers && end <= zeroDigitAscii + || letters && end <= firstLetterAscii)) { + throw new IllegalArgumentException("Parameter end (" + end + ") must be greater then (" + zeroDigitAscii + ") for generating digits " + + "or greater then (" + firstLetterAscii + ") for generating letters."); } final StringBuilder builder = new StringBuilder(count); diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 9f2b18f50..4761be041 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -2350,10 +2350,10 @@ public class StringUtils { // indexes into strings s and t int i; // iterates through s int j; // iterates through t - int upper_left; + int upperleft; int upper; - char t_j; // jth character of t + char jOfT; // jth character of t int cost; for (i = 0; i <= n; i++) { @@ -2361,16 +2361,16 @@ public class StringUtils { } for (j = 1; j <= m; j++) { - upper_left = p[0]; - t_j = t.charAt(j - 1); + upperleft = p[0]; + jOfT = t.charAt(j - 1); p[0] = j; for (i = 1; i <= n; i++) { upper = p[i]; - cost = s.charAt(i - 1) == t_j ? 0 : 1; + cost = s.charAt(i - 1) == jOfT ? 0 : 1; // minimum of cell to the left+1, to the top+1, diagonally left and up +cost - p[i] = Math.min(Math.min(p[i - 1] + 1, p[i] + 1), upper_left + cost); - upper_left = upper; + p[i] = Math.min(Math.min(p[i - 1] + 1, p[i] + 1), upperleft + cost); + upperleft = upper; } } @@ -2505,7 +2505,7 @@ public class StringUtils { // iterates through t for (int j = 1; j <= m; j++) { - final char t_j = t.charAt(j - 1); // jth character of t + final char jOfT = t.charAt(j - 1); // jth character of t d[0] = j; // compute stripe indices, constrain to array size @@ -2524,7 +2524,7 @@ public class StringUtils { // iterates through [min, max] in s for (int i = min; i <= max; i++) { - if (s.charAt(i - 1) == t_j) { + if (s.charAt(i - 1) == jOfT) { // diagonally left and up d[i] = p[i - 1]; } else { diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java index eed05f414..d03f453e2 100644 --- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -437,14 +437,14 @@ public class EqualsBuilderTest extends AbstractLangTest { @Test public void testObjectRecursiveGenericInteger() { - final TestRecursiveGenericObject o1_a = new TestRecursiveGenericObject<>(1); - final TestRecursiveGenericObject o1_b = new TestRecursiveGenericObject<>(1); + final TestRecursiveGenericObject o1A = new TestRecursiveGenericObject<>(1); + final TestRecursiveGenericObject o1B = new TestRecursiveGenericObject<>(1); final TestRecursiveGenericObject o2 = new TestRecursiveGenericObject<>(2); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_b, o1_a).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1B).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1B, o1A).isEquals()); - assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_b, o2).isEquals()); + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1B, o2).isEquals()); } @Test @@ -458,18 +458,18 @@ public class EqualsBuilderTest extends AbstractLangTest { @Test public void testObjectRecursiveGenericString() { // Note: Do not use literals, because string literals are always mapped by same object (internal() of String))! - final String s1_a = String.valueOf(1); - final TestRecursiveGenericObject o1_a = new TestRecursiveGenericObject<>(s1_a); - final TestRecursiveGenericObject o1_b = new TestRecursiveGenericObject<>(String.valueOf(1)); + final String s1A = String.valueOf(1); + final TestRecursiveGenericObject o1A = new TestRecursiveGenericObject<>(s1A); + final TestRecursiveGenericObject o1B = new TestRecursiveGenericObject<>(String.valueOf(1)); final TestRecursiveGenericObject o2 = new TestRecursiveGenericObject<>(String.valueOf(2)); // To trigger bug reported in LANG-1356, call hashCode only on string in instance o1_a - s1_a.hashCode(); + s1A.hashCode(); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_b, o1_a).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1B).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1B, o1A).isEquals()); - assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_b, o2).isEquals()); + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1B, o2).isEquals()); } @Test @@ -481,51 +481,51 @@ public class EqualsBuilderTest extends AbstractLangTest { final TestRecursiveInnerObject i3 = new TestRecursiveInnerObject(3); final TestRecursiveInnerObject i4 = new TestRecursiveInnerObject(4); - final TestRecursiveObject o1_a = new TestRecursiveObject(i1_1, i2_1, 1); - final TestRecursiveObject o1_b = new TestRecursiveObject(i1_2, i2_2, 1); + final TestRecursiveObject o1A = new TestRecursiveObject(i1_1, i2_1, 1); + final TestRecursiveObject o1B = new TestRecursiveObject(i1_2, i2_2, 1); final TestRecursiveObject o2 = new TestRecursiveObject(i3, i4, 2); final TestRecursiveObject oNull = new TestRecursiveObject(null, null, 2); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1A).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1B).isEquals()); - assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1A, o2).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(oNull, oNull).isEquals()); - assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, oNull).isEquals()); + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1A, oNull).isEquals()); } @Test public void testObjectRecursiveCycleSelfreference() { - final TestRecursiveCycleObject o1_a = new TestRecursiveCycleObject(1); - final TestRecursiveCycleObject o1_b = new TestRecursiveCycleObject(1); + final TestRecursiveCycleObject o1A = new TestRecursiveCycleObject(1); + final TestRecursiveCycleObject o1B = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject o2 = new TestRecursiveCycleObject(2); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); - assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1A).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1B).isEquals()); + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1A, o2).isEquals()); } @Test public void testObjectRecursiveCycle() { - final TestRecursiveCycleObject o1_a = new TestRecursiveCycleObject(1); - final TestRecursiveCycleObject i1_a = new TestRecursiveCycleObject(o1_a, 100); - o1_a.setCycle(i1_a); + final TestRecursiveCycleObject o1A = new TestRecursiveCycleObject(1); + final TestRecursiveCycleObject i1A = new TestRecursiveCycleObject(o1A, 100); + o1A.setCycle(i1A); - final TestRecursiveCycleObject o1_b = new TestRecursiveCycleObject(1); - final TestRecursiveCycleObject i1_b = new TestRecursiveCycleObject(o1_b, 100); - o1_b.setCycle(i1_b); + final TestRecursiveCycleObject o1B = new TestRecursiveCycleObject(1); + final TestRecursiveCycleObject i1B = new TestRecursiveCycleObject(o1B, 100); + o1B.setCycle(i1B); final TestRecursiveCycleObject o2 = new TestRecursiveCycleObject(2); - final TestRecursiveCycleObject i2 = new TestRecursiveCycleObject(o1_b, 200); + final TestRecursiveCycleObject i2 = new TestRecursiveCycleObject(o1B, 200); o2.setCycle(i2); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); - assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); - assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1A).isEquals()); + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1A, o1B).isEquals()); + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1A, o2).isEquals()); - assertTrue(EqualsBuilder.reflectionEquals(o1_a, o1_b, false, null, true)); - assertFalse(EqualsBuilder.reflectionEquals(o1_a, o2, false, null, true)); + assertTrue(EqualsBuilder.reflectionEquals(o1A, o1B, false, null, true)); + assertFalse(EqualsBuilder.reflectionEquals(o1A, o2, false, null, true)); } @Test