[java] StringToString rule false-positive with field access #2080
Labels
a:false-positive
PMD flags a piece of code that is not problematic
in:symbol-table
Affects the symbol table code
Milestone
Affects PMD Version:
6.18.0
Rule: StringToString
Description:
Attached code should help to understand better the following description.
We found a false-positive case for the rule String.toString().
When you assign an object field (of type
String
) to a field of another object (not of typeString
) callingtoString()
, the rule emits a warning about calling toString on a String object only when the field names match (value = otherObj.value.toString()
). If either one of the field name changes, Pmd stops emitting the warning (workaround).Since the enum is not a
String
object, we think that the warning is a false-positive triggered by the field name equality.Code Sample demonstrating the issue:
See attached project for a ready-to-go reproduction case.
Running PMD through: Gradle
Attached reproduction project (forgive the eclipse files)
The text was updated successfully, but these errors were encountered: