diff options
10 files changed, 19 insertions, 24 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java b/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java index 49d56286d9a..330f60e74ab 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java @@ -23,6 +23,7 @@ import org.apache.commons.lang.builder.ReflectionToStringBuilder; import javax.annotation.CheckForNull; import javax.annotation.Nullable; + import java.util.Arrays; import java.util.List; @@ -123,7 +124,7 @@ public class Result<T> { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (this.getClass() != o.getClass()) { return false; } Message message = (Message) o; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/RulesAggregation.java b/server/sonar-server/src/main/java/org/sonar/server/issue/RulesAggregation.java index 920b84c60dc..8567a40d295 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/RulesAggregation.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/RulesAggregation.java @@ -71,17 +71,12 @@ public class RulesAggregation { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (this.getClass() != o.getClass()) { return false; } Rule rule = (Rule) o; - - if (!ruleKey.equals(rule.ruleKey)) { - return false; - } - - return true; + return ruleKey.equals(rule.ruleKey); } @Override diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java index 82ab1db55a6..51ecbe54294 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java @@ -19,11 +19,10 @@ */ package org.sonar.duplications.detector.suffixtree; -import java.util.List; - +import com.google.common.collect.Lists; import org.sonar.duplications.block.Block; -import com.google.common.collect.Lists; +import java.util.List; /** * Simplifies construction of <a href="http://en.wikipedia.org/wiki/Generalised_suffix_tree">generalised suffix-tree</a>. @@ -92,7 +91,7 @@ public final class TextSet extends AbstractText { @Override public boolean equals(Object obj) { - return (obj instanceof Terminator) && (((Terminator) obj).stringNumber == stringNumber); + return (this.getClass() == obj.getClass()) && (((Terminator) obj).stringNumber == stringNumber); } @Override diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java index 01b7273da1c..b840c2f55f0 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java @@ -135,7 +135,7 @@ public class CloneGroup { */ @Override public boolean equals(Object object) { - if (!(object instanceof CloneGroup)) { + if (this.getClass() != object.getClass()) { return false; } CloneGroup another = (CloneGroup) object; diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java index 6a569e27eae..630f52c1350 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java @@ -64,7 +64,7 @@ public class ClonePart implements CodeFragment { @Override public boolean equals(Object obj) { - if (obj instanceof ClonePart) { + if (this.getClass() == obj.getClass()) { ClonePart another = (ClonePart) obj; return another.resourceId.equals(resourceId) && another.startLine == startLine diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java index 49e9e90f743..dc1c8ac402d 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java @@ -82,7 +82,7 @@ public class Statement implements CodeFragment { @Override public boolean equals(Object obj) { - if (!(obj instanceof Statement)) { + if (this.getClass() != obj.getClass()) { return false; } Statement other = (Statement) obj; diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/token/Token.java b/sonar-duplications/src/main/java/org/sonar/duplications/token/Token.java index 06525a4ccda..c1c374e7f52 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/token/Token.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/token/Token.java @@ -50,7 +50,7 @@ public class Token { @Override public boolean equals(Object object) { - if (object instanceof Token) { + if (this.getClass() == object.getClass()) { Token anotherToken = (Token) object; return anotherToken.line == line && anotherToken.column == column && anotherToken.value.equals(value); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java b/sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java index 0666e7260f1..42eca231134 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/notifications/Notification.java @@ -121,8 +121,8 @@ public class Notification implements Serializable { } @Override - public boolean equals(Object obj) { - if (!(obj instanceof Notification)) { + public boolean equals(@Nullable Object obj) { + if (obj == null || this.getClass() != obj.getClass()) { return false; } if (this == obj) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleParam.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleParam.java index 683f52cde43..7f83179429f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleParam.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleParam.java @@ -104,12 +104,12 @@ public class ActiveRuleParam implements Cloneable { @Override public boolean equals(Object obj) { - if (!(obj instanceof ActiveRuleParam)) { - return false; - } if (this == obj) { return true; } + if (this.getClass() != obj.getClass()) { + return false; + } ActiveRuleParam other = (ActiveRuleParam) obj; return other.getKey().equals(getKey()); } 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 d9ac5cb7813..1445f50883d 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 @@ -101,12 +101,12 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction { @Override public boolean equals(Object o) { - if (!(o instanceof DefaultDebtRemediationFunction)) { - return false; - } if (this == o) { return true; } + if (this.getClass() != o.getClass()) { + return false; + } DefaultDebtRemediationFunction other = (DefaultDebtRemediationFunction) o; return new EqualsBuilder() .append(coefficient, other.coefficient()) |