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-text.git
commit d7f28be3cceeec4e3a27616525de2a21c59f2167 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue May 31 08:41:46 2022 -0400 PMD: UselessParentheses --- src/main/java/org/apache/commons/text/WordUtils.java | 2 +- src/main/java/org/apache/commons/text/numbers/ParsedDecimal.java | 8 ++++---- .../apache/commons/text/similarity/IntersectionSimilarity.java | 4 ++-- .../org/apache/commons/text/similarity/JaroWinklerSimilarity.java | 2 +- .../commons/text/similarity/LevenshteinDetailedDistance.java | 8 ++++---- .../apache/commons/text/similarity/LongestCommonSubsequence.java | 2 +- .../java/org/apache/commons/text/translate/UnicodeEscaper.java | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java index 1d9d3d9f..561f1afe 100644 --- a/src/main/java/org/apache/commons/text/WordUtils.java +++ b/src/main/java/org/apache/commons/text/WordUtils.java @@ -380,7 +380,7 @@ public class WordUtils { for (int i = 0; i < strLen;) { final int codePoint = str.codePointAt(i); - if (delimiterSet.contains(codePoint) || (delimiters == null && Character.isWhitespace(codePoint))) { + if (delimiterSet.contains(codePoint) || delimiters == null && Character.isWhitespace(codePoint)) { lastWasGap = true; } else if (lastWasGap) { newCodePoints[count++] = codePoint; diff --git a/src/main/java/org/apache/commons/text/numbers/ParsedDecimal.java b/src/main/java/org/apache/commons/text/numbers/ParsedDecimal.java index 7581c0d1..544e11f0 100644 --- a/src/main/java/org/apache/commons/text/numbers/ParsedDecimal.java +++ b/src/main/java/org/apache/commons/text/numbers/ParsedDecimal.java @@ -219,7 +219,7 @@ final class ParsedDecimal { int exp = 0; for (; i < chars.length; ++i) { - exp = (exp * DECIMAL_RADIX) + digitValue(chars[i]); + exp = exp * DECIMAL_RADIX + digitValue(chars[i]); } return neg ? -exp : exp; @@ -515,7 +515,7 @@ final class ParsedDecimal { * @return {@code true} if a grouping separator should be added */ private boolean requiresGroupingSeparatorAfterPosition(final int pos) { - return pos > 1 && (pos % THOUSANDS_GROUP_SIZE) == 1; + return pos > 1 && pos % THOUSANDS_GROUP_SIZE == 1; } /** @@ -621,8 +621,8 @@ final class ParsedDecimal { // and the last digit is odd (half-even rounding). final int digitAfterLast = digits[count]; - return digitAfterLast > ROUND_CENTER || (digitAfterLast == ROUND_CENTER - && (count < digitCount - 1 || (digits[count - 1] % 2) != 0)); + return digitAfterLast > ROUND_CENTER || digitAfterLast == ROUND_CENTER + && (count < digitCount - 1 || digits[count - 1] % 2 != 0); } /** diff --git a/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java b/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java index c692342c..b3bd4f34 100644 --- a/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java +++ b/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java @@ -187,7 +187,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe if (objectsA instanceof Set && objectsB instanceof Set) { // If a Set then the elements will only have a count of 1. // Iterate over the smaller set. - intersection = (sizeA < sizeB) + intersection = sizeA < sizeB ? getIntersection((Set<T>) objectsA, (Set<T>) objectsB) : getIntersection((Set<T>) objectsB, (Set<T>) objectsA); } else { @@ -195,7 +195,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe final TinyBag bagA = toBag(objectsA); final TinyBag bagB = toBag(objectsB); // Iterate over the smaller number of unique elements - intersection = (bagA.uniqueElementSize() < bagB.uniqueElementSize()) + intersection = bagA.uniqueElementSize() < bagB.uniqueElementSize() ? getIntersection(bagA, bagB) : getIntersection(bagB, bagA); } diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java index d5e26513..3659d4d9 100644 --- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java +++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java @@ -155,7 +155,7 @@ public class JaroWinklerSimilarity implements SimilarityScore<Double> { if (m == 0) { return 0d; } - final double j = ((m / left.length() + m / right.length() + (m - (double) mtp[1] / 2) / m)) / 3; + final double j = (m / left.length() + m / right.length() + (m - (double) mtp[1] / 2) / m) / 3; return j < 0.7d ? j : j + defaultScalingFactor * mtp[2] * (1d - j); } diff --git a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java index 478f8405..65ad03e9 100644 --- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java +++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java @@ -100,8 +100,8 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu // handling insert and delete cases. deleted = false; added = false; - if (data - 1 == dataAtLeft && (data <= dataAtDiagonal && data <= dataAtTop) - || (dataAtDiagonal == -1 && dataAtTop == -1)) { // NOPMD + if (data - 1 == dataAtLeft && data <= dataAtDiagonal && data <= dataAtTop + || dataAtDiagonal == -1 && dataAtTop == -1) { // NOPMD columnIndex--; if (swapped) { addCount++; @@ -110,8 +110,8 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu delCount++; deleted = true; } - } else if (data - 1 == dataAtTop && (data <= dataAtDiagonal && data <= dataAtLeft) - || (dataAtDiagonal == -1 && dataAtLeft == -1)) { // NOPMD + } else if (data - 1 == dataAtTop && data <= dataAtDiagonal && data <= dataAtLeft + || dataAtDiagonal == -1 && dataAtLeft == -1) { // NOPMD rowIndex--; if (swapped) { delCount++; diff --git a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java index 3629bab6..7af20612 100644 --- a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java +++ b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java @@ -149,7 +149,7 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> { // An auxiliary method for CharSequence reversal private static String reverse(final CharSequence s) { - return (new StringBuilder(s)).reverse().toString(); + return new StringBuilder(s).reverse().toString(); } /** diff --git a/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java b/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java index 7d0c240c..9602679c 100644 --- a/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java +++ b/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java @@ -128,10 +128,10 @@ public class UnicodeEscaper extends CodePointTranslator { writer.write(toUtf16Escape(codepoint)); } else { writer.write("\\u"); - writer.write(HEX_DIGITS[(codepoint >> 12) & 15]); - writer.write(HEX_DIGITS[(codepoint >> 8) & 15]); - writer.write(HEX_DIGITS[(codepoint >> 4) & 15]); - writer.write(HEX_DIGITS[(codepoint) & 15]); + writer.write(HEX_DIGITS[codepoint >> 12 & 15]); + writer.write(HEX_DIGITS[codepoint >> 8 & 15]); + writer.write(HEX_DIGITS[codepoint >> 4 & 15]); + writer.write(HEX_DIGITS[codepoint & 15]); } return true; }