FIR: report UNSAFE_CALL on dot when possible

This commit is contained in:
Mikhail Glukhikh
2021-01-29 10:25:59 +03:00
parent 0ee4f1f393
commit 7d4eaefd36
249 changed files with 1208 additions and 1649 deletions
@@ -8,13 +8,13 @@ fun test_1(b: Boolean?) {
if ((b == true) == true) {
b.not() // OK
} else {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
}
}
fun test_2(b: Boolean?) {
if ((b == true) != true) {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
} else {
b.not() // OK
}
@@ -22,7 +22,7 @@ fun test_2(b: Boolean?) {
fun test_3(b: Boolean?) {
if ((b == true) == false) {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
} else {
b.not() // OK
}
@@ -32,13 +32,13 @@ fun test_4(b: Boolean?) {
if ((b == true) != false) {
b.not() // OK
} else {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
}
}
fun test_5(b: Boolean?) {
if ((b != true) == true) {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
} else {
b.not() // OK
}
@@ -48,7 +48,7 @@ fun test_6(b: Boolean?) {
if ((b != true) != true) {
b.not() // OK
} else {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
}
}
@@ -56,13 +56,13 @@ fun test_7(b: Boolean?) {
if ((b != true) == false) {
b.not() // OK
} else {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
}
}
fun test_8(b: Boolean?) {
if ((b != true) != false) {
b.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>not<!>()<!> // Bad
b<!UNSAFE_CALL!>.<!>not() // Bad
} else {
b.not() // OK
}
@@ -34,24 +34,24 @@ fun test_4(a: A?) {
fun test_5(a: A?) {
a == null || throw Exception()
a.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}
fun teat_6(a: A?) {
a != null && throw Exception()
a.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}
fun test_7(a: A?) {
if (a == null || throw Exception()) {
a.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}
a.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}
fun test_8(a: A?) {
if (a != null && throw Exception()) {
a.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}
a.<!UNSAFE_CALL{LT}!><!UNSAFE_CALL{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}