aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-09-28 16:44:57 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-09-28 16:45:11 +0200
commit74c8f07db471391618d80ea30101e2af3f34bb35 (patch)
tree865a3ecdf7e807b89036338aea62979a44ca5045
parent24b80b59a96988e27c6aae6234d7d00c22ebc262 (diff)
downloadsonarqube-74c8f07db471391618d80ea30101e2af3f34bb35.tar.gz
sonarqube-74c8f07db471391618d80ea30101e2af3f34bb35.zip
Fix quality flaws
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java21
1 files changed, 7 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
index a5bd987880c..eaba94744d1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
@@ -21,13 +21,14 @@
package org.sonar.api.server.debt.internal;
import com.google.common.base.Objects;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.utils.Duration;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
+import static com.google.common.base.Preconditions.checkArgument;
public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
@@ -75,24 +76,16 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
}
private void validate() {
- if (type == null) {
- throw new IllegalArgumentException("Remediation function type cannot be null");
- }
+ checkArgument(type != null, "Remediation function type cannot be null");
switch (type) {
case LINEAR:
- if (this.coefficient == null || this.offset != null) {
- throw new IllegalArgumentException("Linear functions must only have a non empty coefficient");
- }
+ checkArgument(this.coefficient != null && this.offset == null, "Linear functions must only have a non empty coefficient");
break;
case LINEAR_OFFSET:
- if (this.coefficient == null || this.offset == null) {
- throw new IllegalArgumentException("Linear with offset functions must have both non null coefficient and offset");
- }
+ checkArgument(this.coefficient != null && this.offset != null, "Linear with offset functions must have both non null coefficient and offset");
break;
case CONSTANT_ISSUE:
- if (this.coefficient != null || this.offset == null) {
- throw new IllegalArgumentException("Constant/issue functions must only have a non empty offset");
- }
+ checkArgument(this.coefficient == null && this.offset != null, "Constant/issue functions must only have a non empty offset");
break;
default:
throw new IllegalArgumentException(String.format("Unknown type on %s", this));