You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
It seems that invoking StringBuilder.append() within an if-statement triggers a false-positive of the ConsecutiveAppendsShouldReuse rule. At least, I don't see how the code could be modified to please this rule.
Code Sample demonstrating the issue:
StringBuildermessage = newStringBuilder();
if (nameOfOther == null)
message.append(validator.configuration().stringMappers().toString(other));
elsemessage.append(MessageBuilder.quoteName(nameOfOther));
message.append('.');
Error Message:
[INFO] PMD Failure: com.github.cowwoc.requirements.java.internal.implementation.message.ComparableMessages:47 Rule:ConsecutiveAppendsShouldReuse Priority:3 StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable..
where line 47 points to message.append(validator.configuration().stringMappers().toString(other));
Running PMD through:Maven
maven-pmd-plugin 3.21.2
The text was updated successfully, but these errors were encountered:
Affects PMD Version:
7.0.0
Rule:
Please provide the rule name and a link to the rule documentation: https://docs.pmd-code.org/latest/pmd_rules_java_performance.html#consecutiveappendsshouldreuse
Description:
It seems that invoking
StringBuilder.append()
within an if-statement triggers a false-positive of the ConsecutiveAppendsShouldReuse rule. At least, I don't see how the code could be modified to please this rule.Code Sample demonstrating the issue:
Error Message:
where line 47 points to
message.append(validator.configuration().stringMappers().toString(other));
Running PMD through: Maven
maven-pmd-plugin 3.21.2
The text was updated successfully, but these errors were encountered: