From 692d9e79d2ff4d0c50cc3d1e50af454b47abe657 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Fri, 15 Mar 2024 02:09:46 +0100 Subject: [PATCH] Fixes some warnings --- pom.xml | 2 +- src/main/java/net/knarcraft/ffmpegconverter/Main.java | 6 +++--- .../ffmpegconverter/converter/AbstractConverter.java | 8 ++++---- .../ffmpegconverter/parser/ConverterArgument.java | 2 +- .../knarcraft/ffmpegconverter/utility/FFMpegHelper.java | 4 ++-- .../net/knarcraft/ffmpegconverter/utility/OutputUtil.java | 2 +- .../net/knarcraft/ffmpegconverter/utility/Parser.java | 2 +- .../ffmpegconverter/converter/AnimeConverterTest.java | 8 -------- 8 files changed, 13 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index e186a66..dafdfe5 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ junit junit - 4.11 + 4.13.2 test diff --git a/src/main/java/net/knarcraft/ffmpegconverter/Main.java b/src/main/java/net/knarcraft/ffmpegconverter/Main.java index bc22a4e..c4a58d8 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/Main.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/Main.java @@ -156,7 +156,7 @@ class Main { int videoStreamIndex = -1; try { - if (input.size() > 0) { + if (!input.isEmpty()) { audioStreamIndex = Integer.parseInt(input.get(0)); } if (input.size() > 1) { @@ -191,7 +191,7 @@ class Main { int forcedSubtitleIndex = -1; String subtitleNameFilter = ""; - if (input.size() > 0) { + if (!input.isEmpty()) { audioLanguage = ListUtil.getListFromCommaSeparatedString(input.get(0)); } if (input.size() > 1) { @@ -247,7 +247,7 @@ class Main { private static String getChoice(String prompt) throws IOException { OutputUtil.println(prompt); String choice = ""; - while (choice.equals("")) { + while (choice.isEmpty()) { OutputUtil.println("Your input: "); choice = READER.nextLine(); } diff --git a/src/main/java/net/knarcraft/ffmpegconverter/converter/AbstractConverter.java b/src/main/java/net/knarcraft/ffmpegconverter/converter/AbstractConverter.java index d95c4dd..cdfe356 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/converter/AbstractConverter.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/converter/AbstractConverter.java @@ -37,7 +37,7 @@ public abstract class AbstractConverter implements Converter { audioFormats = FileUtil.readFileLines("audio_formats.txt"); videoFormats = FileUtil.readFileLines("video_formats.txt"); } catch (IOException e) { - e.printStackTrace(); + System.out.println("Unable to read audio and/or video formats from internal files."); System.exit(1); } } @@ -159,7 +159,7 @@ public abstract class AbstractConverter implements Converter { AudioStream audioStream = null; if (audioStreams.size() > n) { audioStream = audioStreams.get(n); - } else if (audioStreams.size() > 0) { + } else if (!audioStreams.isEmpty()) { audioStream = audioStreams.get(0); } return audioStream; @@ -180,7 +180,7 @@ public abstract class AbstractConverter implements Converter { SubtitleStream subtitleStream = null; if (subtitleStreams.size() > n) { subtitleStream = subtitleStreams.get(n); - } else if (subtitleStreams.size() > 0) { + } else if (!subtitleStreams.isEmpty()) { subtitleStream = subtitleStreams.get(0); } return subtitleStream; @@ -201,7 +201,7 @@ public abstract class AbstractConverter implements Converter { VideoStream videoStream = null; if (videoStreams.size() > n) { videoStream = videoStreams.get(n); - } else if (videoStreams.size() > 0) { + } else if (!videoStreams.isEmpty()) { videoStream = videoStreams.get(0); } return videoStream; diff --git a/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java b/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java index 3083950..2b5f793 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/parser/ConverterArgument.java @@ -61,7 +61,7 @@ public class ConverterArgument { * @return

True if the argument is valid. False otherwise.

*/ public boolean testArgumentValue(String value) { - if (value.length() == 0) { + if (value.isEmpty()) { return !valueRequired; } if (valueRequired && value.startsWith("-")) { diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java index acea9d3..1a8f863 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java @@ -110,7 +110,7 @@ public final class FFMpegHelper { StringBuilder output = new StringBuilder(); while (process.isAlive()) { String read = readProcess(processReader, spacer); - if (!read.equals("")) { + if (!read.isEmpty()) { if (write) { OutputUtil.println(read); } else { @@ -339,7 +339,7 @@ public final class FFMpegHelper { private static String readProcess(BufferedReader reader, String spacer) throws IOException { String line; StringBuilder text = new StringBuilder(); - while (reader.ready() && (line = reader.readLine()) != null && !line.equals("") && !line.equals("\n")) { + while (reader.ready() && (line = reader.readLine()) != null && !line.isEmpty() && !line.equals("\n")) { text.append(line).append(spacer); } return text.toString().trim(); diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java index 71b1bbd..61d0e50 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java @@ -32,7 +32,7 @@ public final class OutputUtil { * @throws IOException

If a write is not possible.

*/ public static void println(String input) throws IOException { - if (!input.equals("")) { + if (!input.isEmpty()) { writer.write(input); } println(); diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java index f6999b7..a361299 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java @@ -193,7 +193,7 @@ public final class Parser { * @return

True if the string builder is non empty.

*/ private static boolean isNotEmpty(StringBuilder builder) { - return !builder.toString().trim().equals(""); + return !builder.toString().trim().isEmpty(); } } diff --git a/src/test/java/net/knarcraft/ffmpegconverter/converter/AnimeConverterTest.java b/src/test/java/net/knarcraft/ffmpegconverter/converter/AnimeConverterTest.java index 673f4f9..1ae1961 100644 --- a/src/test/java/net/knarcraft/ffmpegconverter/converter/AnimeConverterTest.java +++ b/src/test/java/net/knarcraft/ffmpegconverter/converter/AnimeConverterTest.java @@ -1,9 +1,6 @@ package net.knarcraft.ffmpegconverter.converter; import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; public class AnimeConverterTest { @@ -14,9 +11,4 @@ public class AnimeConverterTest { false, -1, -1, ""); } - @Test - public void weirdTest() { - assertEquals(0, 0); - } - }