From 3ac5d486ece081b390beb8593a9bfc4bd757e6b0 Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Tue, 18 Aug 2015 22:02:48 +0200 Subject: [PATCH] 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. --- src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java index 62c8c0e08..7bc9e4656 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java @@ -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()); }