diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-02 18:18:07 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-02 18:18:07 +0200 |
commit | 1f5682409af97410aca5e545ccbd40b6b037e6a9 (patch) | |
tree | ba9f1fe3c26d994b9aaafe9a09d5cf528fc21a41 | |
parent | 6e38de82d91aed63e200f0b45f54a4a2a7875941 (diff) | |
download | sonarqube-1f5682409af97410aca5e545ccbd40b6b037e6a9.tar.gz sonarqube-1f5682409af97410aca5e545ccbd40b6b037e6a9.zip |
Fix new violations
28 files changed, 86 insertions, 89 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java index 2fb74c374c5..7461fe4cc60 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java @@ -32,7 +32,6 @@ import org.sonar.api.BatchExtension; import org.sonar.api.CoreProperties; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Java; -import org.sonar.api.resources.Project; import org.sonar.api.resources.ProjectFileSystem; import org.sonar.api.utils.SonarException; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Locale; import java.util.Properties; - public class CheckstyleConfiguration implements BatchExtension { private static final Logger LOG = LoggerFactory.getLogger(CheckstyleConfiguration.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java index 529c42dd29a..bec5499851f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java @@ -55,7 +55,8 @@ public class CloseReviewsDecorator implements Decorator { private NotificationManager notificationManager; private UserFinder userFinder; - public CloseReviewsDecorator(Project project, ResourcePersister resourcePersister, DatabaseSession databaseSession, NotificationManager notificationManager, UserFinder userFinder) { + public CloseReviewsDecorator(Project project, ResourcePersister resourcePersister, DatabaseSession databaseSession, + NotificationManager notificationManager, UserFinder userFinder) { this.project = project; this.resourcePersister = resourcePersister; this.databaseSession = databaseSession; diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilter.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilter.java index 426d4b18fdb..430ac2087a2 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilter.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilter.java @@ -25,6 +25,6 @@ class KeepLibrarySnapshotFilter extends SnapshotFilter { @Override boolean filter(Snapshot snapshot) { - return snapshot.getQualifier().equals("LIB"); + return "LIB".equals(snapshot.getQualifier()); } } diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java index db6edd9f4a5..5ad431a5e2e 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java @@ -24,13 +24,13 @@ import org.sonar.api.rules.RulePriority; public class FindbugsLevelUtils { public RulePriority from(String priority) { - if (priority.equals("1")) { + if ("1".equals(priority)) { return RulePriority.BLOCKER; } - if (priority.equals("2")) { + if ("2".equals(priority)) { return RulePriority.MAJOR; } - if (priority.equals("3")) { + if ("3".equals(priority)) { return RulePriority.INFO; } throw new IllegalArgumentException("Priority not supported: " + priority); diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ClassVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ClassVisitor.java index 722e5809933..21253bd816f 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ClassVisitor.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ClassVisitor.java @@ -31,12 +31,12 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; public class ClassVisitor extends JavaAstVisitor { - public static final List<Integer> wantedTokens = Arrays.asList(TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.ENUM_DEF, + public static final List<Integer> WANTED_TOKENS = Arrays.asList(TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.ENUM_DEF, TokenTypes.ANNOTATION_DEF); @Override public List<Integer> getWantedTokens() { - return wantedTokens; + return WANTED_TOKENS; } @Override @@ -76,7 +76,7 @@ public class ClassVisitor extends JavaAstVisitor { static SourceClass createSourceClass(SourcePackage parentPackage, String className) { StringBuilder key = new StringBuilder(); - if (parentPackage != null && !parentPackage.getKey().equals("")) { + if (parentPackage != null && !"".equals(parentPackage.getKey())) { key.append(parentPackage.getKey()); key.append("/"); } diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/CommentVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/CommentVisitor.java index a5184ea34d9..9d013afd8e5 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/CommentVisitor.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/CommentVisitor.java @@ -30,11 +30,11 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; public class CommentVisitor extends JavaAstVisitor { - private static final List<Integer> wantedTokens = Arrays.asList(TokenTypes.RCURLY); + private static final List<Integer> WANTED_TOKENS = Arrays.asList(TokenTypes.RCURLY); @Override public List<Integer> getWantedTokens() { - return wantedTokens; + return WANTED_TOKENS; } @Override diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/FileVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/FileVisitor.java index 935a4f817e7..aba3b2834d4 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/FileVisitor.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/FileVisitor.java @@ -54,7 +54,7 @@ public class FileVisitor extends JavaAstVisitor { static SourceFile createSourceFile(SourcePackage parentPackage, String fileName) { StringBuilder key = new StringBuilder(); - if (parentPackage != null && !parentPackage.getKey().equals("")) { + if (parentPackage != null && !"".equals(parentPackage.getKey())) { key.append(parentPackage.getKey()); key.append("/"); } diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/JavaAstVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/JavaAstVisitor.java index 64d21c9a3d4..4d6911c2365 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/JavaAstVisitor.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/JavaAstVisitor.java @@ -19,7 +19,6 @@ */ package org.sonar.java.ast.visitor; -import com.google.common.collect.Lists; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FileContents; import org.sonar.api.resources.InputFile; @@ -29,6 +28,7 @@ import org.sonar.squid.api.SourceCode; import org.sonar.squid.api.SourcePackage; import org.sonar.squid.text.Source; +import java.util.Collections; import java.util.List; import java.util.Stack; @@ -42,8 +42,6 @@ public abstract class JavaAstVisitor implements CodeVisitor { private Source source; - private static final List<Integer> emptyWantedTokens = Lists.newArrayList(); - public final void setFileContents(FileContents fileContents) { this.fileContents = fileContents; } @@ -69,7 +67,7 @@ public abstract class JavaAstVisitor implements CodeVisitor { } public List<Integer> getWantedTokens() { - return emptyWantedTokens; + return Collections.emptyList(); } public final void setSourceCodeStack(Stack<SourceCode> sourceCodeStack) { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/LinesVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/LinesVisitor.java index b9f95bd0f00..444ecaa146c 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/LinesVisitor.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/LinesVisitor.java @@ -29,11 +29,11 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; public class LinesVisitor extends JavaAstVisitor { - private static final List<Integer> wantedTokens = Arrays.asList(TokenTypes.RCURLY); + private static final List<Integer> WANTED_TOKENS = Arrays.asList(TokenTypes.RCURLY); @Override public List<Integer> getWantedTokens() { - return wantedTokens; + return WANTED_TOKENS; } @Override diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/MethodVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/MethodVisitor.java index 20baa6befc7..e1e06833a5a 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/MethodVisitor.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/MethodVisitor.java @@ -19,11 +19,7 @@ */ package org.sonar.java.ast.visitor; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import org.sonar.java.signature.JvmJavaType; import org.sonar.java.signature.MethodSignature; @@ -41,24 +37,24 @@ public class MethodVisitor extends JavaAstVisitor { private static final String CONSTRUCTOR = "<init>"; - public static final List<Integer> wantedTokens = Arrays.asList(TokenTypes.CTOR_DEF, TokenTypes.METHOD_DEF); - private static final Map<Integer, JvmJavaType> tokenJavaTypeMapping = new HashMap<Integer, JvmJavaType>(); + public static final List<Integer> WANTED_TOKENS = Arrays.asList(TokenTypes.CTOR_DEF, TokenTypes.METHOD_DEF); + private static final Map<Integer, JvmJavaType> TOKEN_JAVA_TYPE_MAPPING = new HashMap<Integer, JvmJavaType>(); static { - tokenJavaTypeMapping.put(TokenTypes.LITERAL_BYTE, JvmJavaType.B); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_CHAR, JvmJavaType.C); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_SHORT, JvmJavaType.S); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_INT, JvmJavaType.I); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_LONG, JvmJavaType.J); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_BOOLEAN, JvmJavaType.Z); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_FLOAT, JvmJavaType.F); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_DOUBLE, JvmJavaType.D); - tokenJavaTypeMapping.put(TokenTypes.LITERAL_VOID, JvmJavaType.V); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_BYTE, JvmJavaType.B); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_CHAR, JvmJavaType.C); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_SHORT, JvmJavaType.S); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_INT, JvmJavaType.I); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_LONG, JvmJavaType.J); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_BOOLEAN, JvmJavaType.Z); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_FLOAT, JvmJavaType.F); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_DOUBLE, JvmJavaType.D); + TOKEN_JAVA_TYPE_MAPPING.put(TokenTypes.LITERAL_VOID, JvmJavaType.V); } @Override public List<Integer> getWantedTokens() { - return wantedTokens; + return WANTED_TOKENS; } @Override @@ -121,9 +117,9 @@ public class MethodVisitor extends JavaAstVisitor { private Parameter extractArgumentAndReturnType(DetailAST ast) { boolean isArray = isArrayType(ast); - for (Integer tokenType : tokenJavaTypeMapping.keySet()) { + for (Integer tokenType : TOKEN_JAVA_TYPE_MAPPING.keySet()) { if (ast.branchContains(tokenType)) { - return new Parameter(tokenJavaTypeMapping.get(tokenType), isArray); + return new Parameter(TOKEN_JAVA_TYPE_MAPPING.get(tokenType), isArray); } } if (isObjectType(ast)) { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmClass.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmClass.java index b61137b3428..5d4d752f112 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmClass.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmClass.java @@ -111,7 +111,7 @@ public final class AsmClass extends AsmResource { } private void addChildren(AsmClass asmClass) { - if (getInternalName().equals("java/lang/Object")) { + if ("java/lang/Object".equals(getInternalName())) { return; } if (children == null) { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmMethod.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmMethod.java index dbb29d6557f..bce75c3bd76 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmMethod.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/asm/AsmMethod.java @@ -108,11 +108,11 @@ public class AsmMethod extends AsmResource { } public boolean isConstructor() { - return name.equals("<init>") || name.equals("<clinit>"); + return "<init>".equals(name) || "<clinit>".equals(name); } public boolean isDefaultConstructor() { - return key.equals("<init>()V"); + return "<init>()V".equals(key); } void setInherited(boolean inherited) { @@ -153,7 +153,7 @@ public class AsmMethod extends AsmResource { } public boolean isStaticConstructor() { - return name.equals("<init>"); + return "<init>".equals(name); } public void linkTo(AsmMethod implementationLinkage) { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/signature/Parameter.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/signature/Parameter.java index b74a2e20c93..5e9c24d13ff 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/signature/Parameter.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/signature/Parameter.java @@ -34,7 +34,7 @@ public class Parameter { } Parameter(JvmJavaType jvmJavaType, String classCanonicalName, boolean isArray) { - if (jvmJavaType == JvmJavaType.L && (classCanonicalName == null || classCanonicalName.equals(""))) { + if (jvmJavaType == JvmJavaType.L && (classCanonicalName == null || "".equals(classCanonicalName))) { throw new IllegalStateException("With an Object JavaType, this is mandatory to specify the canonical name of the class."); } this.jvmJavaType = jvmJavaType; diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java index 55b92b57998..5e74b027b45 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java @@ -23,9 +23,6 @@ import org.apache.commons.configuration.*; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.database.DatabaseSession; -import org.sonar.api.resources.Project; - -import java.util.Properties; public class ProjectConfiguration extends CompositeConfiguration { private PropertiesConfiguration runtimeConfiguration; @@ -36,7 +33,7 @@ public class ProjectConfiguration extends CompositeConfiguration { public ProjectConfiguration(DatabaseSession session, ProjectReactor projectReactor) { this(session, projectReactor.getRoot()); } - + public ProjectConfiguration(DatabaseSession session, ProjectDefinition project) { runtimeConfiguration = new PropertiesConfiguration(); addConfiguration(runtimeConfiguration); diff --git a/sonar-batch/src/main/java/org/sonar/batch/events/EventBus.java b/sonar-batch/src/main/java/org/sonar/batch/events/EventBus.java index 34765b06315..8c84d849a8e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/events/EventBus.java +++ b/sonar-batch/src/main/java/org/sonar/batch/events/EventBus.java @@ -21,7 +21,6 @@ package org.sonar.batch.events; import com.google.common.collect.Lists; import org.sonar.api.batch.events.EventHandler; -import org.sonar.api.utils.Logs; import java.util.List; diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java index 9004a699a9f..9421f31da8d 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java @@ -36,7 +36,7 @@ import java.text.MessageFormat; import java.util.*; public class I18nManager implements I18n, ServerExtension { - private static Logger LOG = LoggerFactory.getLogger(I18nManager.class); + private static final Logger LOG = LoggerFactory.getLogger(I18nManager.class); public static final String ENGLISH_PACK_PLUGIN_KEY = "l10nen"; public static final String BUNDLE_PACKAGE = "org.sonar.l10n."; diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java index 6d681196c28..da1a374329a 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java @@ -28,6 +28,9 @@ import java.util.Locale; public class RuleI18nManager implements ServerComponent { + private static final String NAME_SUFFIX = ".name"; + private static final String RULE_PREFIX = "rule."; + private I18nManager i18nManager; private RuleKey[] ruleKeys; @@ -46,11 +49,11 @@ public class RuleI18nManager implements ServerComponent { } public String getName(String repositoryKey, String ruleKey, Locale locale) { - return message(repositoryKey, ruleKey, locale, ".name"); + return message(repositoryKey, ruleKey, locale, NAME_SUFFIX); } public String getDescription(String repositoryKey, String ruleKey, Locale locale) { - String relatedProperty = new StringBuilder().append("rule.").append(repositoryKey).append(".").append(ruleKey).append(".name").toString(); + String relatedProperty = new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(ruleKey).append(NAME_SUFFIX).toString(); // TODO add cache String description = i18nManager.messageFromFile(locale, ruleKey + ".html", relatedProperty); @@ -65,7 +68,7 @@ public class RuleI18nManager implements ServerComponent { } String message(String repositoryKey, String ruleKey, Locale locale, String suffix) { - String propertyKey = new StringBuilder().append("rule.").append(repositoryKey).append(".").append(ruleKey).append(suffix).toString(); + String propertyKey = new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(ruleKey).append(suffix).toString(); return i18nManager.message(locale, propertyKey, null); } @@ -85,14 +88,14 @@ public class RuleI18nManager implements ServerComponent { } static RuleKey extractRuleKey(String propertyKey) { - String s = StringUtils.substringBetween(propertyKey, "rule.", ".name"); + String s = StringUtils.substringBetween(propertyKey, RULE_PREFIX, NAME_SUFFIX); String ruleKey = StringUtils.substringAfter(s, "."); String repository = StringUtils.substringBefore(s, "."); return new RuleKey(repository, ruleKey); } static boolean isRuleProperty(String propertyKey) { - return StringUtils.startsWith(propertyKey, "rule.") && StringUtils.endsWith(propertyKey, ".name") && propertyKey.indexOf(".param.") < 0; + return StringUtils.startsWith(propertyKey, RULE_PREFIX) && StringUtils.endsWith(propertyKey, NAME_SUFFIX) && propertyKey.indexOf(".param.") < 0; } public static class RuleKey { @@ -113,19 +116,24 @@ public class RuleI18nManager implements ServerComponent { } public String getNameProperty() { - return new StringBuilder().append("rule.").append(repositoryKey).append(".").append(key).append(".name").toString(); + return new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(key).append(NAME_SUFFIX).toString(); } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } RuleKey ruleKey = (RuleKey) o; - - if (!key.equals(ruleKey.key)) return false; - if (!repositoryKey.equals(ruleKey.repositoryKey)) return false; - + if (!key.equals(ruleKey.key)) { + return false; + } + if (!repositoryKey.equals(ruleKey.repositoryKey)) { + return false; + } return true; } diff --git a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java index 36e263f1c4b..27d89ce073f 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java +++ b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java @@ -93,6 +93,7 @@ public class CycleDetector<V> { } } } catch (MaximumCyclesToFoundException e) { + // ignore } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java index f6dbdcd9f64..49d1bc892d8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java @@ -36,7 +36,7 @@ public final class SquidUtils { } String convertedKey = key.replace('/', '.'); - if (convertedKey.indexOf('.') == -1 && !convertedKey.equals("")) { + if (convertedKey.indexOf('.') == -1 && !"".equals(convertedKey)) { convertedKey = "[default]." + convertedKey; } else if (convertedKey.indexOf('.') == -1) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java index 7844a375578..ee5f98f872f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java @@ -104,22 +104,22 @@ public final class AnnotationCheckFactory extends CheckFactory { if (field.getType().equals(String.class)) { field.set(check, value); - } else if (field.getType().getSimpleName().equals("int")) { + } else if ("int".equals(field.getType().getSimpleName())) { field.setInt(check, Integer.parseInt(value)); - } else if (field.getType().getSimpleName().equals("short")) { + } else if ("short".equals(field.getType().getSimpleName())) { field.setShort(check, Short.parseShort(value)); - } else if (field.getType().getSimpleName().equals("long")) { + } else if ("long".equals(field.getType().getSimpleName())) { field.setLong(check, Long.parseLong(value)); - } else if (field.getType().getSimpleName().equals("double")) { + } else if ("double".equals(field.getType().getSimpleName())) { field.setDouble(check, Double.parseDouble(value)); - } else if (field.getType().getSimpleName().equals("boolean")) { + } else if ("boolean".equals(field.getType().getSimpleName())) { field.setBoolean(check, Boolean.parseBoolean(value)); - } else if (field.getType().getSimpleName().equals("byte")) { + } else if ("byte".equals(field.getType().getSimpleName())) { field.setByte(check, Byte.parseByte(value)); } else if (field.getType().equals(Integer.class)) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java index 4a072719622..c41d5a3684f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java @@ -34,23 +34,23 @@ public final class DateUtils { public static final String DATE_FORMAT = "yyyy-MM-dd"; public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; - private static final ThreadSafeDateFormat dateFormat = new ThreadSafeDateFormat(DATE_FORMAT); - private static final ThreadSafeDateFormat dateTimeFormat = new ThreadSafeDateFormat(DATETIME_FORMAT); + private static final ThreadSafeDateFormat THREAD_SAFE_DATE_FORMAT = new ThreadSafeDateFormat(DATE_FORMAT); + private static final ThreadSafeDateFormat THREAD_SAFE_DATETIME_FORMAT = new ThreadSafeDateFormat(DATETIME_FORMAT); private DateUtils() { } public static String formatDate(Date d) { - return dateFormat.format(d); + return THREAD_SAFE_DATE_FORMAT.format(d); } public static String formatDateTime(Date d) { - return dateTimeFormat.format(d); + return THREAD_SAFE_DATETIME_FORMAT.format(d); } public static Date parseDate(String s) { try { - return dateFormat.parse(s); + return THREAD_SAFE_DATE_FORMAT.parse(s); } catch (ParseException e) { throw new SonarException("The date '" + s + "' does not respect format '" + DATE_FORMAT + "'", e); @@ -59,7 +59,7 @@ public final class DateUtils { public static Date parseDateTime(String s) { try { - return dateTimeFormat.parse(s); + return THREAD_SAFE_DATETIME_FORMAT.parse(s); } catch (ParseException e) { throw new SonarException("The date '" + s + "' does not respect format '" + DATETIME_FORMAT + "'", e); diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java index d82f76cb8fd..2621a63d1d9 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java @@ -157,7 +157,7 @@ public class RulesBackup implements Backupable { while (reader.hasMoreChildren()) { reader.moveDown(); valuesRule.put(reader.getNodeName(), reader.getValue()); - if (reader.getNodeName().equals("params")) { + if ("params".equals(reader.getNodeName())) { while (reader.hasMoreChildren()) { reader.moveDown(); Map<String, String> valuesParam = readNode(reader); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java index 67ecb922744..8dc624f04bd 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java @@ -20,14 +20,15 @@ package org.sonar.server.ui; import com.google.common.collect.Maps; -import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ServerComponent; import org.sonar.api.i18n.I18n; import org.sonar.core.i18n.GwtI18n; import org.sonar.core.i18n.RuleI18nManager; -import java.util.*; +import java.util.List; +import java.util.Locale; +import java.util.Map; /** * Bridge between JRuby webapp and Java I18n component diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java index a755dfbf438..f2337bcdb7c 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java @@ -34,7 +34,7 @@ public class ManualMeasure extends Model { private Date createdAt; private Date updatedAt; private String userLogin; - private String userName; + private String username; public ManualMeasure() { } @@ -102,12 +102,12 @@ public class ManualMeasure extends Model { return this; } - public String getUserName() { - return userName; + public String getUsername() { + return username; } - public ManualMeasure setUserName(String userName) { - this.userName = userName; + public ManualMeasure setUsername(String username) { + this.username = username; return this; } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java index b4c55497a96..dfa4edd735f 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java @@ -22,7 +22,7 @@ package org.sonar.wsclient.services; /** * @since 2.10 */ -public class ManualMeasureCreateQuery extends CreateQuery<ManualMeasure> { +public final class ManualMeasureCreateQuery extends CreateQuery<ManualMeasure> { private String resourceKey; private String metricKey; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java index 1384eb9b6ce..74b3e591136 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java @@ -22,7 +22,7 @@ package org.sonar.wsclient.services; /** * @since 2.10 */ -public class ManualMeasureDeleteQuery extends DeleteQuery<ManualMeasure> { +public final class ManualMeasureDeleteQuery extends DeleteQuery<ManualMeasure> { private String resourceKey; private String metricKey; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java index f3b1a2d7bf8..c873491d5eb 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java @@ -37,7 +37,7 @@ public class ManualMeasureUnmarshaller extends AbstractUnmarshaller<ManualMeasur .setCreatedAt(utils.getDateTime(json, "created_at")) .setUpdatedAt(utils.getDateTime(json, "updated_at")) .setUserLogin(utils.getString(json, "login")) - .setUserName(utils.getString(json, "username")) + .setUsername(utils.getString(json, "username")) .setValue(utils.getDouble(json, "val")) .setTextValue(utils.getString(json, "text")) ; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java index cc6667bc4f9..dcd7b6c4150 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java @@ -21,9 +21,7 @@ package org.sonar.wsclient.unmarshallers; import org.junit.Test; import org.sonar.wsclient.services.ManualMeasure; -import org.sonar.wsclient.services.Metric; -import java.util.Collection; import java.util.List; import static org.hamcrest.CoreMatchers.nullValue; @@ -45,7 +43,7 @@ public class ManualMeasureUnmarshallerTest extends UnmarshallerTestCase { assertThat(measure.getResourceKey(), is("org.apache.struts:struts-parent")); assertThat(measure.getValue(), is(302.5)); assertThat(measure.getUserLogin(), is("admin")); - assertThat(measure.getUserName(), is("Administrator")); + assertThat(measure.getUsername(), is("Administrator")); assertThat(measure.getCreatedAt().getDate(), is(27)); assertThat(measure.getUpdatedAt().getDate(), is(3)); } |