A RetroSearch Logo

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

Search Query:

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

[java] Improve message of InefficientEmptyStringCheck for String.trim().isEmpty() · Issue #1125 · pmd/pmd · GitHub

Affects PMD Version: 6.3.0

Rule: InefficientEmptyStringCheck

Description:

public boolean method0(String arg0) {
    return arg0.trim().isEmpty();
}

produces the message InefficientEmptyStringCheck Priority:3 String.trim().length()==0 is an inefficient way to validate an empty String.. which caused the following misunderstanding on my side: I somehow assumed that there's a difference between String.length()==0 and String.isEmpty() like there is for Collection.size()==0 and Collection.isEmpty() and PMD is confused by the trim in between because of the message. That's not the case and only learned afterwards the String.trim.[length check] is inefficient. It's a rare case, but I'd like to share it together with the suggestion to make the error message say exactly what's written in the code in order to avoid it for anyone else.

Code Sample demonstrating the issue:

see above

Running PMD through: Maven (Plugin version 3.9.0)


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