diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-03-24 20:26:11 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-03-24 20:26:11 +0100 |
commit | f8090239d79037bd1d75a7576058c4da042c4070 (patch) | |
tree | c0aaae18a0fb03c5cb895f48dcf990bc24d69731 | |
parent | 891f9fe52635c0d9714d60fb99308c201bfa4108 (diff) | |
download | sonarqube-f8090239d79037bd1d75a7576058c4da042c4070.tar.gz sonarqube-f8090239d79037bd1d75a7576058c4da042c4070.zip |
Fix quality flaws
8 files changed, 13 insertions, 18 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java b/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java index 107dabad1aa..52c6aacbaac 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java @@ -20,7 +20,6 @@ package org.sonar.server.db; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.lang.StringUtils; import org.picocontainer.Startable; import org.sonar.api.config.Settings; import org.sonar.api.database.DatabaseProperties; diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java index f79c5b32e78..472c048246b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java @@ -28,6 +28,7 @@ import org.sonar.db.qualityprofile.ActiveRuleKey; import org.sonar.server.qualityprofile.ActiveRule; import org.sonar.server.search.BaseDoc; +import static org.apache.commons.lang.StringUtils.containsIgnoreCase; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_CREATED_AT; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE; import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_KEY; @@ -77,11 +78,11 @@ public class ActiveRuleDoc extends BaseDoc implements ActiveRule { public ActiveRule.Inheritance inheritance() { String inheritance = getNullableField(FIELD_ACTIVE_RULE_INHERITANCE); if (inheritance == null || inheritance.isEmpty() || - inheritance.toLowerCase().contains("none")) { + containsIgnoreCase(inheritance, "none")) { return Inheritance.NONE; - } else if (inheritance.toLowerCase().contains("herit")) { + } else if (containsIgnoreCase(inheritance, "herit")) { return Inheritance.INHERITED; - } else if (inheritance.toLowerCase().contains("over")) { + } else if (containsIgnoreCase(inheritance, "over")) { return Inheritance.OVERRIDES; } else { throw new IllegalStateException("Value \"" + inheritance + "\" is not valid for rule's inheritance"); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java index f009dc61756..dcd96d9cbb4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Version.java @@ -109,13 +109,14 @@ public class Version implements Comparable<Version> { int major = 0; int minor = 0; int patch = 0; - if (split.size() > 0) { + int size = split.size(); + if (size > 0) { major = parseSequence(split.get(0)); - if (split.size() > 1) { + if (size > 1) { minor = parseSequence(split.get(1)); - if (split.size() > 2) { + if (size > 2) { patch = parseSequence(split.get(2)); - if (split.size() > 3) { + if (size > 3) { throw new IllegalArgumentException("Only 3 sequences are accepted"); } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java index 7c04dcff55e..c31e190226e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java @@ -20,7 +20,7 @@ package org.sonar.batch.profiling; import com.google.common.collect.Maps; -import java.util.HashMap; +import java.util.EnumMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -31,7 +31,7 @@ import org.sonar.api.utils.System2; public class ModuleProfiling extends AbstractTimeProfiling { - private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<>(); + private Map<Phase, PhaseProfiling> profilingPerPhase = new EnumMap<>(Phase.class); private Map<String, ItemProfiling> profilingPerBatchStep = new LinkedHashMap<>(); private final Project module; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/report/ComponentsPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/report/ComponentsPublisher.java index 27d46165d22..2e6a25d791a 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/report/ComponentsPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/report/ComponentsPublisher.java @@ -159,7 +159,7 @@ public class ComponentsPublisher implements ReportPublisherStep { return ResourceUtils.isProject(r) ? r.getDescription() : null; } - private ComponentType getType(Resource r) { + private static ComponentType getType(Resource r) { if (ResourceUtils.isFile(r)) { return ComponentType.FILE; } else if (ResourceUtils.isDirectory(r)) { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java index de29cc352fc..a1c1f1c2dda 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java @@ -70,7 +70,6 @@ public class RulesProfileProvider extends ProviderAdapter { private static RulesProfile select(QProfile qProfile, ActiveRules activeRules) { RulesProfile deprecatedProfile = new RulesProfile(); - // TODO deprecatedProfile.setVersion(qProfile.version()); deprecatedProfile.setName(qProfile.getName()); deprecatedProfile.setLanguage(qProfile.getLanguage()); for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules.findByLanguage(qProfile.getLanguage())) { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java index 2a2952884f5..256688ef364 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java @@ -58,7 +58,7 @@ public class ExclusionFilters { return mainInclusions.length > 0 || mainExclusions.length > 0 || testInclusions.length > 0 || testExclusions.length > 0; } - private void log(String title, PathPattern[] patterns) { + private static void log(String title, PathPattern[] patterns) { if (patterns.length > 0) { LOG.info(title); for (PathPattern pattern : patterns) { diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java index c0f9fd3c062..c093056c2eb 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java @@ -19,9 +19,7 @@ */ package org.sonar.batch.scan.filesystem; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.FilePredicate; import org.sonar.api.batch.fs.internal.DefaultInputFile; @@ -29,9 +27,6 @@ import static org.assertj.core.api.Assertions.assertThat; public class AdditionalFilePredicatesTest { - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - @Test public void key() { FilePredicate predicate = new AdditionalFilePredicates.KeyPredicate("struts:Action.java"); |