Merge branch 'pmd/new-rule' into 'master'
Ref: add new static analyser rule: bestpractices.xml/UnusedAssignment See merge request sheepitrenderfarm/client!313
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
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/AvoidUsingHardCodedIP" />
|
||||
|
||||
@@ -163,7 +163,7 @@ import java.util.regex.Pattern;
|
||||
gui.status("Rendering");
|
||||
RenderProcess process = getProcessRender();
|
||||
Timer timerOfMaxRenderTime = null;
|
||||
String core_script = "";
|
||||
String core_script;
|
||||
// When sending Ctrl+C to the terminal it also get's sent to all subprocesses e.g. also the render process.
|
||||
// The java program handles Ctrl+C but the renderer quits on Ctrl+C.
|
||||
// This script causes the renderer to ignore Ctrl+C.
|
||||
|
||||
@@ -85,13 +85,12 @@ public class Log {
|
||||
if (LEVEL_DEBUG.equals(level_) && this.debugLevel == false) {
|
||||
return;
|
||||
}
|
||||
String line = null;
|
||||
|
||||
try {
|
||||
int checkpointToWrite = (point_ > 0 ? point_ : this.lastCheckPoint);
|
||||
|
||||
if (msg_.equals("") == false) {
|
||||
line = this.dateFormat.format(new Date()) + " (" + level_ + ") " + msg_;
|
||||
String line = this.dateFormat.format(new Date()) + " (" + level_ + ") " + msg_;
|
||||
if (this.checkpoints.containsKey(checkpointToWrite) && this.checkpoints.get(checkpointToWrite) != null) {
|
||||
this.checkpoints.get(checkpointToWrite).add(line);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class Server extends Thread {
|
||||
|
||||
public Error.Type getConfiguration() {
|
||||
OS os = OS.getOS();
|
||||
String publickey = null;
|
||||
String publickey;
|
||||
try {
|
||||
HttpUrl.Builder remoteURL = Objects.requireNonNull(HttpUrl.parse(this.base_url + "/server/config.php")).newBuilder();
|
||||
FormBody formBody = new FormBody.Builder()
|
||||
@@ -240,12 +240,9 @@ public class Server extends Thread {
|
||||
if (ServerCode.fromInt(serverConfig.getStatus()) != ServerCode.OK) {
|
||||
return Error.ServerCodeToType(ServerCode.fromInt(serverConfig.getStatus()));
|
||||
}
|
||||
|
||||
|
||||
publickey = serverConfig.getPublickey();
|
||||
if (publickey.isEmpty()) {
|
||||
publickey = null;
|
||||
}
|
||||
else {
|
||||
if (publickey.isEmpty() == false) {
|
||||
this.user_config.setPassword(publickey);
|
||||
}
|
||||
}
|
||||
@@ -442,12 +439,11 @@ public class Server extends Thread {
|
||||
}
|
||||
|
||||
Request request = builder.build();
|
||||
Response response = null;
|
||||
|
||||
try {
|
||||
response = httpClient.newCall(request).execute();
|
||||
Response response = httpClient.newCall(request).execute();
|
||||
|
||||
if (!response.isSuccessful()) {
|
||||
if (response.isSuccessful() == false) {
|
||||
this.log.error("Received unsuccessful HTTP response " + response);
|
||||
}
|
||||
|
||||
@@ -470,10 +466,9 @@ public class Server extends Thread {
|
||||
}
|
||||
|
||||
Request request = builder.build();
|
||||
Response response = null;
|
||||
|
||||
|
||||
try {
|
||||
response = httpClient.newCall(request).execute();
|
||||
Response response = httpClient.newCall(request).execute();
|
||||
|
||||
if (checkIsSuccessful && !response.isSuccessful()) {
|
||||
throw new IOException("Unexpected code " + response);
|
||||
@@ -509,7 +504,7 @@ public class Server extends Thread {
|
||||
long size = response.body().contentLength();
|
||||
// only update the gui every 1MB
|
||||
byte[] buffer = new byte[1024 * 1024];
|
||||
int len = 0;
|
||||
int len;
|
||||
long written = 0;
|
||||
|
||||
if (size != -1) {
|
||||
|
||||
@@ -256,9 +256,8 @@ public class SettingsLoader {
|
||||
|
||||
Properties configFileProp = new Properties();
|
||||
if (new File(path).exists()) {
|
||||
InputStream input = null;
|
||||
try {
|
||||
input = new FileInputStream(path);
|
||||
InputStream input = new FileInputStream(path);
|
||||
configFileProp.load(input);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Utils {
|
||||
if (password != null) {
|
||||
zipInputStream.setPassword(password);
|
||||
}
|
||||
LocalFileHeader fileHeader = null;
|
||||
LocalFileHeader fileHeader;
|
||||
while ((fileHeader = zipInputStream.getNextEntry()) != null) {
|
||||
String outFilePath = destinationDirectory + File.separator + fileHeader.getFileName();
|
||||
File outFile = new File(outFilePath);
|
||||
@@ -130,7 +130,7 @@ public class Utils {
|
||||
|
||||
FileOutputStream os = new FileOutputStream(outFile);
|
||||
|
||||
int readLen = -1;
|
||||
int readLen;
|
||||
byte[] buff = new byte[1024];
|
||||
|
||||
//Loop until End of File and write the contents to the output stream
|
||||
@@ -354,8 +354,8 @@ public class Utils {
|
||||
* Examples: 4,20GB, 20,00TB, 3,69MB
|
||||
*/
|
||||
public static String formatDataConsumption(long bytes) {
|
||||
float divider = 0;
|
||||
String suffix = "";
|
||||
float divider;
|
||||
String suffix;
|
||||
|
||||
if (bytes > 1099511627776f) { // 1TB
|
||||
divider = 1099511627776f;
|
||||
|
||||
@@ -164,7 +164,7 @@ public class Nvidia implements GPULister {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
CUDA cudalib = null;
|
||||
CUDA cudalib;
|
||||
try {
|
||||
cudalib = (CUDA) Native.load(path, CUDA.class);
|
||||
}
|
||||
@@ -180,9 +180,7 @@ public class Nvidia implements GPULister {
|
||||
return null;
|
||||
}
|
||||
|
||||
int result = CUresult.CUDA_ERROR_UNKNOWN;
|
||||
|
||||
result = cudalib.cuInit(0);
|
||||
int result = cudalib.cuInit(0);
|
||||
if (result != CUresult.CUDA_SUCCESS) {
|
||||
System.out.println("Nvidia::getGpus cuInit failed: " + getCudaErrorString(result) + " (" + result + ")");
|
||||
if (result == CUresult.CUDA_ERROR_UNKNOWN) {
|
||||
@@ -269,7 +267,7 @@ public class Nvidia implements GPULister {
|
||||
return null;
|
||||
}
|
||||
|
||||
NVML nvml = null;
|
||||
NVML nvml;
|
||||
try {
|
||||
nvml = Native.load(os.getNVMLLib(), NVML.class);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,8 @@ public class Windows extends OS {
|
||||
|
||||
@Override public Process exec(List<String> command, Map<String, String> env) throws IOException {
|
||||
// disable a popup because the renderer might crash (seg fault)
|
||||
Kernel32Lib kernel32lib = null;
|
||||
try {
|
||||
kernel32lib = (Kernel32Lib) Native.load(Kernel32Lib.path, Kernel32Lib.class);
|
||||
Kernel32Lib kernel32lib = (Kernel32Lib) Native.load(Kernel32Lib.path, Kernel32Lib.class);
|
||||
kernel32lib.SetErrorMode(Kernel32Lib.SEM_NOGPFAULTERRORBOX);
|
||||
}
|
||||
catch (UnsatisfiedLinkError e) {
|
||||
|
||||
Reference in New Issue
Block a user