Skip to content

Commit

Permalink
Fix quality flaws
Browse files Browse the repository at this point in the history
  • Loading branch information
julienlancelot committed Feb 23, 2015
1 parent ea5a39c commit 7efdaa4
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 24 deletions.
Expand Up @@ -23,6 +23,7 @@

import javax.annotation.CheckForNull;
import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -123,7 +124,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (this.getClass() != o.getClass()) {
return false;
}
Message message = (Message) o;
Expand Down
Expand Up @@ -71,17 +71,12 @@ public boolean equals(Object o) {
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
Expand Down
Expand Up @@ -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>.
Expand Down Expand Up @@ -92,7 +91,7 @@ public Terminator(int i) {

@Override
public boolean equals(Object obj) {
return (obj instanceof Terminator) && (((Terminator) obj).stringNumber == stringNumber);
return (this.getClass() == obj.getClass()) && (((Terminator) obj).stringNumber == stringNumber);
}

@Override
Expand Down
Expand Up @@ -135,7 +135,7 @@ public String toString() {
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof CloneGroup)) {
if (this.getClass() != object.getClass()) {
return false;
}
CloneGroup another = (CloneGroup) object;
Expand Down
Expand Up @@ -64,7 +64,7 @@ public int getLines() {

@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
Expand Down
Expand Up @@ -82,7 +82,7 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Statement)) {
if (this.getClass() != obj.getClass()) {
return false;
}
Statement other = (Statement) obj;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public String getValue() {

@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);
}
Expand Down
Expand Up @@ -121,8 +121,8 @@ public String getFieldValue(String field) {
}

@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) {
Expand Down
Expand Up @@ -104,12 +104,12 @@ public String getKey() {

@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());
}
Expand Down
Expand Up @@ -101,12 +101,12 @@ private void validate() {

@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())
Expand Down

0 comments on commit 7efdaa4

Please sign in to comment.