Affects SpotBugs Version:
spotbugs-4.0.0-RC2
Rule:
DMI_INVOKING_TOSTRING_ON_ARRAY
Description:
Unable to detect String automatic conversion when string concatenation, for example: "foo" + barArray,
This rule is implemented in SpotBugs.jar\main\java\edu\umd\cs\findbugs\detect\FindPuzzlers.java.
This rule uses the following code to detect explicit string conversion:
if (seen == Const.INVOKEVIRTUAL
&& stack.getStackDepth() > 0
&& ("toString".equals(getNameConstantOperand()) && "()Ljava/lang/String;".equals(getSigConstantOperand())
|| "append".equals(getNameConstantOperand())
&& "(Ljava/lang/Object;)Ljava/lang/StringBuilder;".equals(getSigConstantOperand())
&& "java/lang/StringBuilder".equals(getClassConstantOperand())
|| "append".equals(getNameConstantOperand())
&& "(Ljava/lang/Object;)Ljava/lang/StringBuffer;".equals(getSigConstantOperand())
&& "java/lang/StringBuffer".equals(getClassConstantOperand()) || ("print".equals(getNameConstantOperand())
|| "println".equals(getNameConstantOperand()))
&& "(Ljava/lang/Object;)V".equals(getSigConstantOperand())))
which includes the following 5 situations: 1.toString, 2.StringBuilder.append(Object), 3.StringBuffer.append(Object), 4.print(Object), 5.println(Object).
The string conversion performed during string concatenation is ignored.
Code Sample demonstrating the issue:
public void setRetrieveAttributes(String[] retrieveAttributes)
{
LOGGER.debug("retrieveAttributes::" + retrieveAttributes);
}
Expected outcome:
false-negative
Running SpotBugs through:
command line
Affects SpotBugs Version:
spotbugs-4.0.0-RC2
Rule:
DMI_INVOKING_TOSTRING_ON_ARRAY
Description:
Unable to detect String automatic conversion when string concatenation, for example:
"foo" + barArray,This rule is implemented in SpotBugs.jar\main\java\edu\umd\cs\findbugs\detect\FindPuzzlers.java.
This rule uses the following code to detect explicit string conversion:
which includes the following 5 situations: 1.
toString, 2.StringBuilder.append(Object), 3.StringBuffer.append(Object), 4.print(Object), 5.println(Object).The string conversion performed during string concatenation is ignored.
Code Sample demonstrating the issue:
Expected outcome:
false-negative
Running SpotBugs through:
command line