[TEXT-212] CI/linters changes
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 4d35b19..c2ab36e 100644
--- a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java
+++ b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java
@@ -64,9 +64,9 @@
* An evaluation using JMH revealed that this method is almost two times faster than its previous version.
* </p>
*
- * @param left First character sequence
- * @param right Second character sequence
- * @return Length of the longest common subsequence of <code>left</code> and <code>right</code>
+ * @param left first character sequence
+ * @param right second character sequence
+ * @return length of the longest common subsequence of <code>left</code> and <code>right</code>
* @throws IllegalArgumentException if either String input {@code null}
*/
@Override
@@ -98,12 +98,12 @@
* the LCS of the two sequences in <i>O(m*n)</i> time and <i>O(n)</i> space.
* The last element of the returned array, is the size of the LCS of the two input sequences.
*
- * @param left First input sequence.
- * @param right Second input sequence.
- * @return Last row of DP table for calculating the LCS of <code>left</code> and <code>right</code>
+ * @param left first input sequence.
+ * @param right second input sequence.
+ * @return last row of the dynamic-programming (DP) table for calculating the LCS of <code>left</code> and <code>right</code>
* @since 1.10
*/
- static int[] algorithmB(final CharSequence left, final CharSequence right) {
+ private static int[] algorithmB(final CharSequence left, final CharSequence right) {
final int m = left.length();
final int n = right.length();
@@ -152,7 +152,7 @@
*
* @param left first character sequence
* @param right second character sequence
- * @return The longest common subsequence found
+ * @return the longest common subsequence found
* @throws IllegalArgumentException if either String input {@code null}
* @deprecated Deprecated as of 1.2 due to a typo in the method name.
* Use {@link #longestCommonSubsequence(CharSequence, CharSequence)} instead.
@@ -186,9 +186,9 @@
* elements.
* </p>
*
- * @param left First character sequence
- * @param right Second character sequence
- * @return The longest common subsequence found
+ * @param left first character sequence
+ * @param right second character sequence
+ * @return the longest common subsequence found
* @throws IllegalArgumentException if either String input {@code null}
* @since 1.2
*/
@@ -216,25 +216,25 @@
/**
* An implementation of "ALG C" from Hirschberg's CACM '71 paper.
* Assuming the first input sequence is of size <code>m</code> and the second input sequence is of size
- * <code>n</code>, this method return the Longest Common Subsequence (LCS) the two sequences in
+ * <code>n</code>, this method returns the Longest Common Subsequence (LCS) of the two sequences in
* <i>O(m*n)</i> time and <i>O(m+n)</i> space.
*
- * @param left First input sequence.
- * @param right Second input sequence.
- * @return The LCS of <code>left</code> and <code>right</code>
+ * @param left first input sequence.
+ * @param right second input sequence.
+ * @return the LCS of <code>left</code> and <code>right</code>
* @since 1.10
*/
- static String algorithmC(final CharSequence left, final CharSequence right) {
+ private static String algorithmC(final CharSequence left, final CharSequence right) {
final int m = left.length();
final int n = right.length();
- String out = "";
+ final StringBuilder out = new StringBuilder();
if (m == 1) { // Handle trivial cases, as per the paper
final char leftCh = left.charAt(0);
for (int j = 0; j < n; j++) {
if (leftCh == right.charAt(j)) {
- out += leftCh;
+ out.append(leftCh);
break;
}
}
@@ -260,11 +260,11 @@
}
// Step 5: solve simpler problems, recursively
- out = out.concat(algorithmC(leftFirstPart, right.subSequence(0, k)));
- out = out.concat(algorithmC(leftSecondPart, right.subSequence(k, n)));
+ out.append(algorithmC(leftFirstPart, right.subSequence(0, k)));
+ out.append(algorithmC(leftSecondPart, right.subSequence(k, n)));
}
- return out;
+ return out.toString();
}
// An auxiliary method for CharSequence reversal
diff --git a/src/test/java/org/apache/commons/text/jmh/LongestCommonSubsequencePerformance.java b/src/test/java/org/apache/commons/text/jmh/LongestCommonSubsequencePerformance.java
index 666758b..f548e20 100644
--- a/src/test/java/org/apache/commons/text/jmh/LongestCommonSubsequencePerformance.java
+++ b/src/test/java/org/apache/commons/text/jmh/LongestCommonSubsequencePerformance.java
@@ -61,7 +61,8 @@
InputStreamReader isr = new InputStreamReader(Objects.requireNonNull(is));
BufferedReader br = new BufferedReader(isr)) {
String line;
- while ((line = br.readLine()) != null && !(line = line.trim()).isEmpty()) {
+ while ((line = br.readLine()) != null && !line.trim().isEmpty()) {
+ line = line.trim();
final int indexOfComma = line.indexOf(',');
final String inputA = line.substring(0, indexOfComma);
final String inputB = line.substring(1 + indexOfComma);