toString called on an Array yields a reference, not the contents
ID |
scala.correctness.array_tostring |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Api Misuse |
Language |
Scala |
Description
Array does not override toString, so this yields something like [Ljava.lang.String;@1b6d3586 rather than the elements. Use mkString to render the contents.
Rationale
Array does not override toString, so this yields something like [Ljava.lang.String;@1b6d3586 rather than the elements. Use mkString to render the contents.
The following code illustrates the pattern detected by this rule:
class ArrayToString {
def bad(names: Array[String]): String = {
// FLAGGED: toString called on an Array yields a reference, not the contents
names.toString
}
}