aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-10-11 14:47:13 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-10-11 14:47:13 +0000
commit8c8007b2c9ebe8aa5b5a2fac0d9955e2cbead304 (patch)
treecf57927057addb51b707759d35816c68353e9d6c /sonar-plugin-api
parentf561c79fce592354824d1db303a22fe4cd3a0277 (diff)
downloadsonarqube-8c8007b2c9ebe8aa5b5a2fac0d9955e2cbead304.tar.gz
sonarqube-8c8007b2c9ebe8aa5b5a2fac0d9955e2cbead304.zip
rule API: add the field 'cardinality' to the annotation @org.sonar.check.Rule
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java2
4 files changed, 6 insertions, 9 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java
index 28c7679a5ce..b9c25a2165b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java
@@ -65,6 +65,7 @@ public final class AnnotationRuleParser implements ServerComponent {
rule.setDescription(ruleAnnotation.description());
rule.setRulesCategory(RulesCategory.fromIsoCategory(ruleAnnotation.isoCategory()));
rule.setPriority(RulePriority.fromCheckPriority(ruleAnnotation.priority()));
+ rule.setCardinality(ruleAnnotation.cardinality());
Field[] fields = clazz.getDeclaredFields();
if (fields != null) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java
index cde01feaa4c..2cfbad47348 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java
@@ -33,10 +33,6 @@ import java.util.List;
@Table(name = "rules")
public final class Rule {
- public static enum Cardinality {
- SINGLE, MULTIPLE
- }
-
@Id
@Column(name = "id")
@GeneratedValue
@@ -75,7 +71,7 @@ public final class Rule {
@Enumerated(EnumType.STRING)
@Column(name = "cardinality", updatable = true, nullable = false)
- private Cardinality cardinality = Cardinality.SINGLE;
+ private org.sonar.check.Rule.CARDINALITY cardinality = org.sonar.check.Rule.CARDINALITY.SINGLE;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_id", updatable = true, nullable = true)
@@ -335,11 +331,11 @@ public final class Rule {
return setRepositoryKey(repositoryKey).setKey(key).setConfigKey(key);
}
- public Cardinality getCardinality() {
+ public org.sonar.check.Rule.CARDINALITY getCardinality() {
return cardinality;
}
- public Rule setCardinality(Cardinality c) {
+ public Rule setCardinality(org.sonar.check.Rule.CARDINALITY c) {
this.cardinality = c;
return this;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java
index 60090731ca2..46f6ff48745 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java
@@ -139,7 +139,7 @@ public final class XMLRuleParser implements ServerComponent {
rule.setRulesCategory(new RulesCategory(category));
} else if (StringUtils.equalsIgnoreCase("cardinality", nodeName)) {
- rule.setCardinality(Rule.Cardinality.valueOf(StringUtils.trim(cursor.collectDescendantText(false))));
+ rule.setCardinality(org.sonar.check.Rule.CARDINALITY.valueOf(StringUtils.trim(cursor.collectDescendantText(false))));
} else if (StringUtils.equalsIgnoreCase("param", nodeName)) {
processParameter(rule, cursor);
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java
index ebe150ff997..df56311968a 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java
@@ -42,7 +42,7 @@ public class XMLRuleParserTest {
assertThat(rule.getName(), is("Local Variable Name"));
assertThat(rule.getDescription(), is("Checks that local, non-final variable names conform to a format specified by the format property."));
assertThat(rule.getPriority(), Is.is(RulePriority.BLOCKER));
- assertThat(rule.getCardinality(), Is.is(Rule.Cardinality.MULTIPLE));
+ assertThat(rule.getCardinality(), Is.is(org.sonar.check.Rule.CARDINALITY.MULTIPLE));
assertThat(rule.getConfigKey(), is("Checker/TreeWalker/LocalVariableName"));
assertThat(rule.getParams().size(), is(2));