]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 10 Jan 2014 14:08:32 +0000 (15:08 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 10 Jan 2014 14:08:32 +0000 (15:08 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java

index 8b9f47082ae877e1bbbb14b367b93159f089b7c8..f8113ddcbe1e7d4177c88d0796df4bed2f9d86ed 100644 (file)
@@ -42,7 +42,7 @@ public interface RuleDefinitions extends ServerExtension {
   /**
    * Instantiated by core but not by plugins.
    */
-  public static class Context {
+  static class Context {
     private final Map<String, NewRepository> newRepositories = Maps.newHashMap();
     private final ListMultimap<String, ExtendedRepository> extendedRepositories = ArrayListMultimap.create();
 
@@ -86,7 +86,7 @@ public interface RuleDefinitions extends ServerExtension {
     }
   }
 
-  public static interface ExtendedRepository {
+  static interface ExtendedRepository {
     String key();
 
     NewRule newRule(String ruleKey);
@@ -97,7 +97,7 @@ public interface RuleDefinitions extends ServerExtension {
     List<NewRule> getRules();
   }
 
-  public static class NewRepository implements ExtendedRepository {
+  static class NewRepository implements ExtendedRepository {
     private final String key;
     private String language;
     private String name;
@@ -170,12 +170,11 @@ public interface RuleDefinitions extends ServerExtension {
     }
   }
 
-  public static class NewRule {
+  static class NewRule {
     private final String repoKey, key;
     private String name, htmlDescription, metadata, defaultSeverity = Severity.MAJOR;
     private final Set<String> tags = Sets.newHashSet();
     private final Map<String, NewParam> params = Maps.newHashMap();
-    // TODO cardinality ? or template boolean ?
 
     public NewRule(String repoKey, String key) {
       this.repoKey = repoKey;
@@ -192,7 +191,7 @@ public interface RuleDefinitions extends ServerExtension {
 
     public NewRule setName(String s) {
       if (StringUtils.isBlank(s)) {
-        throw new IllegalArgumentException("Name of rule " + this + " is blank");
+        throw new IllegalArgumentException(String.format("Name of rule %s is blank", this));
       }
       this.name = s;
       return this;
@@ -204,7 +203,7 @@ public interface RuleDefinitions extends ServerExtension {
 
     public NewRule setDefaultSeverity(String s) {
       if (!Severity.ALL.contains(s)) {
-        throw new IllegalArgumentException("Default severity of rule " + this + " is not correct: " + s);
+        throw new IllegalArgumentException(String.format("Default severity of rule %s is not correct: %s", this, s));
       }
       this.defaultSeverity = s;
       return this;
@@ -217,7 +216,7 @@ public interface RuleDefinitions extends ServerExtension {
 
     public NewRule setHtmlDescription(String s) {
       if (StringUtils.isBlank(s)) {
-        throw new IllegalArgumentException("HTML description of rule " + this + " is blank");
+        throw new IllegalArgumentException(String.format("HTML description of rule %s is blank", this));
       }
       this.htmlDescription = s;
       return this;
@@ -225,7 +224,7 @@ public interface RuleDefinitions extends ServerExtension {
 
     public NewParam newParam(String paramKey) {
       if (params.containsKey(paramKey)) {
-        throw new IllegalArgumentException("The parameter '" + key + "' is declared several times on the rule " + this);
+        throw new IllegalArgumentException(String.format("The parameter '%s' is declared several times on the rule %s", paramKey, this));
       }
       NewParam param = new NewParam(this, paramKey);
       params.put(paramKey, param);
@@ -308,7 +307,7 @@ public interface RuleDefinitions extends ServerExtension {
     }
   }
 
-  public static class NewParam {
+  static class NewParam {
     private final NewRule rule;
     private final String key;
     private String name, description, defaultValue;
index 8c8fb960663c58001a0acd2790619100aa051387..1783a0e367f4ad1ae2d58ed1a9f047fcc1da8bf8 100644 (file)
@@ -173,7 +173,7 @@ public class RuleDefinitionsTest {
       rule.newParam("level");
       fail();
     } catch (IllegalArgumentException e) {
-      assertThat(e).hasMessage("The parameter 'NPE' is declared several times on the rule [repository=findbugs, key=NPE]");
+      assertThat(e).hasMessage("The parameter 'level' is declared several times on the rule [repository=findbugs, key=NPE]");
     }
   }