garydgregory commented on code in PR #220:
URL: https://github.com/apache/commons-codec/pull/220#discussion_r1404351532


##########
src/test/java/org/apache/commons/codec/language/MatchRatingApproachEncoderTest.java:
##########
@@ -519,4 +520,22 @@ public final void 
testRemoveVowel_ALESSANDRA_Returns_ALSSNDR() {
 
     // ***** END REGION - TEST GET MRA COMPARISONS
 
+    // ***** BEGIN REGION - TEST INVALID STRING *****
+
+    @Test
+    public final void testPunctuationOnly() {
+      assertDoesNotThrow(() -> this.getStringEncoder().encode(".,-"));

Review Comment:
   See comment in other PR.



##########
src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java:
##########
@@ -126,10 +126,20 @@ public final String encode(String name) {
         // Preprocessing
         name = cleanName(name);
 
+        // Bulletproof if name becomes empty after cleanName(name)
+        if (EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) || 
name.length() == 0) {

Review Comment:
   - You're checking that the name is empty... twice?
   - Why use equalsIgnoreCase() for SPACE?



##########
src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java:
##########
@@ -126,10 +126,20 @@ public final String encode(String name) {
         // Preprocessing
         name = cleanName(name);
 
+        // Bulletproof if name becomes empty after cleanName(name)
+        if (EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) || 
name.length() == 0) {
+            return EMPTY;
+        }
+
         // BEGIN: Actual encoding part of the algorithm...
         // 1. Delete all vowels unless the vowel begins the word
         name = removeVowels(name);
 
+        // Bulletproof if name becomes empty after removeVowels(name)
+        if (EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) || 
name.length() == 0) {

Review Comment:
   - You're checking that the name is empty... twice?
   - Why use equalsIgnoreCase() for SPACE?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to