Affects PMD Version:
6.22.0
Rule:
StringToString
Description:
StringToString can not detect the case: getStringMethod().toString()
This rule is implemented in File: pmd-java-6.22.0-sources.jar!\net\sourceforge\pmd\lang\java\rule\performance\StringToStringRule.java
Firstly, this method visits ASTVariableDeclaratorId node and gets variables of type String
or String[]
, and then check whether these variables call toString()
method.
Calling toString()
by another method that return String
may be ignored.
Code Sample demonstrating the issue:
public class Test{ public String foo(){ String bar = "foobar"; return bar; } public void test(){ String fooStr = foo().toString(); } }
Expected outcome:
false-negative
Running PMD through:
CLI
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