From 299d82a2d4219f9b5edbf05a191ba3ba4289a61e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 12 Dec 2024 22:49:45 +0000 Subject: [PATCH] a reformat code --- .../ReporterThatCreatesAnApprovalScript.java | 75 ++++++++++--------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/approvaltests/src/main/java/org/approvaltests/reporters/ReporterThatCreatesAnApprovalScript.java b/approvaltests/src/main/java/org/approvaltests/reporters/ReporterThatCreatesAnApprovalScript.java index 4c31b746..3358eb0a 100644 --- a/approvaltests/src/main/java/org/approvaltests/reporters/ReporterThatCreatesAnApprovalScript.java +++ b/approvaltests/src/main/java/org/approvaltests/reporters/ReporterThatCreatesAnApprovalScript.java @@ -8,41 +8,46 @@ import java.io.File; -public class ReporterThatCreatesAnApprovalScript implements ApprovalFailureReporter { - private static String fileName = "approval_script"; - private static File scriptFile = null; - static { - initializeFile(); - - } - - private static void initializeFile() { - if (scriptFile != null) {return;} - if (SystemUtils.isWindowsEnvironment()) { - initializeWindows(); - } else { - initializeLinux(); - } - SimpleLogger.event("Created approval script:\n" + scriptFile.getAbsolutePath()); - } - - private static void initializeLinux() { - scriptFile = new File(ApprovedFileLog.APPROVAL_TEMP_DIRECTORY + "/" + fileName + ".sh"); - FileUtils.createIfNeeded(scriptFile.getAbsolutePath()); - FileUtils.writeFile(scriptFile, "#!/bin/bash\n"); - scriptFile.setExecutable(true); - } - - private static void initializeWindows() { - scriptFile = new File(ApprovedFileLog.APPROVAL_TEMP_DIRECTORY + "\\" + fileName + ".bat"); - FileUtils.createIfNeeded(scriptFile.getAbsolutePath()); - FileUtils.writeFile(scriptFile, ""); +public class ReporterThatCreatesAnApprovalScript implements ApprovalFailureReporter +{ + private static String fileName = "approval_script"; + private static File scriptFile = null; + static + { + initializeFile(); + } + private static void initializeFile() + { + if (scriptFile != null) + { return; } + if (SystemUtils.isWindowsEnvironment()) + { + initializeWindows(); } - - @Override - public boolean report(String received, String approved) { - String commandLine = ClipboardReporter.getCommandLine(received, approved); - FileUtils.appendToFile(scriptFile, commandLine + "\n"); - return true; + else + { + initializeLinux(); } + SimpleLogger.event("Created approval script:\n" + scriptFile.getAbsolutePath()); + } + private static void initializeLinux() + { + scriptFile = new File(ApprovedFileLog.APPROVAL_TEMP_DIRECTORY + "/" + fileName + ".sh"); + FileUtils.createIfNeeded(scriptFile.getAbsolutePath()); + FileUtils.writeFile(scriptFile, "#!/bin/bash\n"); + scriptFile.setExecutable(true); + } + private static void initializeWindows() + { + scriptFile = new File(ApprovedFileLog.APPROVAL_TEMP_DIRECTORY + "\\" + fileName + ".bat"); + FileUtils.createIfNeeded(scriptFile.getAbsolutePath()); + FileUtils.writeFile(scriptFile, ""); + } + @Override + public boolean report(String received, String approved) + { + String commandLine = ClipboardReporter.getCommandLine(received, approved); + FileUtils.appendToFile(scriptFile, commandLine + "\n"); + return true; + } }