diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-22 09:41:33 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-22 09:41:33 +0100 |
commit | 929f50815d7c0679b34ade1d75024d54dd35d057 (patch) | |
tree | bfd5876ba79130275e5d13702458409967197580 | |
parent | 948692308d6f43e0525f0bf3210e44288a24f8da (diff) | |
download | sonarqube-929f50815d7c0679b34ade1d75024d54dd35d057.tar.gz sonarqube-929f50815d7c0679b34ade1d75024d54dd35d057.zip |
Fix some quality flaws
6 files changed, 24 insertions, 10 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java index 8b1aa5e33f7..65ab932575a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java @@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList; import org.sonar.api.measures.Metric; import org.sonar.api.measures.Metrics; -import java.util.Arrays; import java.util.List; public final class UserManagedMetrics implements Metrics { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java index 3acaa29481f..88fb6f72379 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java @@ -67,7 +67,7 @@ public final class ResourceTypeTree implements BatchExtension, ServerExtension { return new Builder(); } - public static class Builder { + public static final class Builder { private List<ResourceType> types = Lists.newArrayList(); private ListMultimap<String, String> relations = ArrayListMultimap.create(); @@ -81,11 +81,11 @@ public final class ResourceTypeTree implements BatchExtension, ServerExtension { return this; } - public Builder addRelations(String parentQualifier, String... childQualifiers) { + public Builder addRelations(String parentQualifier, String... childrenQualifiers) { Preconditions.checkNotNull(parentQualifier); - Preconditions.checkNotNull(childQualifiers); - Preconditions.checkArgument(childQualifiers.length > 0, "childQualifiers can't be empty"); - relations.putAll(parentQualifier, Arrays.asList(childQualifiers)); + Preconditions.checkNotNull(childrenQualifiers); + Preconditions.checkArgument(childrenQualifiers.length > 0, "childrenQualifiers can't be empty"); + relations.putAll(parentQualifier, Arrays.asList(childrenQualifiers)); return this; } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java index 486330d7d00..c8f73ec0596 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java @@ -61,4 +61,20 @@ public class ResourceTypeTreeTest { assertThat(tree.getLeaves(), hasItems("FIL", "UTS")); } + @Test(expected = IllegalArgumentException.class) + public void forbidNullRelation() { + ResourceTypeTree.builder() + .addType(ResourceType.builder("TRK").build()) + .addType(ResourceType.builder("DIR").build()) + .addRelations("DIR" /* missing child */) + .build(); + } + + @Test(expected = IllegalArgumentException.class) + public void forbidDuplicatedType() { + ResourceTypeTree.builder() + .addType(ResourceType.builder("TRK").build()) + .addType(ResourceType.builder("TRK").build()) + .build(); + } } diff --git a/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java b/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java index 4730a8210c3..4afa2b8c776 100644 --- a/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java +++ b/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java @@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory; import org.sonar.api.ServerComponent; import org.sonar.api.charts.Chart; -import java.util.HashMap; import java.util.Map; public final class ChartFactory implements ServerComponent { diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 5ec0171e4ef..a497e03fcd3 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -87,8 +87,8 @@ public final class JRubyFacade { } public Collection<String> getResourceChildrenQualifiers(String qualifier) { - return getContainer().getComponentByType(ResourceTypes.class).getChildrenQualifiers(qualifier); - } + return getContainer().getComponentByType(ResourceTypes.class).getChildrenQualifiers(qualifier); + } // UPDATE CENTER ------------------------------------------------------------ diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java index 93aecf2c1d6..7ed8b3384a2 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java @@ -132,7 +132,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> { writer = new FileWriter(dumpFile); writer.write(details); } catch (IOException e) { - throw new RuntimeException("Unable to write the report to 'target/l10n/" + bundleName + ".report.txt'"); + throw new IllegalStateException("Unable to write the report to 'target/l10n/" + bundleName + ".report.txt'", e); } finally { IOUtils.closeQuietly(writer); } |