From d8f2360119b30bd3f65e60baa022e0457176cec9 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 24 Feb 2014 17:36:33 +0100 Subject: [PATCH] Fix some quality flaws --- .../scan/filesystem/DefaultModuleFileSystem.java | 14 +++++++------- .../api/batch/fs/internal/DefaultFileSystem.java | 8 -------- .../org/sonar/api/server/rule/RuleDefinitions.java | 4 ++-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java index 7cbc39852b5..bba59b6e247 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java @@ -235,7 +235,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return FilePredicates.hasType(org.sonar.api.batch.fs.InputFile.Type.valueOf(s)); + return s == null ? FilePredicates.all() : FilePredicates.hasType(org.sonar.api.batch.fs.InputFile.Type.valueOf(s)); } })); } @@ -243,7 +243,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return FilePredicates.hasStatus(org.sonar.api.batch.fs.InputFile.Status.valueOf(s)); + return s == null ? FilePredicates.all() : FilePredicates.hasStatus(org.sonar.api.batch.fs.InputFile.Status.valueOf(s)); } })); } @@ -251,7 +251,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return FilePredicates.hasLanguage(s); + return s == null ? FilePredicates.all() : FilePredicates.hasLanguage(s); } })); } @@ -259,7 +259,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return new FilePredicateAdapters.KeyPredicate(s); + return s == null ? FilePredicates.all() : new FilePredicateAdapters.KeyPredicate(s); } })); } @@ -267,7 +267,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return new FilePredicateAdapters.DeprecatedKeyPredicate(s); + return s == null ? FilePredicates.all() : new FilePredicateAdapters.DeprecatedKeyPredicate(s); } })); } @@ -275,7 +275,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return new FilePredicateAdapters.SourceRelativePathPredicate(s); + return s == null ? FilePredicates.all() : new FilePredicateAdapters.SourceRelativePathPredicate(s); } })); } @@ -283,7 +283,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module return FilePredicates.or(Collections2.transform(value, new Function() { @Override public FilePredicate apply(@Nullable String s) { - return new FilePredicateAdapters.SourceDirPredicate(s); + return s == null ? FilePredicates.all() : new FilePredicateAdapters.SourceDirPredicate(s); } })); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java index 6a21a8d6c15..c78be2ea246 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java @@ -66,11 +66,7 @@ public class DefaultFileSystem implements FileSystem { return this; } - /** - * Marked as nullable only for the tests that do not call {@link #setBaseDir(java.io.File)} - */ @Override - @CheckForNull public File baseDir() { return baseDir; } @@ -98,11 +94,7 @@ public class DefaultFileSystem implements FileSystem { return this; } - /** - * Marked as nullable only for the tests that do not call {@link #setWorkDir(java.io.File)} - */ @Override - @CheckForNull public File workDir() { return workDir; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java index 8eeb31be412..596982289ba 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java @@ -322,7 +322,7 @@ public interface RuleDefinitions extends ServerExtension { return this.key; } - public NewRule setName(String s) { + public NewRule setName(@Nullable String s) { this.name = StringUtils.trim(s); return this; } @@ -353,7 +353,7 @@ public interface RuleDefinitions extends ServerExtension { try { setHtmlDescription(IOUtils.toString(classpathUrl)); } catch (IOException e) { - throw new IllegalStateException("Fail to read: " + classpathUrl); + throw new IllegalStateException("Fail to read: " + classpathUrl, e); } } else { this.htmlDescription = null; -- 2.39.5