From 8fe17463552798b2d50a85fa54850bba09e8e932 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 | 13 +++++++------ .../checkstyle/templates/TemplateProcessorTest.java | 2 +- 2 files changed, 8 insertions(+), 7 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 42f3e33c..710f76f9 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java @@ -47,8 +47,9 @@ private Main() { * Entry point. * * @param args command line arguments. - * @noinspection UseOfSystemOutOrSystemErr + * @noinspection UseOfSystemOutOrSystemErr, CallToSystemExit * @noinspectionreason UseOfSystemOutOrSystemErr - used for CLI output + * @noinspectionreason CallToSystemExit - main method must exit with code */ public static void main(String... args) { int errorCounter; @@ -77,17 +78,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 1bf8ccfa..37cfa66e 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 {