Remove string concatenation done inside string builders. #1555

Fixes `StringConcatenationInsideStringBufferAppend` inspection violations in test code.

Description:
>Reports String concatenation used as the argument to StringBuffer.append(), StringBuilder.append() or Appendable.append(). Such calls may profitably be turned into chained append calls on the existing StringBuffer/Builder/Appendable, saving the cost of an extra StringBuffer/Builder allocation.
This inspection ignores compile time evaluated String concatenations, which when converted to chained append calls would only worsen performance.
This commit is contained in:
Michal Kordas 2015-08-18 22:02:48 +02:00 committed by Roman Ivanov
parent 4f6d7e415d
commit 3ac5d486ec
1 changed files with 3 additions and 3 deletions

View File

@ -485,14 +485,14 @@ public class MainTest {
.replace("/", File.separator);
String format = "%s.java:%s: warning: File length is %s lines (max allowed is 80).";
StringBuilder sb = new StringBuilder();
sb.append("Starting audit..." + System.getProperty("line.separator"));
sb.append("Starting audit...").append(System.getProperty("line.separator"));
for (String[] outputValue : outputValues) {
String line = String.format(format,
expectedPath + outputValue[0], outputValue[1],
outputValue[2]);
sb.append(line + System.getProperty("line.separator"));
sb.append(line).append(System.getProperty("line.separator"));
}
sb.append("Audit done." + System.getProperty("line.separator"));
sb.append("Audit done.").append(System.getProperty("line.separator"));
assertEquals(sb.toString(), systemOut.getLog());
assertEquals("", systemErr.getLog());
}