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-deprecated | |
parent | 8e9d7ff89a66bf987d7fcb7c298a53a992625375 (diff) | |
download | sonarqube-b09f170fa5cd8980019d6cf91251ab11970b1cc6.tar.gz sonarqube-b09f170fa5cd8980019d6cf91251ab11970b1cc6.zip |
SONAR-1829: Use severity instead of priority
Diffstat (limited to 'sonar-deprecated')
4 files changed, 17 insertions, 21 deletions
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java index 3ebc5a99c0f..eade8969a01 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java @@ -42,7 +42,6 @@ public class CheckTemplateRepository implements RulesRepository { private List<CheckTemplate> templates; private Map<String, CheckTemplate> templatesByKey; - public CheckTemplateRepository() { } @@ -112,7 +111,6 @@ public class CheckTemplateRepository implements RulesRepository { return key.hashCode(); } - public static CheckTemplateRepository createFromXml(String repositoryKey, Language language, String pathToXml) { InputStream input = CheckTemplateRepository.class.getResourceAsStream(pathToXml); try { @@ -135,14 +133,10 @@ public class CheckTemplateRepository implements RulesRepository { return repository; } - /* - - CODE FOR BACKWARD COMPATIBLITY - This class should not extend RulesRepository in next versions - - */ - + * CODE FOR BACKWARD COMPATIBLITY + * This class should not extend RulesRepository in next versions + */ public List<Rule> getInitialReferential() { List<Rule> rules = new ArrayList<Rule>(); @@ -156,7 +150,7 @@ public class CheckTemplateRepository implements RulesRepository { Rule rule = new Rule(getKey(), checkTemplate.getKey()); rule.setDescription(checkTemplate.getDescription(Locale.ENGLISH)); rule.setName(checkTemplate.getTitle(Locale.ENGLISH)); - rule.setPriority(RulePriority.fromCheckPriority(checkTemplate.getPriority())); + rule.setSeverity(RulePriority.fromCheckPriority(checkTemplate.getPriority())); for (CheckTemplateProperty checkTemplateProperty : checkTemplate.getProperties()) { RuleParam param = rule.createParameter(checkTemplateProperty.getKey()); param.setDescription(checkTemplateProperty.getDescription(Locale.ENGLISH)); diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java index 1de8a616a0c..b08b584c3c5 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java @@ -34,6 +34,7 @@ import java.util.List; /** * EXPERIMENTAL - will be used in version 2.2 + * * @since 2.1 */ public class XmlCheckTemplateFactory { @@ -75,7 +76,7 @@ public class XmlCheckTemplateFactory { template.setConfigKey(rule.getConfigKey()); template.setDescription(rule.getDescription()); - template.setPriority(rule.getPriority().toCheckPriority()); + template.setPriority(rule.getSeverity().toCheckPriority()); template.setTitle(rule.getName()); if (rule.getParams() != null) { @@ -96,4 +97,4 @@ public class XmlCheckTemplateFactory { return property; } -}
\ No newline at end of file +} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java b/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java index 58b8c69abbc..82889c80c66 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java @@ -44,7 +44,7 @@ public class StandardRulesXmlParser { InputStream inputStream = null; try { inputStream = IOUtils.toInputStream(xml, CharEncoding.UTF_8); - return setDefaultRulePriorities((List<Rule>) getXStream().fromXML(inputStream)); + return setDefaultRuleSeverities((List<Rule>) getXStream().fromXML(inputStream)); } catch (IOException e) { throw new SonarException("Can't parse xml file", e); @@ -55,22 +55,22 @@ public class StandardRulesXmlParser { } public List<Rule> parse(Reader reader) { - return setDefaultRulePriorities((List<Rule>) getXStream().fromXML(reader)); + return setDefaultRuleSeverities((List<Rule>) getXStream().fromXML(reader)); } public List<Rule> parse(InputStream input) { try { - return setDefaultRulePriorities((List<Rule>) getXStream().fromXML(new InputStreamReader(input, CharEncoding.UTF_8))); + return setDefaultRuleSeverities((List<Rule>) getXStream().fromXML(new InputStreamReader(input, CharEncoding.UTF_8))); } catch (UnsupportedEncodingException e) { throw new SonarException("Can't parse xml file", e); } } - private List<Rule> setDefaultRulePriorities(List<Rule> rules) { + private List<Rule> setDefaultRuleSeverities(List<Rule> rules) { for (Rule rule : rules) { - if (rule.getPriority() == null) { - rule.setPriority(RulePriority.MAJOR); + if (rule.getSeverity() == null) { + rule.setSeverity(RulePriority.MAJOR); } } return rules; diff --git a/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java b/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java index cdccbf1875b..25a408ce089 100644 --- a/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java @@ -27,7 +27,8 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class StandardRulesXmlParserTest { @Test @@ -53,7 +54,7 @@ public class StandardRulesXmlParserTest { StandardRulesXmlParser parser = new StandardRulesXmlParser(); String xml = "<rules><rule key='1' priority='CRITICAL'><category name='cat1'/></rule></rules>"; List<Rule> rules = parser.parse(xml); - Assert.assertEquals(RulePriority.CRITICAL, rules.get(0).getPriority()); + Assert.assertEquals(RulePriority.CRITICAL, rules.get(0).getSeverity()); } @Test @@ -61,7 +62,7 @@ public class StandardRulesXmlParserTest { StandardRulesXmlParser parser = new StandardRulesXmlParser(); String xml = "<rules><rule key='1'><category name='cat1'/></rule></rules>"; List<Rule> rules = parser.parse(xml); - Assert.assertEquals(RulePriority.MAJOR, rules.get(0).getPriority()); + Assert.assertEquals(RulePriority.MAJOR, rules.get(0).getSeverity()); } @Test |