We are using Sonarqube 8.7 and I tried to active rule java:S1067.
My expectation was to find issues where to many expressions are concatenated, but I now have this false positive:
Reduce the number of conditional operators (6) used in the expression (maximum allowed 5).
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("name", name)
.add("foo", foo)
.add("bar", bar)
.add("foo1", (foo1!= null) ? (foo1.length + " Byte") : "null")
.add("foo2", foo2)
.add("foo3", (foo3!= null) ? (foo3.length + " Byte") : "null")
.add("foo4", foo4)
.add("foo5", foo5)
.add("foo6", (foo6 != null) ? (foo6.length + " Byte") : "null")
.add("foo7", foo7)
.add("foo8", (foo8 != null) ? (foo8.length + " Byte") : "null")
.add("foo9", (foo9!= null) ? foo9.toUpperCase(Locale.ROOT) : "null")
.add("foo10", (foo10 != null) ? foo10.toUpperCase(Locale.ROOT) : "null")
.add("foo11", foo11)
.add("overallChecksum", overallChecksum)
.toString();
}
I think in chained method calls it should not sum up the expressions inside single methods.
Kind regards,
Michael