]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3879 : Add constant for rule status
authorJulien Lancelot <julien.lancelot@gmail.com>
Mon, 25 Mar 2013 08:31:35 +0000 (09:31 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Mon, 25 Mar 2013 08:31:35 +0000 (09:31 +0100)
sonar-check-api/src/main/java/org/sonar/check/Rule.java
sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java
sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleTest.java

index d754f488e4ac353bc0e2d9a482efc470201151cb..ef62eaa66e4149a7ee5aecf746964b5c05e1dcff 100644 (file)
@@ -31,6 +31,10 @@ import java.lang.annotation.Target;
 @Target(ElementType.TYPE)
 public @interface Rule {
 
+  public static final String STATUS_BETA = "BETA";
+  public static final String STATUS_DEPRECATED = "DEPRECATED";
+  public static final String STATUS_READY = "READY";
+
   /**
    * The default key is the class name.
    */
index 367ffb730dfdce451eb4e60c3975dce3a6bcde8e..985fde99d01e9f4073d9512fc85a6c897790b03d 100644 (file)
@@ -44,7 +44,7 @@ public class AnnotationRuleParserTest {
     assertThat(rule.getName()).isEqualTo("bar");
     assertThat(rule.getDescription()).isEqualTo("Foo Bar");
     assertThat(rule.getSeverity()).isEqualTo(RulePriority.BLOCKER);
-    assertThat(rule.getStatus()).isEqualTo("READY");
+    assertThat(rule.getStatus()).isEqualTo(org.sonar.check.Rule.STATUS_READY);
     assertThat(rule.getParams()).hasSize(1);
 
     RuleParam prop = rule.getParam("property");
@@ -140,7 +140,7 @@ public class AnnotationRuleParserTest {
   static class RuleWithoutNameNorDescription {
   }
 
-  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER)
+  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = org.sonar.check.Rule.STATUS_READY, priority = Priority.BLOCKER)
   static class RuleWithProperty {
     @org.sonar.check.RuleProperty(description = "Ignore ?", defaultValue = "false")
     private String property;
@@ -152,19 +152,19 @@ public class AnnotationRuleParserTest {
     private String additionalProperty;
   }
 
-  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER)
+  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = org.sonar.check.Rule.STATUS_READY, priority = Priority.BLOCKER)
   static class RuleWithIntegerProperty {
     @org.sonar.check.RuleProperty(description = "Max", defaultValue = "12")
     private Integer property;
   }
 
-  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER)
+  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = org.sonar.check.Rule.STATUS_READY, priority = Priority.BLOCKER)
   static class RuleWithTextProperty {
     @org.sonar.check.RuleProperty(description = "text", defaultValue = "Long text", type = "TEXT")
     protected String property;
   }
 
-  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER)
+  @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = org.sonar.check.Rule.STATUS_READY, priority = Priority.BLOCKER)
   static class RuleWithInvalidPropertyType {
     @org.sonar.check.RuleProperty(description = "text", defaultValue = "Long text", type = "INVALID")
     public String property;
index 3cc984f6bb2d80950b6d1619e83453f5b7a3df74..e17c6ca55143916351abca326df3f82068c4854c 100644 (file)
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertThat;
 public class RuleTest {
 
   @Test
-  public void descriptionShouldBeCleaned() {
+  public void description_should_be_cleaned() {
     Rule rule = new Rule();
     rule.setDescription("    my description         ");
     Assert.assertEquals("my description", rule.getDescription());
@@ -43,7 +43,7 @@ public class RuleTest {
   }
 
   @Test
-  public void shouldRemoveNewLineCharactersInNameWithSetter() {
+  public void should_remove_new_line_characters_in_name_with_setter() {
     Rule rule = new Rule();
     for (String example : getExamplesContainingNewLineCharacter()) {
       rule.setName(example);
@@ -52,7 +52,7 @@ public class RuleTest {
   }
 
   @Test
-  public void shouldRemoveNewLineCharactersInNameWithfirstConstructor() {
+  public void should_remove_new_line_characters_in_name_with_first_constructor() {
     Rule rule;
     for (String example : getExamplesContainingNewLineCharacter()) {
       rule = new Rule(null, null).setName(example);
@@ -61,7 +61,7 @@ public class RuleTest {
   }
 
   @Test
-  public void shouldRemoveNewLineCharactersInNameWithSecondConstructor() {
+  public void should_remove_new_line_characters_in_name_with_second_constructor() {
     Rule rule;
     for (String example : getExamplesContainingNewLineCharacter()) {
       rule = new Rule(null, null).setName(example);
@@ -70,7 +70,7 @@ public class RuleTest {
   }
 
   @Test
-  public void defaultPriorityIsMajor() {
+  public void default_priority_is_major() {
     Rule rule = new Rule();
     assertThat(rule.getSeverity(), Is.is(RulePriority.MAJOR));