refactor: fix several issues reported by sonar
This commit is contained in:
@@ -91,12 +91,7 @@ public class ConstStorage {
|
||||
}
|
||||
|
||||
private ValueStorage getClsValues(ClassNode cls) {
|
||||
ValueStorage classValues = classes.get(cls);
|
||||
if (classValues == null) {
|
||||
classValues = new ValueStorage();
|
||||
classes.put(cls, classValues);
|
||||
}
|
||||
return classValues;
|
||||
return classes.computeIfAbsent(cls, c -> new ValueStorage());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
import static jadx.core.utils.files.FileUtils.close;
|
||||
|
||||
/**
|
||||
* Simple template engine
|
||||
* Syntax for replace variable with value: '{{variable}}'
|
||||
@@ -56,21 +54,15 @@ public class TemplateFile {
|
||||
}
|
||||
|
||||
public String build() throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try {
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
process(out);
|
||||
} finally {
|
||||
close(out);
|
||||
return out.toString();
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public void save(File outFile) throws IOException {
|
||||
OutputStream out = new FileOutputStream(outFile);
|
||||
try {
|
||||
try (OutputStream out = new FileOutputStream(outFile)) {
|
||||
process(out);
|
||||
} finally {
|
||||
close(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -92,9 +93,8 @@ public class FileUtils {
|
||||
}
|
||||
|
||||
public static void deleteDir(Path dir) {
|
||||
try {
|
||||
Files.walk(dir)
|
||||
.sorted(Comparator.reverseOrder())
|
||||
try (Stream<Path> pathStream = Files.walk(dir)) {
|
||||
pathStream.sorted(Comparator.reverseOrder())
|
||||
.map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user