From 6a5a342dbd1b8c03eeaaa429f8b160386a269a3e Mon Sep 17 00:00:00 2001 From: Vyom-Yadav Date: Sun, 28 Aug 2022 01:55:27 +0530 Subject: [PATCH] Issue #614: Resolve CallToSystemExit, string formatting and string builder IDEA violations --- .../src/main/java/com/github/checkstyle/Main.java | 12 +++++++----- .../checkstyle/templates/TemplateProcessorTest.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java b/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java index 394b0d590..8f601ed71 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java @@ -47,6 +47,8 @@ private Main() { * Entry point. * * @param args command line arguments. + * @noinspection CallToSystemExit + * @noinspectionreason CallToSystemExit - main method must exit with code */ public static void main(String... args) { int errorCounter; @@ -75,17 +77,17 @@ public static void main(String... args) { } if (errorCounter == 0) { if (publicationErrors != null && !publicationErrors.isEmpty()) { - System.out.println(String.format("%nPublication ends with %d errors:", - publicationErrors.size())); + System.out.printf("%nPublication ends with %d errors:%n", + publicationErrors.size()); printListOf(publicationErrors); } else { - System.out.println(String.format("%nExecution succeeded!")); + System.out.printf("%nExecution succeeded!%n"); } } else { - System.out.println(String.format("%nGeneration ends with %d errors.", - errorCounter)); + System.out.printf("%nGeneration ends with %d errors.%n", + errorCounter); System.exit(ERROR_EXIT_CODE); } } diff --git a/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java b/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java index 1bf8ccfa8..37cfa66ef 100644 --- a/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java +++ b/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java @@ -336,7 +336,7 @@ private void assertFile(String actualName) { } private static String getFileContents(File file) throws IOException { - final StringBuilder result = new StringBuilder(); + final StringBuilder result = new StringBuilder(256); try (BufferedReader br = Files.newBufferedReader(file.toPath())) { do {