From 782ab5228c92df8a57298f03a953682c6478b11f Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 25 Mar 2013 09:31:35 +0100 Subject: [PATCH] SONAR-3879 : Add constant for rule status --- .../src/main/java/org/sonar/check/Rule.java | 4 ++++ .../org/sonar/api/rules/AnnotationRuleParserTest.java | 10 +++++----- .../src/test/java/org/sonar/api/rules/RuleTest.java | 10 +++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sonar-check-api/src/main/java/org/sonar/check/Rule.java b/sonar-check-api/src/main/java/org/sonar/check/Rule.java index d754f488e4a..ef62eaa66e4 100644 --- a/sonar-check-api/src/main/java/org/sonar/check/Rule.java +++ b/sonar-check-api/src/main/java/org/sonar/check/Rule.java @@ -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. */ diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java index 367ffb730df..985fde99d01 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java @@ -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; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleTest.java index 3cc984f6bb2..e17c6ca5514 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleTest.java @@ -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)); -- 2.39.5