import com.google.common.base.Objects;
import com.google.common.base.Strings;
-import org.sonar.api.batch.rule.*;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
+import org.sonar.api.batch.rule.ActiveRule;
+import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.rule.Rule;
+import org.sonar.api.batch.rule.Rules;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.resources.Project;
import org.sonar.api.rule.RuleKey;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.debt.DebtCharacteristic;
import org.sonar.api.batch.debt.DebtModel;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.batch.debt.internal.DefaultDebtModel;
-import org.sonar.api.batch.rule.DebtRemediationFunction;
import org.sonar.api.batch.rule.Rules;
import org.sonar.api.batch.rule.internal.NewRule;
import org.sonar.api.batch.rule.internal.RulesBuilder;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.api.batch.rule.DebtRemediationFunction;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
import org.sonar.api.batch.rule.internal.RulesBuilder;
import org.sonar.api.issue.internal.DefaultIssue;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.batch.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.batch.debt.internal.DefaultDebtModel;
-import org.sonar.api.batch.rule.DebtRemediationFunction;
import org.sonar.api.batch.rule.Rule;
import org.sonar.api.batch.rule.RuleParam;
import org.sonar.api.batch.rule.Rules;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.api.batch.debt;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+import org.sonar.api.utils.Duration;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+/**
+ * @since 4.3
+ */
+public class DebtRemediationFunction {
+
+ public static enum Type {
+ LINEAR, LINEAR_OFFSET, CONSTANT_ISSUE
+ }
+
+ private Type type;
+ private Duration coefficient;
+ private Duration offset;
+
+ private DebtRemediationFunction(Type type, @Nullable Duration coefficient, @Nullable Duration offset) {
+ this.type = type;
+ this.coefficient = coefficient;
+ this.offset = offset;
+ }
+
+ public static DebtRemediationFunction create(Type type, @Nullable Duration coefficient, @Nullable Duration offset) {
+ return new DebtRemediationFunction(type, coefficient, offset);
+ }
+
+ public static DebtRemediationFunction createLinear(Duration coefficient) {
+ return new DebtRemediationFunction(Type.LINEAR, coefficient, null);
+ }
+
+ public static DebtRemediationFunction createLinearWithOffset(Duration coefficient, Duration offset) {
+ return new DebtRemediationFunction(Type.LINEAR_OFFSET, coefficient, offset);
+ }
+
+ public static DebtRemediationFunction createConstantPerIssue(Duration offset) {
+ return new DebtRemediationFunction(Type.CONSTANT_ISSUE, null, offset);
+ }
+
+ public Type type() {
+ return type;
+ }
+
+ @CheckForNull
+ public Duration coefficient() {
+ return coefficient;
+ }
+
+ @CheckForNull
+ public Duration offset() {
+ return offset;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DebtRemediationFunction that = (DebtRemediationFunction) o;
+ return new EqualsBuilder()
+ .append(type, that.type())
+ .append(coefficient, that.coefficient())
+ .append(offset, that.offset())
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(15, 31)
+ .append(type)
+ .append(coefficient)
+ .append(offset)
+ .toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
+ }
+}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.api.batch.rule;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.utils.Duration;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-/**
- * @since 4.3
- */
-public class DebtRemediationFunction {
-
- public static enum Type {
- LINEAR, LINEAR_OFFSET, CONSTANT_ISSUE
- }
-
- private Type type;
- private Duration coefficient;
- private Duration offset;
-
- private DebtRemediationFunction(Type type, @Nullable Duration coefficient, @Nullable Duration offset) {
- this.type = type;
- this.coefficient = coefficient;
- this.offset = offset;
- }
-
- public static DebtRemediationFunction create(Type type, @Nullable Duration coefficient, @Nullable Duration offset) {
- return new DebtRemediationFunction(type, coefficient, offset);
- }
-
- public static DebtRemediationFunction createLinear(Duration coefficient) {
- return new DebtRemediationFunction(Type.LINEAR, coefficient, null);
- }
-
- public static DebtRemediationFunction createLinearWithOffset(Duration coefficient, Duration offset) {
- return new DebtRemediationFunction(Type.LINEAR_OFFSET, coefficient, offset);
- }
-
- public static DebtRemediationFunction createConstantPerIssue(Duration offset) {
- return new DebtRemediationFunction(Type.CONSTANT_ISSUE, null, offset);
- }
-
- public Type type() {
- return type;
- }
-
- @CheckForNull
- public Duration coefficient() {
- return coefficient;
- }
-
- @CheckForNull
- public Duration offset() {
- return offset;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DebtRemediationFunction that = (DebtRemediationFunction) o;
- return new EqualsBuilder()
- .append(type, that.type())
- .append(coefficient, that.coefficient())
- .append(offset, that.offset())
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(15, 31)
- .append(type)
- .append(coefficient)
- .append(offset)
- .toHashCode();
- }
-
- @Override
- public String toString() {
- return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
- }
-}
package org.sonar.api.batch.rule;
import com.google.common.annotations.Beta;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
package org.sonar.api.batch.rule.internal;
import com.google.common.collect.ImmutableMap;
-import org.sonar.api.batch.rule.DebtRemediationFunction;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.batch.rule.Rule;
import org.sonar.api.batch.rule.RuleParam;
import org.sonar.api.rule.RuleKey;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.rule.DebtRemediationFunction;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.api.batch.debt;
+
+import org.junit.Test;
+import org.sonar.api.utils.Duration;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DebtRemediationFunctionTest {
+
+ @Test
+ public void create_linear() throws Exception {
+ DebtRemediationFunction function = DebtRemediationFunction.createLinear(Duration.create(10));
+ assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.LINEAR);
+ assertThat(function.coefficient()).isEqualTo(Duration.create(10));
+ assertThat(function.offset()).isNull();
+ }
+
+ @Test
+ public void create_linear_with_offset() throws Exception {
+ DebtRemediationFunction function = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
+ assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
+ assertThat(function.coefficient()).isEqualTo(Duration.create(10));
+ assertThat(function.offset()).isEqualTo(Duration.create(5));
+ }
+
+ @Test
+ public void create_constant_per_issue() throws Exception {
+ DebtRemediationFunction function = DebtRemediationFunction.createConstantPerIssue(Duration.create(10));
+ assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE);
+ assertThat(function.coefficient()).isNull();
+ assertThat(function.offset()).isEqualTo(Duration.create(10));
+ }
+
+ @Test
+ public void test_equals_and_hashcode() throws Exception {
+ DebtRemediationFunction function = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
+ DebtRemediationFunction functionWithSameValue = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
+ DebtRemediationFunction functionWithDifferentType = DebtRemediationFunction.createConstantPerIssue(Duration.create(5));
+
+ assertThat(function).isEqualTo(function);
+ assertThat(function).isEqualTo(functionWithSameValue);
+ assertThat(function).isNotEqualTo(functionWithDifferentType);
+ assertThat(function).isNotEqualTo(DebtRemediationFunction.createLinearWithOffset(Duration.create(11), Duration.create(5)));
+ assertThat(function).isNotEqualTo(DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(6)));
+ assertThat(function).isNotEqualTo(DebtRemediationFunction.createLinear(Duration.create(10)));
+ assertThat(function).isNotEqualTo(DebtRemediationFunction.createConstantPerIssue(Duration.create(6)));
+
+ assertThat(function.hashCode()).isEqualTo(function.hashCode());
+ assertThat(function.hashCode()).isEqualTo(functionWithSameValue.hashCode());
+ assertThat(function.hashCode()).isNotEqualTo(functionWithDifferentType.hashCode());
+ }
+
+ @Test
+ public void test_to_string() throws Exception {
+ assertThat(DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5)).toString()).isNotNull();
+ }
+}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.api.batch.rule;
-
-import org.junit.Test;
-import org.sonar.api.utils.Duration;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class DefaultDebtRemediationFunctionTest {
-
- @Test
- public void create_linear() throws Exception {
- DebtRemediationFunction function = DebtRemediationFunction.createLinear(Duration.create(10));
- assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.LINEAR);
- assertThat(function.coefficient()).isEqualTo(Duration.create(10));
- assertThat(function.offset()).isNull();
- }
-
- @Test
- public void create_linear_with_offset() throws Exception {
- DebtRemediationFunction function = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
- assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(function.coefficient()).isEqualTo(Duration.create(10));
- assertThat(function.offset()).isEqualTo(Duration.create(5));
- }
-
- @Test
- public void create_constant_per_issue() throws Exception {
- DebtRemediationFunction function = DebtRemediationFunction.createConstantPerIssue(Duration.create(10));
- assertThat(function.type()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE);
- assertThat(function.coefficient()).isNull();
- assertThat(function.offset()).isEqualTo(Duration.create(10));
- }
-
- @Test
- public void test_equals_and_hashcode() throws Exception {
- DebtRemediationFunction function = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
- DebtRemediationFunction functionWithSameValue = DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5));
- DebtRemediationFunction functionWithDifferentType = DebtRemediationFunction.createConstantPerIssue(Duration.create(5));
-
- assertThat(function).isEqualTo(function);
- assertThat(function).isEqualTo(functionWithSameValue);
- assertThat(function).isNotEqualTo(functionWithDifferentType);
- assertThat(function).isNotEqualTo(DebtRemediationFunction.createLinearWithOffset(Duration.create(11), Duration.create(5)));
- assertThat(function).isNotEqualTo(DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(6)));
- assertThat(function).isNotEqualTo(DebtRemediationFunction.createLinear(Duration.create(10)));
- assertThat(function).isNotEqualTo(DebtRemediationFunction.createConstantPerIssue(Duration.create(6)));
-
- assertThat(function.hashCode()).isEqualTo(function.hashCode());
- assertThat(function.hashCode()).isEqualTo(functionWithSameValue.hashCode());
- assertThat(function.hashCode()).isNotEqualTo(functionWithDifferentType.hashCode());
- }
-
- @Test
- public void test_to_string() throws Exception {
- assertThat(DebtRemediationFunction.createLinearWithOffset(Duration.create(10), Duration.create(5)).toString()).isNotNull();
- }
-}
package org.sonar.api.batch.rule.internal;
import org.junit.Test;
-import org.sonar.api.batch.rule.DebtRemediationFunction;
+import org.sonar.api.batch.debt.DebtRemediationFunction;
import org.sonar.api.batch.rule.Rule;
import org.sonar.api.batch.rule.Rules;
import org.sonar.api.rule.RuleKey;