From: Simon Brandhof Date: Wed, 3 Sep 2014 08:08:18 +0000 (+0200) Subject: Fix quality flaws X-Git-Tag: 4.5-RC1~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5b11d674c478568b9445d5d65624b473cff8b84f;p=sonarqube.git Fix quality flaws --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java b/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java index ab447a9db5c..887e13847be 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java @@ -75,23 +75,27 @@ public class FacetValue implements Comparable { public int compareTo(FacetValue other) { if (this.sort.equals(Sort.BY_KEY)) { return this.getKey().compareTo(other.getKey()); - } else { - return this.getValue().compareTo(other.getValue()); } + return this.getValue().compareTo(other.getValue()); } @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof FacetValue)) return false; + if (this == o) { + return true; + } + if (!(o instanceof FacetValue)) { + return false; + } FacetValue that = (FacetValue) o; - - if (!key.equals(that.key)) return false; - if (subFacets != null ? !subFacets.equals(that.subFacets) : that.subFacets != null) return false; - if (!value.equals(that.value)) return false; - - return true; + if (!key.equals(that.key)) { + return false; + } + if (subFacets != null ? !subFacets.equals(that.subFacets) : that.subFacets != null) { + return false; + } + return value.equals(that.value); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/Hit.java b/server/sonar-server/src/main/java/org/sonar/server/search/Hit.java index ef04a7ddd6b..d4e0e4c8647 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/Hit.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/Hit.java @@ -66,25 +66,29 @@ public class Hit implements Comparable { @Override public int compareTo(Hit hit) { - if (this.getRank() != null) { - return this.getRank().compareTo(hit.getRank()); - } else { - return this.getScore().compareTo(hit.getScore()); + if (getRank() != null) { + return getRank().compareTo(hit.getRank()); } + return getScore().compareTo(hit.getScore()); } @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Hit)) return false; + if (this == o) { + return true; + } + if (!(o instanceof Hit)) { + return false; + } Hit hit = (Hit) o; - - if (fields != null ? !fields.equals(hit.fields) : hit.fields != null) return false; - if (rank != null ? !rank.equals(hit.rank) : hit.rank != null) return false; - if (score != null ? !score.equals(hit.score) : hit.score != null) return false; - - return true; + if (fields != null ? !fields.equals(hit.fields) : hit.fields != null) { + return false; + } + if (rank != null ? !rank.equals(hit.rank) : hit.rank != null) { + return false; + } + return !(score != null ? !score.equals(hit.score) : hit.score != null); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteDto.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteDto.java index 8b801a45b72..73941663882 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteDto.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteDto.java @@ -42,7 +42,7 @@ public class DeleteDto extends IndexActionRequest { } @Override - public Class getPayloadClass() { + public Class getPayloadClass() { return dto.getClass(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java index adc15a9a9a5..772f34f9041 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java @@ -42,7 +42,7 @@ public class DeleteKey extends IndexActionRequest { } @Override - public Class getPayloadClass() { + public Class getPayloadClass() { throw new IllegalStateException("Deletion by key does not have an object payload!"); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java index 15555a4481b..e85dff4279a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java @@ -45,7 +45,7 @@ public class DeleteNestedItem extends IndexActionRequest } @Override - public Class getPayloadClass() { + public Class getPayloadClass() { return item.getClass(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/IndexActionRequest.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/IndexActionRequest.java index 2d36fa0d5dc..8eb540df4a6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/IndexActionRequest.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/IndexActionRequest.java @@ -46,7 +46,7 @@ public abstract class IndexActionRequest implements ClusterAction getPayloadClass(); + public abstract Class getPayloadClass(); public String getIndexType() { return indexType; diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertDto.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertDto.java index 5ad7af6c3f5..c2c6b5c0e65 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertDto.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertDto.java @@ -44,7 +44,7 @@ public class UpsertDto extends IndexActionRequest { } @Override - public Class getPayloadClass() { + public Class getPayloadClass() { return dto.getClass(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java index e87fe604e86..a16ba90bfa6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java @@ -46,7 +46,7 @@ public class UpsertNestedItem extends IndexActionRequest } @Override - public Class getPayloadClass() { + public Class getPayloadClass() { return item.getClass(); }