diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2018-07-30 17:34:02 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-08-02 20:21:36 +0200 |
commit | bc7274cb5f1293f968e42d42abbb8940f1ff96a7 (patch) | |
tree | 7b93996f1713b1131500bf3f95db17e72561b6a0 /sonar-core | |
parent | 7218f5f2817a78f1447b098a3bd4b998c1e4584a (diff) | |
download | sonarqube-bc7274cb5f1293f968e42d42abbb8940f1ff96a7.tar.gz sonarqube-bc7274cb5f1293f968e42d42abbb8940f1ff96a7.zip |
Fix Quality flaws
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/util/FileUtils.java | 23 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/util/FileUtilsTest.java | 7 |
2 files changed, 8 insertions, 22 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java b/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java index 5b91a8055f3..85d55a3b1cd 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java +++ b/sonar-core/src/main/java/org/sonar/core/util/FileUtils.java @@ -50,7 +50,7 @@ public final class FileUtils { /** * Deletes a directory recursively. * - * @param directory directory to delete + * @param directory directory to delete * @throws IOException in case deletion is unsuccessful */ public static void deleteDirectory(File directory) throws IOException { @@ -61,7 +61,7 @@ public final class FileUtils { /** * Deletes a directory recursively. * - * @param directory directory to delete + * @param directory directory to delete * @throws IOException in case deletion is unsuccessful */ public static void deleteDirectory(Path directory) throws IOException { @@ -72,7 +72,7 @@ public final class FileUtils { /** * Cleans a directory recursively. * - * @param directory directory to delete + * @param directory directory to delete * @throws IOException in case deletion is unsuccessful */ public static void cleanDirectory(File directory) throws IOException { @@ -95,7 +95,7 @@ public final class FileUtils { * <li>No exceptions are thrown when a file or directory cannot be deleted.</li> * </ul> * - * @param file file or directory to delete, can be {@code null} + * @param file file or directory to delete, can be {@code null} * @return {@code true} if the file or directory was deleted, otherwise {@code false} */ public static boolean deleteQuietly(@Nullable File file) { @@ -114,7 +114,7 @@ public final class FileUtils { * <li>No exceptions are thrown when a file or directory cannot be deleted.</li> * </ul> * - * @param file file or directory to delete, can be {@code null} + * @param path file or directory to delete, can be {@code null} * @return {@code true} if the file or directory was deleted, otherwise {@code false} */ public static boolean deleteQuietly(@Nullable Path path) { @@ -123,7 +123,7 @@ public final class FileUtils { } try { - if (Files.isDirectory(path)) { + if (path.toFile().isDirectory()) { deleteDirectory(path); } else { Files.delete(path); @@ -160,13 +160,6 @@ public final class FileUtils { checkIO(!file.exists(), "Unable to delete directory '%s'", path); } - - - public static Path getPack200FilePath(Path jarFilePath) { - String jarFileName = jarFilePath.getFileName().toString(); - String filename = jarFileName.substring(0, jarFileName.length() - 3) + "pack.gz"; - return jarFilePath.resolveSibling(filename); - } /** * This visitor is intended to be used to visit direct children of directory <strong>or a symLink to a directory</strong>, @@ -174,12 +167,12 @@ public final class FileUtils { * or recursively deleted (if directory). */ private static class CleanDirectoryFileVisitor extends SimpleFileVisitor<Path> { - public static final int VISIT_MAX_DEPTH = 1; + private static final int VISIT_MAX_DEPTH = 1; private final Path path; private final boolean symLink; - public CleanDirectoryFileVisitor(Path path) { + private CleanDirectoryFileVisitor(Path path) { this.path = path; this.symLink = Files.isSymbolicLink(path); } diff --git a/sonar-core/src/test/java/org/sonar/core/util/FileUtilsTest.java b/sonar-core/src/test/java/org/sonar/core/util/FileUtilsTest.java index 258fda58408..bc47bfd9618 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/FileUtilsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/FileUtilsTest.java @@ -23,7 +23,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import javax.annotation.CheckForNull; import org.apache.commons.lang.SystemUtils; @@ -239,12 +238,6 @@ public class FileUtilsTest { assertThat(childDir2).doesNotExist(); } - @Test - public void getPack200FilePath_transforms_jar_name() { - Path jarPath = Paths.get("plugin.jar"); - assertThat(FileUtils.getPack200FilePath(jarPath)).isEqualTo(Paths.get("plugin.pack.gz")); - } - private void expectDirectoryCanNotBeNullNPE() { expectedException.expect(NullPointerException.class); expectedException.expectMessage("Directory can not be null"); |