Affects PMD Version:
6.6.0
Rule:
ConsecutiveLiteralAppends
Description:
ConsecutiveLiteralAppends complains about the below snippet (marker at the first line) even though it shouldn't. Presumably, it is not taking into account the fact that the lambda is calling the builder.
Code Sample demonstrating the issue:
StringBuilder builder = new StringBuilder("[");
nodes.forEach((k, v) -> builder
.append(k)
.append(" = ")
.append(valueToStringFunction.apply(v))
.append(", "));
int length = builder.length();
if (length > 1) {
builder.delete(length - 2, length);
}
builder.append(']');
return builder.toString();
Running PMD through: Eclipse
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