Code smell reduction (#2554)

* Correct use of <> diamond operator

* Correct modifiers order

* Private constructor for utility class

* Correct use of diamond operator

* Corrected naming convention

* Correct modifier order

* Use not synchronized class

* Introduced try/resource in stream copy

* Removed unused private field

* Code reformat

Reformat of IOUtils.copy from to stream

* Add a space

Improved code formatting

* Code reformat

Only a new space

* Code reformat

Removed extra spaces
This commit is contained in:
Matteo Baccan
2021-04-14 12:31:32 +02:00
committed by GitHub
parent baf8bb592a
commit b3741409f5
7 changed files with 29 additions and 24 deletions

View File

@ -19,7 +19,7 @@ package brut.util;
import java.io.DataInput;
import java.io.IOException;
abstract public class DataInputDelegate implements DataInput {
public abstract class DataInputDelegate implements DataInput {
protected final DataInput mDelegate;
public DataInputDelegate(DataInput delegate) {

View File

@ -21,14 +21,11 @@ import org.apache.commons.io.IOUtils;
import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
abstract public class Jar {
private final static Set<String> mLoaded = new HashSet<String>();
private final static Map<String, File> mExtracted = new HashMap<String, File>();
public abstract class Jar {
private static final Map<String, File> mExtracted = new HashMap<>();
public static File getResourceAsFile(String name, Class clazz) throws BrutException {
File file = mExtracted.get(name);

View File

@ -72,11 +72,11 @@ public class OS {
continue;
}
try {
InputStream in = new FileInputStream(file);
OutputStream out = new FileOutputStream(destFile);
IOUtils.copy(in, out);
in.close();
out.close();
try (InputStream in = new FileInputStream(file)) {
try (OutputStream out = new FileOutputStream(destFile)) {
IOUtils.copy(in, out);
}
}
} catch (IOException ex) {
throw new BrutException("Could not copy file: " + file, ex);
}
@ -173,7 +173,7 @@ public class OS {
}
static class StreamCollector implements Runnable {
private final StringBuffer buffer = new StringBuffer();
private final StringBuilder buffer = new StringBuilder();
private final InputStream inputStream;
public StreamCollector(InputStream inputStream) {

View File

@ -17,8 +17,8 @@
package brut.util;
public class OSDetection {
private static String OS = System.getProperty("os.name").toLowerCase();
private static String Bit = System.getProperty("sun.arch.data.model").toLowerCase();
private static final String OS = System.getProperty("os.name").toLowerCase();
private static final String BIT = System.getProperty("sun.arch.data.model").toLowerCase();
public static boolean isWindows() {
return (OS.contains("win"));
@ -39,7 +39,7 @@ public class OSDetection {
return arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64");
}
return Bit.equalsIgnoreCase("64");
return BIT.equalsIgnoreCase("64");
}
public static String returnOS() {