mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
ComparatorResultComparisonInspection: support >/>=/</<= checks
Additional fix for IDEA-173177. Now conditions like "a.compareTo(b) > 1" are warned as well.
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void test(Comparator<String> cmp) {
|
||||
if(cmp.compare("a", "b") <warning descr="Comparison of compare method result with specific constant">!=</warning> -1) {
|
||||
System.out.println("Oops");
|
||||
}
|
||||
|
||||
if(cmp.compare("a", "b") <warning descr="Comparison of compare method result with specific constant">></warning> 1) {
|
||||
System.out.println("Bad");
|
||||
}
|
||||
if(cmp.compare("a", "b") >= 1) {
|
||||
System.out.println("Ok");
|
||||
}
|
||||
if(cmp.compare("a", "b") < 1) {
|
||||
System.out.println("Ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Replace with '>= 0'" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void test(Comparator<String> cmp) {
|
||||
if(cmp.compare("a", "b") >= 0) {
|
||||
System.out.println("Oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Replace with '>= 0'" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void test(Comparator<String> cmp) {
|
||||
if(cmp.compare("a", "b") !<caret>= -1) {
|
||||
System.out.println("Oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user