Trivial code householding
- Replace `if (!x) ... else ...` with `if(x) ... else ...` - Avoid throwing RuntimeException; use children
This commit is contained in:
@@ -62,10 +62,10 @@ public final class ToolsRunner {
|
||||
ToolTask task = tasks.get(taskName);
|
||||
if (task == null) {
|
||||
System.out.format("Unknown task '%s'%n", taskName);
|
||||
} else if (!(task instanceof AutoToolTask)) {
|
||||
System.out.format("Task '%s' cannot be run on command line%n", taskName);
|
||||
} else {
|
||||
} else if (task instanceof AutoToolTask) {
|
||||
((AutoToolTask) task).executeDefault();
|
||||
} else {
|
||||
System.out.format("Task '%s' cannot be run on command line%n", taskName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public final class VerifyMessagesTask implements ToolTask {
|
||||
File folder = new File(MESSAGES_FOLDER);
|
||||
File[] files = folder.listFiles();
|
||||
if (files == null) {
|
||||
throw new RuntimeException("Could not read files from folder '" + folder.getName() + "'");
|
||||
throw new IllegalStateException("Could not read files from folder '" + folder.getName() + "'");
|
||||
}
|
||||
|
||||
List<File> messageFiles = new ArrayList<>();
|
||||
@@ -143,7 +143,7 @@ public final class VerifyMessagesTask implements ToolTask {
|
||||
}
|
||||
}
|
||||
if (messageFiles.isEmpty()) {
|
||||
throw new RuntimeException("Error getting message files: list of files is empty");
|
||||
throw new IllegalStateException("Error getting message files: list of files is empty");
|
||||
}
|
||||
return messageFiles;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public final class FileUtils {
|
||||
try {
|
||||
Files.write(Paths.get(outputFile), contents.getBytes());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to write to file '" + outputFile + "'", e);
|
||||
throw new UnsupportedOperationException("Failed to write to file '" + outputFile + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class FileUtils {
|
||||
try {
|
||||
Files.write(Paths.get(outputFile), contents.getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to append to file '" + outputFile + "'", e);
|
||||
throw new UnsupportedOperationException("Failed to append to file '" + outputFile + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class FileUtils {
|
||||
try {
|
||||
return new String(Files.readAllBytes(Paths.get(file)), CHARSET);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not read from file '" + file + "'", e);
|
||||
throw new UnsupportedOperationException("Could not read from file '" + file + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class FileUtils {
|
||||
try {
|
||||
return Files.readAllLines(Paths.get(file), CHARSET);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not read from file '" + file + "'", e);
|
||||
throw new UnsupportedOperationException("Could not read from file '" + file + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ package tools.utils;
|
||||
*/
|
||||
public final class ToolsConstants {
|
||||
|
||||
private ToolsConstants() {
|
||||
}
|
||||
|
||||
public static final String MAIN_SOURCE_ROOT = "src/main/java/";
|
||||
|
||||
public static final String MAIN_RESOURCES_ROOT = "src/main/resources/";
|
||||
@@ -21,4 +18,7 @@ public final class ToolsConstants {
|
||||
|
||||
public static final String DOCS_FOLDER_URL = "https://github.com/AuthMe-Team/AuthMeReloaded/tree/master/docs/";
|
||||
|
||||
private ToolsConstants() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user