A comparison method returns Integer.MIN_VALUE, which stays negative when negated
What it finds
return Integer.MIN_VALUE; from compareTo or compare breaks callers that reverse the order by negating the result: -Integer.MIN_VALUE is Integer.MIN_VALUE again, so the reversed comparison still says "less". Any negative number, such as -1, means "less" just as well.
From the rule's source, compare_min_value.rs.
class Version implements Comparable<Version> { int major; @Override public int compareTo(Version other) { if (other == null) { return Integer.MIN_VALUE;tx0 reports: Integer.MIN_VALUE stays negative when a caller negates it } return Integer.compare(major, other.major); } int lowest() { return Integer.MIN_VALUE; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:compare-min-value" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:compare-min-value] reason="..."tx0 explain tx0/java:compare-min-value shows the same in the terminal. Found a false positive? Report it.