Fixes some warnings

This commit is contained in:
Kristian Knarvik 2024-03-15 02:09:46 +01:00
parent 6c614b2f17
commit 692d9e79d2
8 changed files with 13 additions and 21 deletions

View File

@ -101,7 +101,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.11</version> <version>4.13.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -156,7 +156,7 @@ class Main {
int videoStreamIndex = -1; int videoStreamIndex = -1;
try { try {
if (input.size() > 0) { if (!input.isEmpty()) {
audioStreamIndex = Integer.parseInt(input.get(0)); audioStreamIndex = Integer.parseInt(input.get(0));
} }
if (input.size() > 1) { if (input.size() > 1) {
@ -191,7 +191,7 @@ class Main {
int forcedSubtitleIndex = -1; int forcedSubtitleIndex = -1;
String subtitleNameFilter = ""; String subtitleNameFilter = "";
if (input.size() > 0) { if (!input.isEmpty()) {
audioLanguage = ListUtil.getListFromCommaSeparatedString(input.get(0)); audioLanguage = ListUtil.getListFromCommaSeparatedString(input.get(0));
} }
if (input.size() > 1) { if (input.size() > 1) {
@ -247,7 +247,7 @@ class Main {
private static String getChoice(String prompt) throws IOException { private static String getChoice(String prompt) throws IOException {
OutputUtil.println(prompt); OutputUtil.println(prompt);
String choice = ""; String choice = "";
while (choice.equals("")) { while (choice.isEmpty()) {
OutputUtil.println("Your input: "); OutputUtil.println("Your input: ");
choice = READER.nextLine(); choice = READER.nextLine();
} }

View File

@ -37,7 +37,7 @@ public abstract class AbstractConverter implements Converter {
audioFormats = FileUtil.readFileLines("audio_formats.txt"); audioFormats = FileUtil.readFileLines("audio_formats.txt");
videoFormats = FileUtil.readFileLines("video_formats.txt"); videoFormats = FileUtil.readFileLines("video_formats.txt");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); System.out.println("Unable to read audio and/or video formats from internal files.");
System.exit(1); System.exit(1);
} }
} }
@ -159,7 +159,7 @@ public abstract class AbstractConverter implements Converter {
AudioStream audioStream = null; AudioStream audioStream = null;
if (audioStreams.size() > n) { if (audioStreams.size() > n) {
audioStream = audioStreams.get(n); audioStream = audioStreams.get(n);
} else if (audioStreams.size() > 0) { } else if (!audioStreams.isEmpty()) {
audioStream = audioStreams.get(0); audioStream = audioStreams.get(0);
} }
return audioStream; return audioStream;
@ -180,7 +180,7 @@ public abstract class AbstractConverter implements Converter {
SubtitleStream subtitleStream = null; SubtitleStream subtitleStream = null;
if (subtitleStreams.size() > n) { if (subtitleStreams.size() > n) {
subtitleStream = subtitleStreams.get(n); subtitleStream = subtitleStreams.get(n);
} else if (subtitleStreams.size() > 0) { } else if (!subtitleStreams.isEmpty()) {
subtitleStream = subtitleStreams.get(0); subtitleStream = subtitleStreams.get(0);
} }
return subtitleStream; return subtitleStream;
@ -201,7 +201,7 @@ public abstract class AbstractConverter implements Converter {
VideoStream videoStream = null; VideoStream videoStream = null;
if (videoStreams.size() > n) { if (videoStreams.size() > n) {
videoStream = videoStreams.get(n); videoStream = videoStreams.get(n);
} else if (videoStreams.size() > 0) { } else if (!videoStreams.isEmpty()) {
videoStream = videoStreams.get(0); videoStream = videoStreams.get(0);
} }
return videoStream; return videoStream;

View File

@ -61,7 +61,7 @@ public class ConverterArgument {
* @return <p>True if the argument is valid. False otherwise.</p> * @return <p>True if the argument is valid. False otherwise.</p>
*/ */
public boolean testArgumentValue(String value) { public boolean testArgumentValue(String value) {
if (value.length() == 0) { if (value.isEmpty()) {
return !valueRequired; return !valueRequired;
} }
if (valueRequired && value.startsWith("-")) { if (valueRequired && value.startsWith("-")) {

View File

@ -110,7 +110,7 @@ public final class FFMpegHelper {
StringBuilder output = new StringBuilder(); StringBuilder output = new StringBuilder();
while (process.isAlive()) { while (process.isAlive()) {
String read = readProcess(processReader, spacer); String read = readProcess(processReader, spacer);
if (!read.equals("")) { if (!read.isEmpty()) {
if (write) { if (write) {
OutputUtil.println(read); OutputUtil.println(read);
} else { } else {
@ -339,7 +339,7 @@ public final class FFMpegHelper {
private static String readProcess(BufferedReader reader, String spacer) throws IOException { private static String readProcess(BufferedReader reader, String spacer) throws IOException {
String line; String line;
StringBuilder text = new StringBuilder(); 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); text.append(line).append(spacer);
} }
return text.toString().trim(); return text.toString().trim();

View File

@ -32,7 +32,7 @@ public final class OutputUtil {
* @throws IOException <p>If a write is not possible.</p> * @throws IOException <p>If a write is not possible.</p>
*/ */
public static void println(String input) throws IOException { public static void println(String input) throws IOException {
if (!input.equals("")) { if (!input.isEmpty()) {
writer.write(input); writer.write(input);
} }
println(); println();

View File

@ -193,7 +193,7 @@ public final class Parser {
* @return <p>True if the string builder is non empty.</p> * @return <p>True if the string builder is non empty.</p>
*/ */
private static boolean isNotEmpty(StringBuilder builder) { private static boolean isNotEmpty(StringBuilder builder) {
return !builder.toString().trim().equals(""); return !builder.toString().trim().isEmpty();
} }
} }

View File

@ -1,9 +1,6 @@
package net.knarcraft.ffmpegconverter.converter; package net.knarcraft.ffmpegconverter.converter;
import org.junit.Before; import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class AnimeConverterTest { public class AnimeConverterTest {
@ -14,9 +11,4 @@ public class AnimeConverterTest {
false, -1, -1, ""); false, -1, -1, "");
} }
@Test
public void weirdTest() {
assertEquals(0, 0);
}
} }