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>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -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();
}

View File

@ -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;

View File

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

View File

@ -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();

View File

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

View File

@ -193,7 +193,7 @@ public final class Parser {
* @return <p>True if the string builder is non empty.</p>
*/
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;
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);
}
}