force PMD v7

PMD v7: fix new design/SimplifyBooleanReturns matches
PMD v7: fix new bestpractices/UnusedAssignment matches
PMD v7: fix new bestpractices/LiteralsFirstInComparisons matches
PMD v7: fix new codestyle/UnnecessaryFullyQualifiedName matches
PMD v7: fix new bestpractices/LooseCoupling matches
PMD rules: bestpractices/UseVarargs
PMD rules: sort lines
This commit is contained in:
M*C*O
2024-06-10 16:34:12 +00:00
committed by Laurent Clouet
parent 46f893327d
commit 48f3761656
17 changed files with 121 additions and 122 deletions

View File

@@ -64,6 +64,7 @@ jar {
}
pmd {
toolVersion = "7.2.0"
ignoreFailures = false
ruleSetFiles = files("rulesets/java-sheepit.xml")
ruleSets = []

View File

@@ -9,21 +9,39 @@
SheepIt client custom rules
</description>
<rule ref="category/java/bestpractices.xml/UnusedAssignment" />
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly" />
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" />
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration" />
<rule ref="category/java/bestpractices.xml/AccessorMethodGeneration" />
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly" />
<rule ref="category/java/bestpractices.xml/AvoidMessageDigestField" />
<rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables" />
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField" />
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" />
<rule ref="category/java/bestpractices.xml/CheckResultSet" />
<rule ref="category/java/bestpractices.xml/MissingOverride" />
<rule ref="category/java/bestpractices.xml/ConstantsInInterface" />
<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization" />
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
<rule ref="category/java/bestpractices.xml/ForLoopVariableCount" />
<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert" />
<rule ref="category/java/bestpractices.xml/JUnitUseExpected" />
<rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons" />
<rule ref="category/java/bestpractices.xml/LooseCoupling" />
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" />
<rule ref="category/java/bestpractices.xml/MissingOverride" />
<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine" />
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator" />
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" />
<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion" />
<rule ref="category/java/bestpractices.xml/UnusedAssignment" />
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter" />
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty" />
<rule ref="category/java/bestpractices.xml/LooseCoupling" />
<rule ref="category/java/bestpractices.xml/UseStandardCharsets" />
<rule ref="category/java/bestpractices.xml/UseVarargs" />
<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean" />
<rule ref="category/java/codestyle.xml/ExtendsObject" />
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" />
<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
@@ -32,40 +50,83 @@
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon" />
<rule ref="category/java/codestyle.xml/UselessQualifiedThis" />
<rule ref="category/java/design.xml/SimplifiedTernary" />
<rule ref="category/java/design.xml/UselessOverridingMethod" />
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod" />
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" />
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
<rule ref="category/java/design.xml/ExcessivePublicCount" />
<rule ref="category/java/design.xml/InvalidJavaBean" />
<rule ref="category/java/design.xml/LogicInversion" />
<rule ref="category/java/design.xml/SimplifiedTernary" />
<rule ref="category/java/design.xml/SimplifyBooleanReturns" />
<rule ref="category/java/design.xml/SimplifyConditional" />
<rule ref="category/java/design.xml/UselessOverridingMethod" />
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic" />
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier" />
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize" />
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable" />
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier" />
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingTypeName" />
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation" />
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" />
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" />
<rule ref="category/java/errorprone.xml/BrokenNullCheck" />
<rule ref="category/java/errorprone.xml/CallSuperFirst" />
<rule ref="category/java/errorprone.xml/CallSuperLast" />
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic" />
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable" />
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName" />
<rule ref="category/java/errorprone.xml/ComparisonWithNaN" />
<rule ref="category/java/errorprone.xml/DetachedTestCase" />
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable" />
<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard" />
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally" />
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
<rule ref="category/java/errorprone.xml/EmptyFinalizer" />
<rule ref="category/java/errorprone.xml/EqualsNull" />
<rule ref="category/java/errorprone.xml/FinalizeOverloaded" />
<rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected" />
<rule ref="category/java/errorprone.xml/IdempotentOperations" />
<rule ref="category/java/errorprone.xml/InstantiationToGetClass" />
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat" />
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
<rule ref="category/java/errorprone.xml/JUnitSpelling" />
<rule ref="category/java/errorprone.xml/JUnitStaticSuite" />
<rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass" />
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass" />
<rule ref="category/java/errorprone.xml/MoreThanOneLogger" />
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement" />
<rule ref="category/java/errorprone.xml/NonStaticInitializer" />
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />
<rule ref="category/java/errorprone.xml/ProperCloneImplementation" />
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" />
<rule ref="category/java/errorprone.xml/SingleMethodSingleton" />
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance" />
<rule ref="category/java/errorprone.xml/StaticEJBFieldShouldBeFinal" />
<rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar" />
<rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName" />
<rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName" />
<rule ref="category/java/errorprone.xml/SuspiciousOctalEscape" />
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases" />
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" />
<rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion" />
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange" />
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" />
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" />
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" />
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
<rule ref="category/java/performance.xml/UselessStringValueOf" />
<rule ref="category/java/security.xml/HardCodedCryptoKey" />
<rule ref="category/java/security.xml/InsecureCryptoIv" />
<rule ref="category/java/performance.xml/UseStringBufferLength" />
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration" />
<rule ref="category/java/bestpractices.xml/AccessorMethodGeneration" />
<rule ref="category/java/bestpractices.xml/AvoidMessageDigestField" />
<rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables" />
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField" />
<rule ref="category/java/bestpractices.xml/ConstantsInInterface" />
<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization" />
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
<rule ref="category/java/bestpractices.xml/ForLoopVariableCount" />
<rule ref="category/java/errorprone.xml/UseProperClassLoader" />
<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
<rule ref="category/java/multithreading.xml/AvoidUsingVolatile" />
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
<rule ref="category/java/multithreading.xml/UnsynchronizedStaticFormatter" />
<rule ref="category/java/performance.xml/AvoidArrayLoops" />
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse" />
<rule ref="category/java/performance.xml/InefficientEmptyStringCheck" />
<rule ref="category/java/performance.xml/InefficientStringBuffering" />
@@ -76,73 +137,10 @@
<rule ref="category/java/performance.xml/UseArrayListInsteadOfVector" />
<rule ref="category/java/performance.xml/UseArraysAsList" />
<rule ref="category/java/performance.xml/UseIOStreamsWithApacheCommonsFileItem" />
<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert" />
<rule ref="category/java/bestpractices.xml/JUnitUseExpected" />
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" />
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator" />
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" />
<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion" />
<rule ref="category/java/bestpractices.xml/UseStandardCharsets" />
<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean" />
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic" />
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier" />
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize" />
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable" />
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier" />
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingTypeName" />
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation" />
<rule ref="category/java/errorprone.xml/CallSuperFirst" />
<rule ref="category/java/errorprone.xml/CallSuperLast" />
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic" />
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable" />
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName" />
<rule ref="category/java/errorprone.xml/ComparisonWithNaN" />
<rule ref="category/java/errorprone.xml/DetachedTestCase" />
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable" />
<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard" />
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally" />
<rule ref="category/java/errorprone.xml/DontImportSun" />
<rule ref="category/java/errorprone.xml/EmptyFinalizer" />
<rule ref="category/java/errorprone.xml/EqualsNull" />
<rule ref="category/java/errorprone.xml/FinalizeOverloaded" />
<rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected" />
<rule ref="category/java/errorprone.xml/IdempotentOperations" />
<rule ref="category/java/errorprone.xml/InstantiationToGetClass" />
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat" />
<rule ref="category/java/errorprone.xml/JUnitSpelling" />
<rule ref="category/java/errorprone.xml/JUnitStaticSuite" />
<rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass" />
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass" />
<rule ref="category/java/errorprone.xml/MoreThanOneLogger" />
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement" />
<rule ref="category/java/errorprone.xml/NonStaticInitializer" />
<rule ref="category/java/errorprone.xml/ProperCloneImplementation" />
<rule ref="category/java/errorprone.xml/SingleMethodSingleton" />
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance" />
<rule ref="category/java/errorprone.xml/StaticEJBFieldShouldBeFinal" />
<rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar" />
<rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName" />
<rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName" />
<rule ref="category/java/errorprone.xml/SuspiciousOctalEscape" />
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases" />
<rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion" />
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange" />
<rule ref="category/java/errorprone.xml/UseProperClassLoader" />
<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
<rule ref="category/java/multithreading.xml/AvoidUsingVolatile" />
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
<rule ref="category/java/multithreading.xml/UnsynchronizedStaticFormatter" />
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod" />
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException" />
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />
<rule ref="category/java/design.xml/CouplingBetweenObjects" />
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
<rule ref="category/java/design.xml/ExcessivePublicCount" />
<rule ref="category/java/design.xml/InvalidJavaBean" />
<rule ref="category/java/design.xml/LogicInversion" />
<rule ref="category/java/design.xml/SimplifyBooleanReturns" />
<rule ref="category/java/design.xml/SimplifyConditional" />
<rule ref="category/java/performance.xml/UselessStringValueOf" />
<rule ref="category/java/performance.xml/UseStringBufferLength" />
<rule ref="category/java/security.xml/HardCodedCryptoKey" />
<rule ref="category/java/security.xml/InsecureCryptoIv" />
</ruleset>

View File

@@ -9,12 +9,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
public class ChunkInputStream extends InputStream {
@NonNull private final ArrayDeque<Path> chunkPaths;
@NonNull private final Deque<Path> chunkPaths;
@NonNull private BufferedInputStream currentStream;
/**

View File

@@ -619,7 +619,7 @@ import okhttp3.HttpUrl;
// Insert the info at the beginning of the error log
writer.write(logHeader.toString().getBytes());
Optional<ArrayList<String>> logs = this.log.getForCheckPoint(step);
Optional<List<String>> logs = this.log.getForCheckPoint(step);
if (logs.isPresent()) {
for (String line : logs.get()) {
writer.write(line.getBytes());
@@ -799,7 +799,7 @@ import okhttp3.HttpUrl;
int threads = Math.max(1, Math.min(total, 12)); // at least one thread, to avoid IllegalArgumentException if total = 0
ExecutorService executor = Executors.newFixedThreadPool(threads);
ArrayList<Callable<Error.Type>> tasks = new ArrayList<>();
List<Callable<Error.Type>> tasks = new ArrayList<>();
this.gui.getDownloadProgress().reset("Downloading project");
@@ -944,6 +944,7 @@ import okhttp3.HttpUrl;
return 0;
}
@SuppressWarnings("unused") // Suppress false positive about this.isValidatingJob - PMD rule cannot detect time-sensitive reads
protected Error.Type confirmJob(Job ajob, int checkpoint) {
String urlReal = String.format(LOCALE, "%s&rendertime=%d&preptime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getRenderDuration(), ajob.getProcessRender().getScenePrepDuration(),
ajob.getProcessRender().getPeakMemoryUsed());

View File

@@ -370,11 +370,11 @@ import lombok.Data;
* @return an ArrayList of Strings containing all logs of the FSHealth check
*/
public List<String> filesystemHealthCheck() {
ArrayList<String> logs = new ArrayList<>();
List<String> logs = new ArrayList<>();
String f = "FSHealth: ";
logs.add(f + "FilesystemHealthCheck started");
ArrayList<File> dirsToCheck = new ArrayList<>();
ArrayList<File> dirsChecked = new ArrayList<>();
List<File> dirsToCheck = new ArrayList<>();
List<File> dirsChecked = new ArrayList<>();
dirsToCheck.add(workingDirectory.getAbsoluteFile());
if (sharedDownloadsDirectory != null && dirsToCheck.contains(sharedDownloadsDirectory.getAbsoluteFile()) == false) {
dirsToCheck.add(sharedDownloadsDirectory.getAbsoluteFile());

View File

@@ -128,13 +128,13 @@ public class Error {
}
public static ServerCode fromInt(int val) {
ServerCode[] As = ServerCode.values();
ServerCode[] As = values();
for (ServerCode A : As) {
if (A.getValue() == val) {
return A;
}
}
return ServerCode.UNKNOWN;
return UNKNOWN;
}
}

View File

@@ -470,7 +470,7 @@ import java.util.regex.Pattern;
// Once the process is finished (either finished successfully or with an error) move back to
// base icon (isolated S with no progress bar)
gui.updateTrayIcon(Job.SHOW_BASE_ICON);
gui.updateTrayIcon(SHOW_BASE_ICON);
return Error.Type.RENDERER_OUT_OF_MEMORY;
}
@@ -494,7 +494,7 @@ import java.util.regex.Pattern;
}
// Put back base icon
gui.updateTrayIcon(Job.SHOW_BASE_ICON);
gui.updateTrayIcon(SHOW_BASE_ICON);
process.kill();
maybeCleanWorkingDir(error);
for (String logline : configuration.filesystemHealthCheck()) {
@@ -545,7 +545,7 @@ import java.util.regex.Pattern;
}
// Put back base icon
gui.updateTrayIcon(Job.SHOW_BASE_ICON);
gui.updateTrayIcon(SHOW_BASE_ICON);
log.debug("end of rendering");
@@ -714,7 +714,7 @@ import java.util.regex.Pattern;
}
private void updateRenderingStatus(String line, int progress) {
if (getUpdateRenderingStatusMethod() == null || getUpdateRenderingStatusMethod().equals(Job.UPDATE_METHOD_BY_REMAINING_TIME)) {
if (getUpdateRenderingStatusMethod() == null || UPDATE_METHOD_BY_REMAINING_TIME.equals(getUpdateRenderingStatusMethod())) {
String search_remaining = "remaining:";
int index = line.toLowerCase().indexOf(search_remaining);
if (index != -1) {
@@ -760,7 +760,7 @@ import java.util.regex.Pattern;
}
}
}
else if (Job.UPDATE_METHOD_BY_TILE.equals(getUpdateRenderingStatusMethod())) {
else if (UPDATE_METHOD_BY_TILE.equals(getUpdateRenderingStatusMethod())) {
String search = " Tile ";
int index = line.lastIndexOf(search);
if (index != -1) {

View File

@@ -29,6 +29,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -39,7 +40,7 @@ public final class Log {
private static Log instance = null;
private Map<Integer, ArrayList<String>> checkpoints = new HashMap<Integer, ArrayList<String>>();
private Map<Integer, List<String>> checkpoints = new HashMap<>();
private int lastCheckPoint;
private DateFormat dateFormat;
@@ -120,7 +121,7 @@ public final class Log {
return this.lastCheckPoint;
}
public Optional<ArrayList<String>> getForCheckPoint(int point_) {
public Optional<List<String>> getForCheckPoint(int point_) {
return Optional.ofNullable(this.checkpoints.get(point_));
}
@@ -149,8 +150,8 @@ public final class Log {
}
public static synchronized void printCheckPoint(int point_) {
Log log = Log.getInstance(null);
Optional<ArrayList<String>> logs = log.getForCheckPoint(point_);
Log log = getInstance(null);
Optional<List<String>> logs = log.getForCheckPoint(point_);
if (logs.isPresent()) {
for (String alog : logs.get()) {
System.out.println(alog);

View File

@@ -178,7 +178,7 @@ public class Server extends Thread {
}
}
try {
Thread.sleep(60 * 1000); // 1min
sleep(60 * 1000); // 1min
}
catch (InterruptedException e) {
return;

View File

@@ -502,7 +502,7 @@ public class SettingsLoader {
if (device != null) {
config.setGPUDevice(device);
}
else if (config.getUIType() != null && (config.getUIType().equals(GuiText.type) || config.getUIType().equals(GuiTextOneLine.type))) {
else if (config.getUIType() != null && (GuiText.type.equals(config.getUIType()) || GuiTextOneLine.type.equals(config.getUIType()))) {
System.err.println("SettingsLoader::merge could not find specified GPU");
System.exit(2);
}
@@ -533,7 +533,7 @@ public class SettingsLoader {
}
if (config.getTheme() == null) {
if (this.theme != null && (this.theme.getValue().equals("dark") || this.theme.getValue().equals("light"))) {
if (this.theme != null && ("dark".equals(this.theme.getValue()) || "light".equals(this.theme.getValue()))) {
config.setTheme(this.theme.getValue());
}
else {
@@ -547,7 +547,7 @@ public class SettingsLoader {
// if the user has invoked the app with --no-systray, then we just overwrite the existing configuration with (boolean)false. If no parameter has been
// specified and the settings file contains use-systray=false, then deactivate as well.
if (!config.isUseSysTray() || (config.isUseSysTray() && useSysTray != null && useSysTray.getValue().equals("false"))) {
if (!config.isUseSysTray() || (config.isUseSysTray() && useSysTray != null && "false".equals(useSysTray.getValue()))) {
config.setUseSysTray(false);
}

View File

@@ -331,7 +331,7 @@ public class Utils {
mimeType = URLConnection.guessContentTypeFromName(file);
}
if (mimeType == null || (mimeType.equals("image/aces") && file.toLowerCase().endsWith(".exr"))) {
if (mimeType == null || ("image/aces".equals(mimeType) && file.toLowerCase().endsWith(".exr"))) {
try {
String extension = file.substring(file.lastIndexOf('.'));
mimeType = mimeTypes.get(extension);

View File

@@ -68,12 +68,8 @@ public class GPU {
public static boolean hasHIPDevices() {
OS os = OS.getOS();
if (os instanceof Windows) { // for now we only allow AMD on Windows
return HIP.hasHIPDevices();
}
else {
return false;
}
// for now we only allow AMD on Windows
return os instanceof Windows && HIP.hasHIPDevices();
}
public static GPUDevice getGPUDevice(String deviceId) {

View File

@@ -164,7 +164,7 @@ public class WinProcess {
}
private List<WinProcess> getChildren() throws IOException {
ArrayList<WinProcess> result = new ArrayList<WinProcess>();
List<WinProcess> result = new ArrayList<>();
WinNT.HANDLE hSnap = this.kernel32lib.CreateToolhelp32Snapshot(Kernel32Lib.TH32CS_SNAPPROCESS, new DWORD(0));
Kernel32Lib.PROCESSENTRY32.ByReference ent = new Kernel32Lib.PROCESSENTRY32.ByReference();

View File

@@ -193,7 +193,7 @@ public class GuiSwing extends JFrame implements Gui {
setTitle(title);
setSize(WIDTH, 760);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setDefaultCloseOperation(EXIT_ON_CLOSE);
panel = new JPanel();
panel.setLayout(new GridBagLayout());
@@ -406,7 +406,7 @@ public class GuiSwing extends JFrame implements Gui {
if (sysTray != null && SystemTray.isSupported()) {
sysTray.remove(trayIcon);
setVisible(true);
setExtendedState(getExtendedState() & ~JFrame.ICONIFIED & JFrame.NORMAL); // for toFront and requestFocus to actually work
setExtendedState(getExtendedState() & ~ICONIFIED & NORMAL); // for toFront and requestFocus to actually work
toFront();
requestFocus();
}

View File

@@ -127,7 +127,7 @@ public class Worker {
new Worker().doMain(args);
}
public void doMain(String[] args) {
public void doMain(String... args) {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);

View File

@@ -28,6 +28,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
@@ -357,7 +358,7 @@ public class Settings implements Activity {
step += 1000000;
display = (double) all_ram / (double) step;
}
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
Dictionary<Integer, JLabel> labelTable = new Hashtable<>();
for (int g = 0; g < all_ram; g += step) {
labelTable.put(g, new JLabel("" + (g / 1000000)));
}
@@ -395,7 +396,7 @@ public class Settings implements Activity {
// -19 is highest priority
boolean high_priority_support = os.isHighPrioritySupported();
priority = new JSlider(high_priority_support ? -19 : 0, 19);
Hashtable<Integer, JLabel> labelTablePriority = new Hashtable<>();
Dictionary<Integer, JLabel> labelTablePriority = new Hashtable<>();
labelTablePriority.put(high_priority_support ? -19 : 0, new JLabel("Low"));
labelTablePriority.put(19, new JLabel("High"));
priority.setLabelTable(labelTablePriority);

View File

@@ -45,7 +45,7 @@ public class CLIInputObserver implements Runnable {
in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while ((line != null) && (line.equalsIgnoreCase("quit") == false)) {
while ((line != null) && ("quit".equalsIgnoreCase(line) == false)) {
try {
line = in.readLine();
}