diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-03-14 14:43:48 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-03-14 18:49:24 +0100 |
commit | a8d7a5929e638328796e51163ab16bb82e6aaf1b (patch) | |
tree | 9e16c65acf3a5bb303f87afc61d4d7db53c32c0a /sonar-plugin-api | |
parent | 0240db35d71a8c177459fc182207a27b752c2e0b (diff) | |
download | sonarqube-a8d7a5929e638328796e51163ab16bb82e6aaf1b.tar.gz sonarqube-a8d7a5929e638328796e51163ab16bb82e6aaf1b.zip |
Rename RuleDefinitions to RulesDefinition
Diffstat (limited to 'sonar-plugin-api')
6 files changed, 79 insertions, 78 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromAnnotations.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromAnnotations.java index a9b1143ce15..a5ad00af839 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromAnnotations.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromAnnotations.java @@ -39,7 +39,7 @@ import java.util.List; /** * Read definitions of rules based on the annotations provided by sonar-check-api. * </p> - * It is internally used by {@link RuleDefinitions} and can't be directly + * It is internally used by {@link RulesDefinition} and can't be directly * used by plugins. * * @since 4.2 @@ -48,14 +48,14 @@ class RuleDefinitionsFromAnnotations { private static final Logger LOG = LoggerFactory.getLogger(RuleDefinitionsFromAnnotations.class); - void loadRules(RuleDefinitions.NewRepository repo, Class... annotatedClasses) { + void loadRules(RulesDefinition.NewRepository repo, Class... annotatedClasses) { for (Class annotatedClass : annotatedClasses) { loadRule(repo, annotatedClass); } } @CheckForNull - RuleDefinitions.NewRule loadRule(RuleDefinitions.NewRepository repo, Class clazz) { + RulesDefinition.NewRule loadRule(RulesDefinition.NewRepository repo, Class clazz) { org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(clazz, org.sonar.check.Rule.class); if (ruleAnnotation != null) { return loadRule(repo, clazz, ruleAnnotation); @@ -65,12 +65,12 @@ class RuleDefinitionsFromAnnotations { } } - private RuleDefinitions.NewRule loadRule(RuleDefinitions.NewRepository repo, Class clazz, org.sonar.check.Rule ruleAnnotation) { + private RulesDefinition.NewRule loadRule(RulesDefinition.NewRepository repo, Class clazz, org.sonar.check.Rule ruleAnnotation) { String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName()); String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null); String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null); - RuleDefinitions.NewRule rule = repo.createRule(ruleKey); + RulesDefinition.NewRule rule = repo.createRule(ruleKey); rule.setName(ruleName).setHtmlDescription(description); rule.setSeverity(ruleAnnotation.priority().name()); rule.setTemplate(ruleAnnotation.cardinality() == Cardinality.MULTIPLE); @@ -85,11 +85,11 @@ class RuleDefinitionsFromAnnotations { return rule; } - private void loadParameters(RuleDefinitions.NewRule rule, Field field) { + private void loadParameters(RulesDefinition.NewRule rule, Field field) { org.sonar.check.RuleProperty propertyAnnotation = field.getAnnotation(org.sonar.check.RuleProperty.class); if (propertyAnnotation != null) { String fieldKey = StringUtils.defaultIfEmpty(propertyAnnotation.key(), field.getName()); - RuleDefinitions.NewParam param = rule.createParam(fieldKey) + RulesDefinition.NewParam param = rule.createParam(fieldKey) .setDescription(propertyAnnotation.description()) .setDefaultValue(propertyAnnotation.defaultValue()); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromXml.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromXml.java index 1fbba08db7a..80b9bec7e06 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromXml.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitionsFromXml.java @@ -24,12 +24,13 @@ import org.apache.commons.lang.StringUtils; import org.codehaus.staxmate.SMInputFactory; import org.codehaus.staxmate.in.SMHierarchicCursor; import org.codehaus.staxmate.in.SMInputCursor; -import org.sonar.api.rule.Severity; import org.sonar.api.rule.RuleStatus; +import org.sonar.api.rule.Severity; import org.sonar.check.Cardinality; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -42,7 +43,7 @@ import java.util.List; */ class RuleDefinitionsFromXml { - void loadRules(RuleDefinitions.NewRepository repo, InputStream input, String encoding) { + void loadRules(RulesDefinition.NewRepository repo, InputStream input, String encoding) { Reader reader = null; try { reader = new InputStreamReader(input, encoding); @@ -56,7 +57,7 @@ class RuleDefinitionsFromXml { } } - void loadRules(RuleDefinitions.NewRepository repo, Reader reader) { + void loadRules(RulesDefinition.NewRepository repo, Reader reader) { XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); @@ -79,7 +80,7 @@ class RuleDefinitionsFromXml { } } - private void processRule(RuleDefinitions.NewRepository repo, SMInputCursor ruleC) throws XMLStreamException { + private void processRule(RulesDefinition.NewRepository repo, SMInputCursor ruleC) throws XMLStreamException { String key = null, name = null, description = null, internalKey = null, severity = Severity.defaultSeverity(), status = null; Cardinality cardinality = Cardinality.SINGLE; List<ParamStruct> params = new ArrayList<ParamStruct>(); @@ -135,7 +136,7 @@ class RuleDefinitionsFromXml { tags.add(StringUtils.trim(cursor.collectDescendantText(false))); } } - RuleDefinitions.NewRule rule = repo.createRule(key) + RulesDefinition.NewRule rule = repo.createRule(key) .setHtmlDescription(description) .setSeverity(severity) .setName(name) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java index 0233e286a31..3ff8facfb01 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java @@ -47,7 +47,7 @@ import java.util.Set; * * @since 4.3 */ -public interface RuleDefinitions extends ServerExtension { +public interface RulesDefinition extends ServerExtension { /** * Instantiated by core but not by plugins @@ -208,7 +208,7 @@ public interface RuleDefinitions extends ServerExtension { } @Override - public RuleDefinitions.NewRule loadAnnotatedClass(Class clazz) { + public RulesDefinition.NewRule loadAnnotatedClass(Class clazz) { return new RuleDefinitionsFromAnnotations().loadRule(this, clazz); } @@ -567,7 +567,7 @@ public interface RuleDefinitions extends ServerExtension { } /** - * @see RuleDefinitions.NewRule#setInternalKey(String) + * @see RulesDefinition.NewRule#setInternalKey(String) */ @CheckForNull public String internalKey() { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsFromAnnotationsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromAnnotationsTest.java index f83e13e9f84..65efa9d1258 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsFromAnnotationsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromAnnotationsTest.java @@ -23,21 +23,21 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; -import org.sonar.api.server.rule.RuleDefinitions.NewRule; +import org.sonar.api.server.rule.RulesDefinition.NewRule; import org.sonar.check.Priority; import static org.fest.assertions.Assertions.assertThat; -public class RuleDefinitionsFromAnnotationsTest { +public class RulesDefinitionFromAnnotationsTest { @org.junit.Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void rule_with_property() { - RuleDefinitions.Repository repository = load(RuleWithProperty.class); + RulesDefinition.Repository repository = load(RuleWithProperty.class); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.key()).isEqualTo("foo"); assertThat(rule.status()).isEqualTo(RuleStatus.BETA); assertThat(rule.name()).isEqualTo("bar"); @@ -46,7 +46,7 @@ public class RuleDefinitionsFromAnnotationsTest { assertThat(rule.params()).hasSize(1); assertThat(rule.tags()).isEmpty(); - RuleDefinitions.Param prop = rule.param("property"); + RulesDefinition.Param prop = rule.param("property"); assertThat(prop.key()).isEqualTo("property"); assertThat(prop.description()).isEqualTo("Ignore ?"); assertThat(prop.defaultValue()).isEqualTo("false"); @@ -55,17 +55,17 @@ public class RuleDefinitionsFromAnnotationsTest { @Test public void override_annotation_programmatically() { - RuleDefinitions.Context context = new RuleDefinitions.Context(); - RuleDefinitions.NewRepository newRepository = context.createRepository("squid", "java"); + RulesDefinition.Context context = new RulesDefinition.Context(); + RulesDefinition.NewRepository newRepository = context.createRepository("squid", "java"); NewRule newRule = newRepository.loadAnnotatedClass(RuleWithProperty.class); newRule.setName("Overriden name"); newRule.param("property").setDefaultValue("true"); newRule.param("property").setDescription("Overriden"); newRepository.done(); - RuleDefinitions.Repository repository = context.repository("squid"); + RulesDefinition.Repository repository = context.repository("squid"); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.key()).isEqualTo("foo"); assertThat(rule.status()).isEqualTo(RuleStatus.BETA); assertThat(rule.name()).isEqualTo("Overriden name"); @@ -73,7 +73,7 @@ public class RuleDefinitionsFromAnnotationsTest { assertThat(rule.severity()).isEqualTo(Severity.BLOCKER); assertThat(rule.params()).hasSize(1); - RuleDefinitions.Param prop = rule.param("property"); + RulesDefinition.Param prop = rule.param("property"); assertThat(prop.key()).isEqualTo("property"); assertThat(prop.description()).isEqualTo("Overriden"); assertThat(prop.defaultValue()).isEqualTo("true"); @@ -82,9 +82,9 @@ public class RuleDefinitionsFromAnnotationsTest { @Test public void rule_with_integer_property() { - RuleDefinitions.Repository repository = load(RuleWithIntegerProperty.class); + RulesDefinition.Repository repository = load(RuleWithIntegerProperty.class); - RuleDefinitions.Param prop = repository.rules().get(0).param("property"); + RulesDefinition.Param prop = repository.rules().get(0).param("property"); assertThat(prop.description()).isEqualTo("Max"); assertThat(prop.defaultValue()).isEqualTo("12"); assertThat(prop.type()).isEqualTo(RuleParamType.INTEGER); @@ -92,9 +92,9 @@ public class RuleDefinitionsFromAnnotationsTest { @Test public void rule_with_text_property() { - RuleDefinitions.Repository repository = load(RuleWithTextProperty.class); + RulesDefinition.Repository repository = load(RuleWithTextProperty.class); - RuleDefinitions.Param prop = repository.rules().get(0).param("property"); + RulesDefinition.Param prop = repository.rules().get(0).param("property"); assertThat(prop.description()).isEqualTo("text"); assertThat(prop.defaultValue()).isEqualTo("Long text"); assertThat(prop.type()).isEqualTo(RuleParamType.TEXT); @@ -114,26 +114,26 @@ public class RuleDefinitionsFromAnnotationsTest { @Test public void use_classname_when_missing_key() { - RuleDefinitions.Repository repository = load(RuleWithoutKey.class); + RulesDefinition.Repository repository = load(RuleWithoutKey.class); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.key()).isEqualTo(RuleWithoutKey.class.getCanonicalName()); assertThat(rule.name()).isEqualTo("foo"); } @Test public void rule_with_tags() { - RuleDefinitions.Repository repository = load(RuleWithTags.class); + RulesDefinition.Repository repository = load(RuleWithTags.class); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.tags()).containsOnly("style", "security"); } @Test public void overridden_class() { - RuleDefinitions.Repository repository = load(OverridingRule.class); + RulesDefinition.Repository repository = load(OverridingRule.class); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.key()).isEqualTo("overriding_foo"); assertThat(rule.name()).isEqualTo("Overriding Foo"); assertThat(rule.severity()).isEqualTo(Severity.MAJOR); @@ -141,9 +141,9 @@ public class RuleDefinitionsFromAnnotationsTest { assertThat(rule.params()).hasSize(2); } - private RuleDefinitions.Repository load(Class annotatedClass) { - RuleDefinitions.Context context = new RuleDefinitions.Context(); - RuleDefinitions.NewExtendedRepository newRepository = context.createRepository("squid", "java") + private RulesDefinition.Repository load(Class annotatedClass) { + RulesDefinition.Context context = new RulesDefinition.Context(); + RulesDefinition.NewExtendedRepository newRepository = context.createRepository("squid", "java") .loadAnnotatedClasses(annotatedClass); newRepository.done(); return context.repository("squid"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsFromXmlTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromXmlTest.java index 213a35210f0..8be35912749 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsFromXmlTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromXmlTest.java @@ -22,8 +22,8 @@ package org.sonar.api.server.rule; import com.google.common.base.Charsets; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.rule.Severity; import org.sonar.api.rule.RuleStatus; +import org.sonar.api.rule.Severity; import java.io.InputStreamReader; import java.io.Reader; @@ -32,14 +32,14 @@ import java.io.UnsupportedEncodingException; import static org.fest.assertions.Assertions.assertThat; -public class RuleDefinitionsFromXmlTest { +public class RulesDefinitionFromXmlTest { @org.junit.Rule public final ExpectedException thrown = ExpectedException.none(); - private RuleDefinitions.Repository load(Reader reader) { - RuleDefinitions.Context context = new RuleDefinitions.Context(); - RuleDefinitions.NewRepository newRepository = context.createRepository("squid", "java"); + private RulesDefinition.Repository load(Reader reader) { + RulesDefinition.Context context = new RulesDefinition.Context(); + RulesDefinition.NewRepository newRepository = context.createRepository("squid", "java"); new RuleDefinitionsFromXml().loadRules(newRepository, reader); newRepository.done(); return context.repository("squid"); @@ -48,10 +48,10 @@ public class RuleDefinitionsFromXmlTest { @Test public void should_parse_xml() throws Exception { InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("/org/sonar/api/server/rule/RuleDefinitionsFromXmlTest/rules.xml"), Charsets.UTF_8.name()); - RuleDefinitions.Repository repository = load(reader); + RulesDefinition.Repository repository = load(reader); assertThat(repository.rules()).hasSize(2); - RuleDefinitions.Rule rule = repository.rule("complete"); + RulesDefinition.Rule rule = repository.rule("complete"); assertThat(rule.key()).isEqualTo("complete"); assertThat(rule.name()).isEqualTo("Complete"); assertThat(rule.htmlDescription()).isEqualTo("Description of Complete"); @@ -62,7 +62,7 @@ public class RuleDefinitionsFromXmlTest { assertThat(rule.tags()).containsOnly("style", "security"); assertThat(rule.params()).hasSize(2); - RuleDefinitions.Param ignore = rule.param("ignore"); + RulesDefinition.Param ignore = rule.param("ignore"); assertThat(ignore.key()).isEqualTo("ignore"); assertThat(ignore.description()).isEqualTo("Ignore ?"); assertThat(ignore.defaultValue()).isEqualTo("false"); @@ -97,10 +97,10 @@ public class RuleDefinitionsFromXmlTest { @Test public void test_utf8_encoding() throws UnsupportedEncodingException { InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("/org/sonar/api/server/rule/RuleDefinitionsFromXmlTest/utf8.xml"), Charsets.UTF_8.name()); - RuleDefinitions.Repository repository = load(reader); + RulesDefinition.Repository repository = load(reader); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.key()).isEqualTo("com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck"); assertThat(rule.name()).isEqualTo("M & M"); assertThat(rule.htmlDescription().charAt(0)).isEqualTo('\u00E9'); @@ -112,10 +112,10 @@ public class RuleDefinitionsFromXmlTest { public void should_support_deprecated_format() throws UnsupportedEncodingException { // the deprecated format uses some attributes instead of nodes InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("/org/sonar/api/server/rule/RuleDefinitionsFromXmlTest/deprecated.xml"), Charsets.UTF_8.name()); - RuleDefinitions.Repository repository = load(reader); + RulesDefinition.Repository repository = load(reader); assertThat(repository.rules()).hasSize(1); - RuleDefinitions.Rule rule = repository.rules().get(0); + RulesDefinition.Rule rule = repository.rules().get(0); assertThat(rule.key()).isEqualTo("org.sonar.it.checkstyle.MethodsCountCheck"); assertThat(rule.internalKey()).isEqualTo("Checker/TreeWalker/org.sonar.it.checkstyle.MethodsCountCheck"); assertThat(rule.severity()).isEqualTo(Severity.CRITICAL); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java index 023719c4ea1..f37ec36b71d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java @@ -30,9 +30,9 @@ import java.net.URL; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; -public class RuleDefinitionsTest { +public class RulesDefinitionTest { - RuleDefinitions.Context context = new RuleDefinitions.Context(); + RulesDefinition.Context context = new RulesDefinition.Context(); @Test public void define_repositories() throws Exception { @@ -42,13 +42,13 @@ public class RuleDefinitionsTest { context.createRepository("checkstyle", "java").done(); assertThat(context.repositories()).hasSize(2); - RuleDefinitions.Repository findbugs = context.repository("findbugs"); + RulesDefinition.Repository findbugs = context.repository("findbugs"); assertThat(findbugs).isNotNull(); assertThat(findbugs.key()).isEqualTo("findbugs"); assertThat(findbugs.language()).isEqualTo("java"); assertThat(findbugs.name()).isEqualTo("Findbugs"); assertThat(findbugs.rules()).isEmpty(); - RuleDefinitions.Repository checkstyle = context.repository("checkstyle"); + RulesDefinition.Repository checkstyle = context.repository("checkstyle"); assertThat(checkstyle).isNotNull(); assertThat(checkstyle.key()).isEqualTo("checkstyle"); assertThat(checkstyle.language()).isEqualTo("java"); @@ -65,7 +65,7 @@ public class RuleDefinitionsTest { @Test public void define_rules() { - RuleDefinitions.NewRepository newFindbugs = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newFindbugs = context.createRepository("findbugs", "java"); newFindbugs.createRule("NPE") .setName("Detect NPE") .setHtmlDescription("Detect <code>java.lang.NullPointerException</code>") @@ -82,10 +82,10 @@ public class RuleDefinitionsTest { newFindbugs.createRule("ABC").setName("ABC").setHtmlDescription("ABC"); newFindbugs.done(); - RuleDefinitions.Repository findbugs = context.repository("findbugs"); + RulesDefinition.Repository findbugs = context.repository("findbugs"); assertThat(findbugs.rules()).hasSize(2); - RuleDefinitions.Rule npeRule = findbugs.rule("NPE"); + RulesDefinition.Rule npeRule = findbugs.rule("NPE"); assertThat(npeRule.key()).isEqualTo("NPE"); assertThat(npeRule.name()).isEqualTo("Detect NPE"); assertThat(npeRule.severity()).isEqualTo(Severity.BLOCKER); @@ -104,18 +104,18 @@ public class RuleDefinitionsTest { assertThat(npeRule.repository()).isSameAs(findbugs); // test equals() and hashCode() - RuleDefinitions.Rule otherRule = findbugs.rule("ABC"); + RulesDefinition.Rule otherRule = findbugs.rule("ABC"); assertThat(npeRule).isEqualTo(npeRule).isNotEqualTo(otherRule).isNotEqualTo("NPE").isNotEqualTo(null); assertThat(npeRule.hashCode()).isEqualTo(npeRule.hashCode()); } @Test public void define_rule_with_default_fields() { - RuleDefinitions.NewRepository newFindbugs = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newFindbugs = context.createRepository("findbugs", "java"); newFindbugs.createRule("NPE").setName("NPE").setHtmlDescription("NPE"); newFindbugs.done(); - RuleDefinitions.Rule rule = context.repository("findbugs").rule("NPE"); + RulesDefinition.Rule rule = context.repository("findbugs").rule("NPE"); assertThat(rule.key()).isEqualTo("NPE"); assertThat(rule.severity()).isEqualTo(Severity.MAJOR); assertThat(rule.params()).isEmpty(); @@ -130,23 +130,23 @@ public class RuleDefinitionsTest { @Test public void define_rule_parameters() { - RuleDefinitions.NewRepository newFindbugs = context.createRepository("findbugs", "java"); - RuleDefinitions.NewRule newNpe = newFindbugs.createRule("NPE").setName("NPE").setHtmlDescription("NPE"); + RulesDefinition.NewRepository newFindbugs = context.createRepository("findbugs", "java"); + RulesDefinition.NewRule newNpe = newFindbugs.createRule("NPE").setName("NPE").setHtmlDescription("NPE"); newNpe.createParam("level").setDefaultValue("LOW").setName("Level").setDescription("The level").setType(RuleParamType.INTEGER); newNpe.createParam("effort"); newFindbugs.done(); - RuleDefinitions.Rule rule = context.repository("findbugs").rule("NPE"); + RulesDefinition.Rule rule = context.repository("findbugs").rule("NPE"); assertThat(rule.params()).hasSize(2); - RuleDefinitions.Param level = rule.param("level"); + RulesDefinition.Param level = rule.param("level"); assertThat(level.key()).isEqualTo("level"); assertThat(level.name()).isEqualTo("Level"); assertThat(level.description()).isEqualTo("The level"); assertThat(level.defaultValue()).isEqualTo("LOW"); assertThat(level.type()).isEqualTo(RuleParamType.INTEGER); - RuleDefinitions.Param effort = rule.param("effort"); + RulesDefinition.Param effort = rule.param("effort"); assertThat(effort.key()).isEqualTo("effort").isEqualTo(effort.name()); assertThat(effort.description()).isNull(); assertThat(effort.defaultValue()).isNull(); @@ -159,17 +159,17 @@ public class RuleDefinitionsTest { @Test public void sanitize_rule_name() { - RuleDefinitions.NewRepository newFindbugs = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newFindbugs = context.createRepository("findbugs", "java"); newFindbugs.createRule("NPE").setName(" \n NullPointer \n ").setHtmlDescription("NPE"); newFindbugs.done(); - RuleDefinitions.Rule rule = context.repository("findbugs").rule("NPE"); + RulesDefinition.Rule rule = context.repository("findbugs").rule("NPE"); assertThat(rule.name()).isEqualTo("NullPointer"); } @Test public void sanitize_remediation_factor_and_offset() { - RuleDefinitions.NewRepository newFindbugs = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newFindbugs = context.createRepository("findbugs", "java"); newFindbugs.createRule("NPE") .setName("Detect NPE") .setHtmlDescription("NPE") @@ -177,7 +177,7 @@ public class RuleDefinitionsTest { .setRemediationOffset(" 10 mi n "); newFindbugs.done(); - RuleDefinitions.Rule npeRule = context.repository("findbugs").rule("NPE"); + RulesDefinition.Rule npeRule = context.repository("findbugs").rule("NPE"); assertThat(npeRule.remediationFactor()).isEqualTo("1h"); assertThat(npeRule.remediationOffset()).isEqualTo("10min"); } @@ -187,7 +187,7 @@ public class RuleDefinitionsTest { assertThat(context.extendedRepositories()).isEmpty(); // for example fb-contrib - RuleDefinitions.NewExtendedRepository newFindbugs = context.extendRepository("findbugs", "java"); + RulesDefinition.NewExtendedRepository newFindbugs = context.extendRepository("findbugs", "java"); newFindbugs.createRule("NPE").setName("NPE").setHtmlDescription("NPE"); newFindbugs.done(); @@ -196,7 +196,7 @@ public class RuleDefinitionsTest { assertThat(context.extendedRepositories("other")).isEmpty(); assertThat(context.extendedRepositories("findbugs")).hasSize(1); - RuleDefinitions.ExtendedRepository findbugs = context.extendedRepositories("findbugs").get(0); + RulesDefinition.ExtendedRepository findbugs = context.extendedRepositories("findbugs").get(0); assertThat(findbugs.language()).isEqualTo("java"); assertThat(findbugs.rule("NPE")).isNotNull(); } @@ -221,7 +221,7 @@ public class RuleDefinitionsTest { @Test public void warning_if_duplicated_rule_keys() { - RuleDefinitions.NewRepository findbugs = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository findbugs = context.createRepository("findbugs", "java"); findbugs.createRule("NPE"); findbugs.createRule("NPE"); // do not fail as long as http://jira.codehaus.org/browse/SONARJAVA-428 is not fixed @@ -229,7 +229,7 @@ public class RuleDefinitionsTest { @Test public void fail_if_duplicated_rule_param_keys() { - RuleDefinitions.NewRule rule = context.createRepository("findbugs", "java").createRule("NPE"); + RulesDefinition.NewRule rule = context.createRepository("findbugs", "java").createRule("NPE"); rule.createParam("level"); try { rule.createParam("level"); @@ -241,7 +241,7 @@ public class RuleDefinitionsTest { @Test public void fail_if_blank_rule_name() { - RuleDefinitions.NewRepository newRepository = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName(null).setHtmlDescription("NPE"); try { newRepository.done(); @@ -265,17 +265,17 @@ public class RuleDefinitionsTest { @Test public void load_rule_description_from_file() { - RuleDefinitions.NewRepository newRepository = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName("NPE").setHtmlDescription(getClass().getResource("/org/sonar/api/server/rule/RuleDefinitionsTest/sample.html")); newRepository.done(); - RuleDefinitions.Rule rule = context.repository("findbugs").rule("NPE"); + RulesDefinition.Rule rule = context.repository("findbugs").rule("NPE"); assertThat(rule.htmlDescription()).isEqualTo("description of rule loaded from file"); } @Test public void fail_to_load_rule_description_from_file() { - RuleDefinitions.NewRepository newRepository = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName("NPE").setHtmlDescription((URL)null); try { newRepository.done(); @@ -287,7 +287,7 @@ public class RuleDefinitionsTest { @Test public void fail_if_blank_rule_html_description() { - RuleDefinitions.NewRepository newRepository = context.createRepository("findbugs", "java"); + RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName("NPE").setHtmlDescription((String)null); try { newRepository.done(); |