aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src/main/java
diff options
context:
space:
mode:
authorKlaudio Sinani <klaudio.sinani@sonarsource.com>2022-10-26 15:16:57 +0200
committersonartech <sonartech@sonarsource.com>2022-10-28 20:03:23 +0000
commitce409098feab4f5f5ca8168cd995775e1fa32cbb (patch)
treea04c7bf89c2b7792dbed6895b6f3db0fd3171cb1 /sonar-duplications/src/main/java
parent84dfd8b586f0c458d324e815f8b09ce3b395c044 (diff)
downloadsonarqube-ce409098feab4f5f5ca8168cd995775e1fa32cbb.tar.gz
sonarqube-ce409098feab4f5f5ca8168cd995775e1fa32cbb.zip
[NO-JIRA] Fix reported code smells & bugs
Diffstat (limited to 'sonar-duplications/src/main/java')
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/TextSet.java2
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java2
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java2
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java2
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/token/Token.java2
5 files changed, 5 insertions, 5 deletions
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 01c1bd268ec..16764bae35b 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
@@ -89,7 +89,7 @@ public final class TextSet extends AbstractText {
@Override
public boolean equals(Object obj) {
- return (obj instanceof Terminator) && (((Terminator) obj).stringNumber == stringNumber);
+ return obj != null && 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 bfc6897e0fd..402682247b2 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
@@ -131,7 +131,7 @@ public class CloneGroup {
*/
@Override
public boolean equals(Object object) {
- if (!(object instanceof CloneGroup)) {
+ if (object == null || 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 daae5d9ace9..204b07effc0 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
@@ -60,7 +60,7 @@ public class ClonePart {
@Override
public boolean equals(Object obj) {
- if (obj instanceof ClonePart) {
+ if (obj != null && 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 bb0b6c37b40..d92aebf2de9 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
@@ -79,7 +79,7 @@ public class Statement {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof Statement)) {
+ if (obj == null || 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 6f2f3d00e05..58a080588d6 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 (object != null && getClass() == object.getClass()) {
Token anotherToken = (Token) object;
return anotherToken.line == line && anotherToken.column == column && anotherToken.value.equals(value);
}