Skip to content

Commit

Permalink
Merge pull request jenkinsci#4237 from StefanSpieker/negating_result_…
Browse files Browse the repository at this point in the history
…compareto

Spotbugs: changed order for compare instead of negating result
  • Loading branch information
oleg-nenashev authored Oct 2, 2019
2 parents 5f4b878 + d408627 commit 9ba288f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ private StringBuilder buildSuperclassHierarchy(Class c, StringBuilder buf) {
}

public int compareTo(Tag that) {
int r = Double.compare(this.ordinal, that.ordinal);
if (r!=0) return -r; // descending for ordinal
int r = Double.compare(that.ordinal, this.ordinal);
if (r!=0) return r; // descending for ordinal by reversing the order for compare
return this.hierarchy.compareTo(that.hierarchy);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/RunMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public R oldestValue() {
@Deprecated
public static final Comparator<Comparable> COMPARATOR = new Comparator<Comparable>() {
public int compare(Comparable o1, Comparable o2) {
return -o1.compareTo(o2);
return o2.compareTo(o1);
}
};

Expand Down

0 comments on commit 9ba288f

Please sign in to comment.