You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/04/20 00:40:41 UTC

[GitHub] [commons-lang] Isira-Seneviratne opened a new pull request #521: Simplify some if statements in StringUtils.

Isira-Seneviratne opened a new pull request #521:
URL: https://github.com/apache/commons-lang/pull/521


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-lang] coveralls edited a comment on issue #521: Simplify some if statements in StringUtils.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #521:
URL: https://github.com/apache/commons-lang/pull/521#issuecomment-616255603


   
   [![Coverage Status](https://coveralls.io/builds/30183164/badge)](https://coveralls.io/builds/30183164)
   
   Coverage decreased (-0.0009%) to 95.093% when pulling **a7c92a631e1453b1f2b041e894a7b7ad34194c4f on Isira-Seneviratne:Simplify_StringUtils_if_statements** into **7f45b8898b804f0fe4fa55c088ff4a99a56af277 on apache:master**.
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-lang] garydgregory commented on a change in pull request #521: Simplify some if statements in StringUtils.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #521:
URL: https://github.com/apache/commons-lang/pull/521#discussion_r411684196



##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -330,11 +330,9 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
      * @since 3.6
      */
     public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
-        if (isEmpty(str) && isEmpty(abbrevMarker)) {
-            return str;
-        } else if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
-            return str.substring(0, maxWidth);
-        } else if (isEmpty(str) || isEmpty(abbrevMarker)) {
+        if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {

Review comment:
       @Isira-Seneviratne You are correct!




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-lang] Isira-Seneviratne commented on a change in pull request #521: Simplify some if statements in StringUtils.

Posted by GitBox <gi...@apache.org>.
Isira-Seneviratne commented on a change in pull request #521:
URL: https://github.com/apache/commons-lang/pull/521#discussion_r411417616



##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -330,11 +330,9 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
      * @since 3.6
      */
     public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
-        if (isEmpty(str) && isEmpty(abbrevMarker)) {
-            return str;
-        } else if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
-            return str.substring(0, maxWidth);
-        } else if (isEmpty(str) || isEmpty(abbrevMarker)) {
+        if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {

Review comment:
       That change would mean that `abbrevMarker` is potentially null, according to SonarLint.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-lang] Isira-Seneviratne commented on a change in pull request #521: Simplify some if statements in StringUtils.

Posted by GitBox <gi...@apache.org>.
Isira-Seneviratne commented on a change in pull request #521:
URL: https://github.com/apache/commons-lang/pull/521#discussion_r411417616



##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -330,11 +330,9 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
      * @since 3.6
      */
     public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
-        if (isEmpty(str) && isEmpty(abbrevMarker)) {
-            return str;
-        } else if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
-            return str.substring(0, maxWidth);
-        } else if (isEmpty(str) || isEmpty(abbrevMarker)) {
+        if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {

Review comment:
       That change would mean that `abbrevMarker` is potentially null.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-lang] garydgregory commented on a change in pull request #521: Simplify some if statements in StringUtils.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #521:
URL: https://github.com/apache/commons-lang/pull/521#discussion_r411386416



##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -330,11 +330,9 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
      * @since 3.6
      */
     public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
-        if (isEmpty(str) && isEmpty(abbrevMarker)) {
-            return str;
-        } else if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
-            return str.substring(0, maxWidth);
-        } else if (isEmpty(str) || isEmpty(abbrevMarker)) {
+        if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {

Review comment:
       How about `EMPTY.equals(abbrevMarker)` -> `isEmpty(abbrevMarker)` ?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-lang] coveralls commented on issue #521: Simplify some if statements in StringUtils.

Posted by GitBox <gi...@apache.org>.
coveralls commented on issue #521:
URL: https://github.com/apache/commons-lang/pull/521#issuecomment-616255603


   
   [![Coverage Status](https://coveralls.io/builds/30182574/badge)](https://coveralls.io/builds/30182574)
   
   Coverage decreased (-0.001%) to 95.093% when pulling **f00ba3ba068333cce942734e6d4b79a31d5799b1 on Isira-Seneviratne:Simplify_StringUtils_if_statements** into **7f45b8898b804f0fe4fa55c088ff4a99a56af277 on apache:master**.
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org