rspec/rules/S3024/java/rule.adoc
2022-02-04 16:28:24 +00:00

30 lines
656 B
Plaintext

The use of a ``++StringBuilder++`` or ``++StringBuffer++`` is supposed to make ``++String++`` assembly more efficient than plain concatenation. So don't ruin the effect by concatenating the arguments to ``++append++``.
== Noncompliant Code Example
[source,java]
----
StringBuilder sb = new StringBuilder();
sb.append("foo is: " + getFoo()); // Noncompliant
----
== Compliant Solution
[source,java]
----
StringBuilder sb = new StringBuilder();
sb.append("foo is: ").append(getFoo());
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]