From: Julien Lancelot Date: Wed, 19 Mar 2014 13:22:24 +0000 (+0100) Subject: SONAR-4915 Do not display a warning when no effort to fix description with linear... X-Git-Tag: 4.3~362 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6fc2b3da4d2a6547e5f440b46bc4606a4a0ea572;p=sonarqube.git SONAR-4915 Do not display a warning when no effort to fix description with linear and linear with offset functions --- 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 3c213f18b97..68b4d17d9ff 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 @@ -23,7 +23,6 @@ import com.google.common.base.Strings; import com.google.common.collect.*; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ServerExtension; import org.sonar.api.rule.RuleStatus; @@ -50,8 +49,6 @@ import java.util.Set; */ public interface RulesDefinition extends ServerExtension { - static final Logger LOG = LoggerFactory.getLogger(RulesDefinition.class); - /** * Instantiated by core but not by plugins */ @@ -446,13 +443,6 @@ public interface RulesDefinition extends ServerExtension { 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 (debtRemediationFunction != null && - (DebtRemediationFunction.Type.LINEAR.equals(debtRemediationFunction.type()) || DebtRemediationFunction.Type.LINEAR_OFFSET.equals(debtRemediationFunction.type())) && - Strings.isNullOrEmpty(effortToFixDescription)) { - // Only generate a warning for the moment, but should throw an exception when most of plugin defines rules with Java API instead of XML - LOG.warn(String.format("'Rule '%s' should have a description for the remediation function parameter " + - "as it's using a 'Linear' or 'Linear with offset' remediation function ", this)); - } } @Override 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 a14051dfc4d..2cc13c0abc8 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 @@ -321,24 +321,4 @@ public class RulesDefinitionTest { } } - @Test - public void not_fail_if_linear_but_no_effort_to_fix_description() { - RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); - newRepository.createRule("NPE").setName("NPE").setHtmlDescription("Detect java.lang.NullPointerException") - .setDebtCharacteristic("COMPILER") - .setDebtRemediationFunction(DebtRemediationFunction.createLinear("1h")); - newRepository.done(); - // A warning log is displayed - } - - @Test - public void not_fail_if_linear_offset_but_no_effort_to_fix_description() { - RulesDefinition.NewRepository newRepository = context.createRepository("findbugs", "java"); - newRepository.createRule("NPE").setName("NPE").setHtmlDescription("Detect java.lang.NullPointerException") - .setDebtCharacteristic("COMPILER") - .setDebtRemediationFunction(DebtRemediationFunction.createLinearWithOffset("1h", "10min")); - newRepository.done(); - // A warning log is displayed - } - }