A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/290 below:

[java] InefficientEmptyStringCheck misses String.trim().isEmpty() · Issue #290 · pmd/pmd · GitHub

Rule Set: java/strings.html#InefficientEmptyStringCheck

Description:

Since Java 1.6 the String class provides the isEmpty() method which returns true if the string has a length of 0 (JavaDoc). The check for the inefficient empty string check should be extended such that String.trim().isEmpty() triggers a violation, too.

Code Sample demonstrating the issue:

final String str = "   test.  ";
// the next line should cause a violation of the InefficientEmptyStringCheck but does not
if (str.trim().isEmpty()) {
    System.out.println("String is empty");
}

Running PMD through: Maven and Eclipse


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4