aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-deprecated/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-01 11:30:48 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-01 11:30:48 +0000
commite537ea6120df8eb20ba04da66811c21161f6ec6d (patch)
treee0e5898938290b5506bb834106c908780125ff88 /sonar-deprecated/src
parent0441e5cb03ef5fcd21f681682a994437e985768d (diff)
downloadsonarqube-e537ea6120df8eb20ba04da66811c21161f6ec6d.tar.gz
sonarqube-e537ea6120df8eb20ba04da66811c21161f6ec6d.zip
SONAR-2007 Remove the useless ISO Categories + fix components page
Diffstat (limited to 'sonar-deprecated/src')
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/checks/templates/CheckTemplateRepository.java41
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/checks/templates/XmlCheckTemplateFactory.java1
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java9
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java4
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java26
5 files changed, 19 insertions, 62 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 fa96311c8db..3ebc5a99c0f 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
@@ -22,8 +22,10 @@ package org.sonar.api.checks.templates;
import org.apache.commons.io.IOUtils;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Language;
-import org.sonar.api.rules.*;
-import org.sonar.check.IsoCategory;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleParam;
+import org.sonar.api.rules.RulePriority;
+import org.sonar.api.rules.RulesRepository;
import java.io.InputStream;
import java.util.*;
@@ -134,20 +136,12 @@ public class CheckTemplateRepository implements RulesRepository {
}
-
-
-
-
-
-
-
-
/*
- 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() {
@@ -163,7 +157,6 @@ public class CheckTemplateRepository implements RulesRepository {
rule.setDescription(checkTemplate.getDescription(Locale.ENGLISH));
rule.setName(checkTemplate.getTitle(Locale.ENGLISH));
rule.setPriority(RulePriority.fromCheckPriority(checkTemplate.getPriority()));
- rule.setRulesCategory(toRuleCategory(checkTemplate.getIsoCategory()));
for (CheckTemplateProperty checkTemplateProperty : checkTemplate.getProperties()) {
RuleParam param = rule.createParameter(checkTemplateProperty.getKey());
param.setDescription(checkTemplateProperty.getDescription(Locale.ENGLISH));
@@ -173,26 +166,6 @@ public class CheckTemplateRepository implements RulesRepository {
return rule;
}
- private RulesCategory toRuleCategory(IsoCategory isoCategory) {
- if (isoCategory == IsoCategory.Reliability) {
- return Iso9126RulesCategories.RELIABILITY;
- }
- if (isoCategory == IsoCategory.Efficiency) {
- return Iso9126RulesCategories.EFFICIENCY;
- }
- if (isoCategory == IsoCategory.Maintainability) {
- return Iso9126RulesCategories.MAINTAINABILITY;
- }
- if (isoCategory == IsoCategory.Portability) {
- return Iso9126RulesCategories.PORTABILITY;
- }
- if (isoCategory == IsoCategory.Usability) {
- return Iso9126RulesCategories.USABILITY;
- }
- return null;
- }
-
-
public List<Rule> parseReferential(String fileContent) {
return Collections.emptyList();
}
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 0b51222c53d..1de8a616a0c 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
@@ -75,7 +75,6 @@ public class XmlCheckTemplateFactory {
template.setConfigKey(rule.getConfigKey());
template.setDescription(rule.getDescription());
- template.setIsoCategory(rule.getRulesCategory().toIsoCategory());
template.setPriority(rule.getPriority().toCheckPriority());
template.setTitle(rule.getName());
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java b/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java
index 1d5d5fb90bc..cb7842f049d 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/database/daos/RulesDao.java
@@ -27,6 +27,7 @@ import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleParam;
import org.sonar.api.rules.RulesCategory;
+import java.util.Collections;
import java.util.List;
@Deprecated
@@ -47,7 +48,7 @@ public class RulesDao {
}
public List<Rule> getRulesByCategory(RulesCategory categ) {
- return target.getRulesByCategory(categ);
+ return Collections.emptyList();
}
public Rule getRuleByKey(String pluginKey, String ruleKey) {
@@ -55,15 +56,15 @@ public class RulesDao {
}
public Long countRules(List<String> plugins, String categoryName) {
- return target.countRules(plugins, categoryName);
+ return target.countRules(plugins);
}
public List<RulesCategory> getCategories() {
- return target.getCategories();
+ return Collections.emptyList();
}
public RulesCategory getCategory(String key) {
- return target.getCategory(key);
+ return null;
}
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 e532df1d040..58b8c69abbc 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
@@ -105,9 +105,7 @@ public class StandardRulesXmlParser {
xstream.registerConverter(new TrimStringConverter());
xstream.alias("rules", ArrayList.class);
- xstream.alias("categ", RulesCategory.class);
- xstream.useAttributeFor(RulesCategory.class, "name");
- xstream.aliasField("category", Rule.class, "rulesCategory");
+ xstream.omitField(Rule.class, "category");
xstream.alias("rule", Rule.class);
xstream.useAttributeFor(Rule.class, "key");
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 30bc75f9f89..cdccbf1875b 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
@@ -20,15 +20,15 @@
package org.sonar.api.rules;
import org.apache.commons.io.IOUtils;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
-
import org.junit.Assert;
import org.junit.Test;
import java.util.List;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
+
public class StandardRulesXmlParserTest {
@Test
public void checkAllFields() {
@@ -49,25 +49,11 @@ public class StandardRulesXmlParserTest {
}
@Test
- public void ruleShouldHaveACategory() {
- StandardRulesXmlParser parser = new StandardRulesXmlParser();
- String xml = "<rules><rule><category name='cat1' /></rule></rules>";
- List<Rule> rules = parser.parse(xml);
- assertNotNull(rules.get(0).getRulesCategory());
- Assert.assertEquals("cat1", rules.get(0).getRulesCategory().getName());
- assertNull(rules.get(0).getRulesCategory().getId());
- assertNull(rules.get(0).getRulesCategory().getDescription());
- }
-
- @Test
public void ruleCanHaveALevel() {
StandardRulesXmlParser parser = new StandardRulesXmlParser();
String xml = "<rules><rule key='1' priority='CRITICAL'><category name='cat1'/></rule></rules>";
List<Rule> rules = parser.parse(xml);
- assertNotNull(rules.get(0).getRulesCategory());
Assert.assertEquals(RulePriority.CRITICAL, rules.get(0).getPriority());
- assertNull(rules.get(0).getRulesCategory().getId());
- assertNull(rules.get(0).getRulesCategory().getDescription());
}
@Test
@@ -101,10 +87,10 @@ public class StandardRulesXmlParserTest {
@Test
public void shouldContainCDataDescription() {
StandardRulesXmlParser parser = new StandardRulesXmlParser();
- String xml = "<rules><rule key='key1' category='cat1'><description> <![CDATA[<xml> </nodes> and accents Žˆ˜ ]]> </description></rule></rules>";
+ String xml = "<rules><rule key='key1' category='cat1'><description> <![CDATA[<xml> </nodes> and accents ��� ]]> </description></rule></rules>";
List<Rule> rules = parser.parse(xml);
assertEquals(1, rules.size());
- Assert.assertEquals("<xml> </nodes> and accents Žˆ˜", rules.get(0).getDescription());
+ Assert.assertEquals("<xml> </nodes> and accents ���", rules.get(0).getDescription());
}
@Test