aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-01-10 15:08:32 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-01-10 15:08:32 +0100
commita35c03b255dac26885347b0c5afed10a8ff6b1cc (patch)
tree25a9a811e4b4f888df4e6a7b3ae46913f47804d3 /sonar-plugin-api
parent1b0ef4b501a0d177b278d3aac482160e3b4e07a3 (diff)
downloadsonarqube-a35c03b255dac26885347b0c5afed10a8ff6b1cc.tar.gz
sonarqube-a35c03b255dac26885347b0c5afed10a8ff6b1cc.zip
Fix some quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java19
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java2
2 files changed, 10 insertions, 11 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
index 8b9f47082ae..f8113ddcbe1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
@@ -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;
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java
index 8c8fb960663..1783a0e367f 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java
@@ -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]");
}
}