mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
fix some code smells reported by sonarqube
This commit is contained in:
@@ -61,7 +61,8 @@ class PathDatabase {
|
||||
|
||||
private void ensureParentDirectoryExists() {
|
||||
Path parent = storePath.getParent();
|
||||
if (!Files.exists(parent)) {
|
||||
// Files.exists is slow on java 8
|
||||
if (!parent.toFile().exists()) {
|
||||
try {
|
||||
Files.createDirectories(parent);
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -47,7 +47,6 @@ import sonia.scm.store.StoreConstants;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Clock;
|
||||
import java.util.Collection;
|
||||
@@ -98,7 +97,8 @@ public class XmlRepositoryDAO implements PathBasedRepositoryDAO {
|
||||
private void read() {
|
||||
Path storePath = createStorePath();
|
||||
|
||||
if (!Files.exists(storePath)) {
|
||||
// Files.exists is slow on java 8
|
||||
if (!storePath.toFile().exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
@@ -44,7 +45,7 @@ public final class XmlStreams {
|
||||
}
|
||||
|
||||
public static XMLStreamReader createReader(Path path) throws IOException, XMLStreamException {
|
||||
return createReader(Files.newBufferedReader(path, Charsets.UTF_8));
|
||||
return createReader(Files.newBufferedReader(path, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static XMLStreamReader createReader(File file) throws IOException, XMLStreamException {
|
||||
@@ -57,7 +58,7 @@ public final class XmlStreams {
|
||||
|
||||
|
||||
public static IndentXMLStreamWriter createWriter(Path path) throws IOException, XMLStreamException {
|
||||
return createWriter(Files.newBufferedWriter(path, Charsets.UTF_8));
|
||||
return createWriter(Files.newBufferedWriter(path, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static IndentXMLStreamWriter createWriter(File file) throws IOException, XMLStreamException {
|
||||
|
||||
Reference in New Issue
Block a user