diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-03-25 18:02:53 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-03-25 18:02:53 +0100 |
commit | 0abfc8ad75bb91dceba66f9e5905268312bed038 (patch) | |
tree | 0ba58a14eb1c4aec7b1274ca84c373f718ca60fb /sonar-plugin-api | |
parent | e2b033fccc4e306a11b77b3632b388f556385815 (diff) | |
download | sonarqube-0abfc8ad75bb91dceba66f9e5905268312bed038.tar.gz sonarqube-0abfc8ad75bb91dceba66f9e5905268312bed038.zip |
SONAR-4908 rename RulesDefinition#setDebtCharacteristic() to setDebtSubCharacteristic()
-> better follow SQALE method
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java | 29 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java | 14 |
2 files changed, 23 insertions, 20 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java index 79d08f46588..fff3f96e797 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java @@ -75,7 +75,7 @@ import java.util.Set; * .setSeverity(Severity.MINOR); * * x1Rule - * .setDebtCharacteristic("INTEGRATION_TESTABILITY") + * .setDebtSubCharacteristic("INTEGRATION_TESTABILITY") * .setDebtRemediationFunction(x1Rule.debtRemediationFunctions().linearWithOffset("1h", "30min")); * * x1Rule.createParam("acceptWhitespace") @@ -90,7 +90,7 @@ import java.util.Set; * </pre> * <p/> * If rules are declared in a XML file with the standard SonarQube format, then it can be loaded by using : - * + * <p/> * <pre> * public class JsSquidRulesDefinition implements RulesDefinition { * @@ -109,10 +109,10 @@ import java.util.Set; * } * } * </pre> - * + * <p/> * In the above example, XML file must contain name and description of each rule. If it's not the case, then the * (deprecated) English bundles can be used : - * + * <p/> * <pre> * public class JsSquidRulesDefinition implements RulesDefinition { * @@ -376,7 +376,7 @@ public interface RulesDefinition extends ServerExtension { private String name, htmlDescription, internalKey, severity = Severity.MAJOR; private boolean template; private RuleStatus status = RuleStatus.defaultStatus(); - private String debtCharacteristic; + private String debtSubCharacteristic; private DebtRemediationFunction debtRemediationFunction; private String effortToFixDescription; private final Set<String> tags = Sets.newTreeSet(); @@ -440,11 +440,14 @@ public interface RulesDefinition extends ServerExtension { return this; } - public NewRule setDebtCharacteristic(@Nullable String debtCharacteristic) { - this.debtCharacteristic = debtCharacteristic; + public NewRule setDebtSubCharacteristic(@Nullable String s) { + this.debtSubCharacteristic = s; return this; } + /** + * Factory of {@link org.sonar.api.server.debt.DebtRemediationFunction} + */ public DebtRemediationFunctions debtRemediationFunctions() { return functions; } @@ -517,8 +520,8 @@ public interface RulesDefinition extends ServerExtension { if (Strings.isNullOrEmpty(htmlDescription)) { throw new IllegalStateException(String.format("HTML description of rule %s is empty", this)); } - if ((Strings.isNullOrEmpty(debtCharacteristic) && debtRemediationFunction != null) || (!Strings.isNullOrEmpty(debtCharacteristic) && debtRemediationFunction == null)) { - throw new IllegalStateException(String.format("Both debt characteristic and debt remediation function should be defined on rule '%s'", this)); + if ((Strings.isNullOrEmpty(debtSubCharacteristic) && debtRemediationFunction != null) || (!Strings.isNullOrEmpty(debtSubCharacteristic) && debtRemediationFunction == null)) { + throw new IllegalStateException(String.format("Both debt sub-characteristic and debt remediation function should be defined on rule '%s'", this)); } } @@ -533,7 +536,7 @@ public interface RulesDefinition extends ServerExtension { private final Repository repository; private final String repoKey, key, name, htmlDescription, internalKey, severity; private final boolean template; - private final String debtCharacteristic; + private final String debtSubCharacteristic; private final DebtRemediationFunction debtRemediationFunction; private final String effortToFixDescription; private final Set<String> tags; @@ -550,7 +553,7 @@ public interface RulesDefinition extends ServerExtension { this.severity = newRule.severity; this.template = newRule.template; this.status = newRule.status; - this.debtCharacteristic = newRule.debtCharacteristic; + this.debtSubCharacteristic = newRule.debtSubCharacteristic; this.debtRemediationFunction = newRule.debtRemediationFunction; this.effortToFixDescription = newRule.effortToFixDescription; this.tags = ImmutableSortedSet.copyOf(newRule.tags); @@ -591,8 +594,8 @@ public interface RulesDefinition extends ServerExtension { } @CheckForNull - public String debtCharacteristic() { - return debtCharacteristic; + public String debtSubCharacteristic() { + return debtSubCharacteristic; } @CheckForNull diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java index 96351855f53..186fe99dc22 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java @@ -71,7 +71,7 @@ public class RulesDefinitionTest { .setSeverity(Severity.BLOCKER) .setInternalKey("/something") .setStatus(RuleStatus.BETA) - .setDebtCharacteristic("COMPILER") + .setDebtSubCharacteristic("COMPILER") .setEffortToFixDescription("squid.S115.effortToFix") .setTags("one", "two") .addTags("two", "three", "four"); @@ -93,7 +93,7 @@ public class RulesDefinitionTest { assertThat(rule.internalKey()).isEqualTo("/something"); assertThat(rule.template()).isFalse(); assertThat(rule.status()).isEqualTo(RuleStatus.BETA); - assertThat(rule.debtCharacteristic()).isEqualTo("COMPILER"); + assertThat(rule.debtSubCharacteristic()).isEqualTo("COMPILER"); assertThat(rule.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET); assertThat(rule.debtRemediationFunction().factor()).isEqualTo("1h"); assertThat(rule.debtRemediationFunction().offset()).isEqualTo("10min"); @@ -120,7 +120,7 @@ public class RulesDefinitionTest { assertThat(rule.internalKey()).isNull(); assertThat(rule.status()).isEqualTo(RuleStatus.defaultStatus()); assertThat(rule.tags()).isEmpty(); - assertThat(rule.debtCharacteristic()).isNull(); + assertThat(rule.debtSubCharacteristic()).isNull(); assertThat(rule.debtRemediationFunction()).isNull(); } @@ -302,12 +302,12 @@ public class RulesDefinitionTest { public void fail_if_define_characteristic_without_function() { RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); newRepository.createRule("NPE").setName("NPE").setHtmlDescription("Detect <code>java.lang.NullPointerException</code>") - .setDebtCharacteristic("COMPILER"); + .setDebtSubCharacteristic("COMPILER"); try { newRepository.done(); fail(); } catch (IllegalStateException e) { - assertThat(e).hasMessage("Both debt characteristic and debt remediation function should be defined on rule '[repository=findbugs, key=NPE]'"); + assertThat(e).hasMessage("Both debt sub-characteristic and debt remediation function should be defined on rule '[repository=findbugs, key=NPE]'"); } } @@ -315,13 +315,13 @@ public class RulesDefinitionTest { public void fail_if_define_function_without_characteristic() { RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); RulesDefinition.NewRule newRule = newRepository.createRule("NPE").setName("NPE").setHtmlDescription("Detect <code>java.lang.NullPointerException</code>") - .setDebtCharacteristic(""); + .setDebtSubCharacteristic(""); newRule.setDebtRemediationFunction(newRule.debtRemediationFunctions().linearWithOffset("1h", "10min")); try { newRepository.done(); fail(); } catch (IllegalStateException e) { - assertThat(e).hasMessage("Both debt characteristic and debt remediation function should be defined on rule '[repository=findbugs, key=NPE]'"); + assertThat(e).hasMessage("Both debt sub-characteristic and debt remediation function should be defined on rule '[repository=findbugs, key=NPE]'"); } } |