diff --git a/pmd-java/src/main/resources/rulesets/java/strings.xml b/pmd-java/src/main/resources/rulesets/java/strings.xml index 3f10b95d68..cafbda7516 100644 --- a/pmd-java/src/main/resources/rulesets/java/strings.xml +++ b/pmd-java/src/main/resources/rulesets/java/strings.xml @@ -221,8 +221,9 @@ if (s.indexOf('d') {} String.trim().length() is an inefficient way to check if a String is really empty, as it creates a new String object just to check its size. Consider creating a static function that loops through a string, checking Character.isWhitespace() on each character and returning -false if a non-whitespace character is found. You can refer to Apache's StringUtils#isBlank (in commons-lang) -or Spring's StringUtils#hasText (in the Springs framework) for existing implementations. +false if a non-whitespace character is found. You can refer to Apache's StringUtils#isBlank (in commons-lang), +Spring's StringUtils#hasText (in the Spring framework) or Google's CharMatcher#whitespace (in Guava) for +existing implementations. 3