diff options
author | Godin <mandrikov@gmail.com> | 2010-12-07 16:02:48 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-07 16:02:48 +0000 |
commit | b09f170fa5cd8980019d6cf91251ab11970b1cc6 (patch) | |
tree | 4fbf596dfeb13b56fec587d49c404de977264642 /sonar-plugin-api | |
parent | 8e9d7ff89a66bf987d7fcb7c298a53a992625375 (diff) | |
download | sonarqube-b09f170fa5cd8980019d6cf91251ab11970b1cc6.tar.gz sonarqube-b09f170fa5cd8980019d6cf91251ab11970b1cc6.zip |
SONAR-1829: Use severity instead of priority
Diffstat (limited to 'sonar-plugin-api')
7 files changed, 29 insertions, 29 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 d40dc943553..619a01c3c7e 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 @@ -64,7 +64,7 @@ public final class AnnotationRuleParser implements ServerComponent { String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), ruleKey); Rule rule = Rule.create(repositoryKey, ruleKey, ruleName); rule.setDescription(ruleAnnotation.description()); - rule.setPriority(RulePriority.fromCheckPriority(ruleAnnotation.priority())); + rule.setSeverity(RulePriority.fromCheckPriority(ruleAnnotation.priority())); rule.setCardinality(ruleAnnotation.cardinality()); Field[] fields = clazz.getDeclaredFields(); @@ -82,7 +82,7 @@ public final class AnnotationRuleParser implements ServerComponent { String ruleName = StringUtils.defaultIfEmpty(checkAnnotation.title(), ruleKey); Rule rule = Rule.create(repositoryKey, ruleKey, ruleName); rule.setDescription(checkAnnotation.description()); - rule.setPriority(RulePriority.fromCheckPriority(checkAnnotation.priority())); + rule.setSeverity(RulePriority.fromCheckPriority(checkAnnotation.priority())); 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 d257ef39a2f..618d0e6fb46 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 @@ -124,7 +124,7 @@ public final class Rule { }
/**
- * @deprecated Use the factory method {@link #create()}
+ * @deprecated since 2.3. Use the factory method {@link #create()}
*/
@Deprecated
public Rule(String name, String key, RulesCategory rulesCategory, String pluginName, String description) {
@@ -154,7 +154,7 @@ public final class Rule { }
/**
- * @deprecated visibility should be decreased to protected or package
+ * @deprecated since 2.3. visibility should be decreased to protected or package
*/
@Deprecated
public void setId(Integer id) {
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 adc70ff30e5..8eadd746680 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 @@ -33,6 +33,7 @@ import org.sonar.check.Cardinality; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; + import java.io.*; import java.util.ArrayList; import java.util.List; @@ -111,7 +112,7 @@ public final class XMLRuleParser implements ServerComponent { /* BACKWARD COMPATIBILITY WITH DEPRECATED FORMAT */ String priorityAttribute = ruleC.getAttrValue("priority"); if (StringUtils.isNotBlank(priorityAttribute)) { - rule.setPriority(RulePriority.valueOf(StringUtils.trim(priorityAttribute))); + rule.setSeverity(RulePriority.valueOf(StringUtils.trim(priorityAttribute))); } SMInputCursor cursor = ruleC.childElementCursor(); @@ -132,7 +133,7 @@ public final class XMLRuleParser implements ServerComponent { rule.setConfigKey(StringUtils.trim(cursor.collectDescendantText(false))); } else if (StringUtils.equalsIgnoreCase("priority", nodeName)) { - rule.setPriority(RulePriority.valueOf(StringUtils.trim(cursor.collectDescendantText(false)))); + rule.setSeverity(RulePriority.valueOf(StringUtils.trim(cursor.collectDescendantText(false)))); } else if (StringUtils.equalsIgnoreCase("cardinality", nodeName)) { rule.setCardinality(Cardinality.valueOf(StringUtils.trim(cursor.collectDescendantText(false)))); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java index 3f36241a437..0e54a3a824d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java @@ -42,16 +42,16 @@ public class RulesProfileTest { @Test public void activateRuleWithDefaultPriority() { RulesProfile profile = RulesProfile.create(); - Rule rule = Rule.create("repo", "key1", "name1").setPriority(RulePriority.CRITICAL); + Rule rule = Rule.create("repo", "key1", "name1").setSeverity(RulePriority.CRITICAL); profile.activateRule(rule, null); - assertThat(profile.getActiveRule("repo", "key1").getPriority(), is(RulePriority.CRITICAL)); + assertThat(profile.getActiveRule("repo", "key1").getSeverity(), is(RulePriority.CRITICAL)); } @Test public void activateRuleWithSpecificPriority() { RulesProfile profile = RulesProfile.create(); - Rule rule = Rule.create("repo", "key1", "name1").setPriority(RulePriority.CRITICAL); + Rule rule = Rule.create("repo", "key1", "name1").setSeverity(RulePriority.CRITICAL); profile.activateRule(rule, RulePriority.MINOR); - assertThat(profile.getActiveRule("repo", "key1").getPriority(), is(RulePriority.MINOR)); + assertThat(profile.getActiveRule("repo", "key1").getSeverity(), is(RulePriority.MINOR)); } } 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 6493581677b..c48445bfbec 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 @@ -19,7 +19,7 @@ public class AnnotationRuleParserTest { Rule rule = rules.get(0); assertThat(rule.getKey(), is("foo")); assertThat(rule.getName(), is("bar")); - assertThat(rule.getPriority(), is(RulePriority.BLOCKER)); + assertThat(rule.getSeverity(), is(RulePriority.BLOCKER)); assertThat(rule.getParams().size(), is(1)); RuleParam prop = rule.getParam("property"); assertThat(prop.getKey(), is("property")); @@ -34,7 +34,7 @@ public class AnnotationRuleParserTest { Rule rule = rules.get(0); assertThat(rule.getKey(), is("foo")); assertThat(rule.getName(), is("foo")); - assertThat(rule.getPriority(), is(RulePriority.MAJOR)); + assertThat(rule.getSeverity(), is(RulePriority.MAJOR)); } @Test @@ -44,7 +44,7 @@ public class AnnotationRuleParserTest { Rule rule = rules.get(0); assertThat(rule.getKey(), is(RuleWithoutKey.class.getCanonicalName())); assertThat(rule.getName(), is("foo")); - assertThat(rule.getPriority(), is(RulePriority.MAJOR)); + assertThat(rule.getSeverity(), is(RulePriority.MAJOR)); } @Test @@ -55,7 +55,7 @@ public class AnnotationRuleParserTest { assertThat(rule.getKey(), is(Check.class.getCanonicalName())); assertThat(rule.getName(), is(Check.class.getCanonicalName())); assertThat(rule.getDescription(), is("Deprecated check")); - assertThat(rule.getPriority(), is(RulePriority.BLOCKER)); + assertThat(rule.getSeverity(), is(RulePriority.BLOCKER)); } private List<Rule> parseAnnotatedClass(Class annotatedClass) { 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 c0767fda0ad..56285ed10f2 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 @@ -19,9 +19,6 @@ */ package org.sonar.api.rules; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; - import org.hamcrest.core.Is; import org.junit.Assert; import org.junit.Test; @@ -29,6 +26,10 @@ import org.junit.Test; import java.util.Arrays; import java.util.List; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + public class RuleTest { @Test @@ -63,7 +64,7 @@ public class RuleTest { public void shouldRemoveNewLineCharactersInNameWithSecondConstructor() { Rule rule; for (String example : getExamplesContainingNewLineCharacter()) { - rule = new Rule(null, null, example, (RulesCategory)null, null); + rule = new Rule(null, null, example, (RulesCategory) null, null); assertThat(rule.getName(), is("test")); } } @@ -71,25 +72,23 @@ public class RuleTest { @Test public void defaultPriorityIsMajor() { Rule rule = new Rule(); - assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR)); + assertThat(rule.getSeverity(), Is.is(RulePriority.MAJOR)); rule = new Rule("name", "key"); - assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR)); + assertThat(rule.getSeverity(), Is.is(RulePriority.MAJOR)); rule = new Rule("pkey", "key", "name", Iso9126RulesCategories.EFFICIENCY, null, null); - assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR)); + assertThat(rule.getSeverity(), Is.is(RulePriority.MAJOR)); - rule.setPriority(RulePriority.BLOCKER); - assertThat(rule.getPriority(), Is.is(RulePriority.BLOCKER)); + rule.setSeverity(RulePriority.BLOCKER); + assertThat(rule.getSeverity(), Is.is(RulePriority.BLOCKER)); - rule.setPriority(null); - assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR)); + rule.setSeverity(null); + assertThat(rule.getSeverity(), Is.is(RulePriority.MAJOR)); } - private List<String> getExamplesContainingNewLineCharacter() { return Arrays.asList("te\nst", "te\ns\nt", "te\rst", "te\n\rst", "te\r\nst"); } - } 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 02027741ceb..dab65bfc564 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 @@ -44,7 +44,7 @@ public class XMLRuleParserTest { Rule rule = rules.get(0); 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.getSeverity(), Is.is(RulePriority.BLOCKER)); assertThat(rule.getCardinality(), Is.is(Cardinality.MULTIPLE)); assertThat(rule.getConfigKey(), is("Checker/TreeWalker/LocalVariableName")); @@ -93,7 +93,7 @@ public class XMLRuleParserTest { List<Rule> rules = new XMLRuleParser().parse(getClass().getResourceAsStream("/org/sonar/api/rules/XMLRuleParserTest/deprecated.xml")); assertThat(rules.size(), is(1)); Rule rule = rules.get(0); - assertThat(rule.getPriority(), Is.is(RulePriority.CRITICAL)); + assertThat(rule.getSeverity(), Is.is(RulePriority.CRITICAL)); assertThat(rule.getKey(), is("org.sonar.it.checkstyle.MethodsCountCheck")); assertThat(rule.getParam("minMethodsCount"), not(nullValue())); } |