A RetroSearch Logo

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

Search Query:

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

false negative when using method result · Issue #3848 · pmd/pmd · GitHub

Affects PMD Version:6.42.0

Rule:StringInstantiation

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_performance.html#stringinstantiation

Description:

Hi, I found a false negative about the rule StringInstantiation. Please read the following code example. PMD should have reported a warning at line 5 because this line create a String object by new. Hence, I think this is a false negative. Thanks for your kind consideration.

Code Sample demonstrating the issue:

String getLiteral() {
    return "foo";
}
String foo() {
    return new String(getLiteral()); // should report a warning at this line
}

Expected outcome:Warning

PMD should report a violation at line 5, but doesn't. This is a false-negative.

Running PMD through: [Maven]


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