FIR checker: warn useless elvis
This commit is contained in:
committed by
TeamCityServer
parent
b2005302dc
commit
24d792fb49
+1
-1
@@ -27,6 +27,6 @@ fun case3() {
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
fun case4() {
|
||||
val x = null ?: null
|
||||
val x = null <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -122,7 +122,7 @@ fun case_10(value_1: Int, value_2: String?, value_3: String?) {
|
||||
when {
|
||||
value_1 == 1 -> value_2 ?: true
|
||||
value_1 == 2 -> value_2 ?: value_3 ?: true
|
||||
value_1 == 3 -> value_2!! ?: true
|
||||
value_1 == 3 -> value_2!! <!USELESS_ELVIS!>?: true<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -125,7 +125,7 @@ fun case_10(value_1: Int, value_2: String?, value_3: String?) {
|
||||
when (value_1) {
|
||||
1 -> value_2 ?: true
|
||||
2 -> value_2 ?: value_3 ?: true
|
||||
3 -> value_2!! ?: true
|
||||
3 -> value_2!! <!USELESS_ELVIS!>?: true<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -87,7 +87,7 @@ fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
|
||||
when (value_1) {
|
||||
value_2 ?: 0 -> {}
|
||||
value_2 ?: value_3 ?: 0 -> {}
|
||||
value_2!! ?: 0 -> {}
|
||||
value_2!! <!USELESS_ELVIS!>?: 0<!> -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -66,7 +66,7 @@ fun case_7(value_1: Any, value_2: String, value_3: String) {
|
||||
// TESTCASE NUMBER: 8
|
||||
fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
|
||||
when (value_1) {
|
||||
value_2 ?: 0, value_2 ?: value_3 ?: 0, value_2!! ?: 0 -> {}
|
||||
value_2 ?: 0, value_2 ?: value_3 ?: 0, value_2!! <!USELESS_ELVIS!>?: 0<!> -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case_1(x: Int?) {
|
||||
if ((x is Int) ?: (x is Int)) {
|
||||
if ((x is Int) <!USELESS_ELVIS!>?: (x is Int)<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>inv()
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case_1(x: Int?) {
|
||||
if ((x is Int) ?: (x is Int)) {
|
||||
if ((x is Int) <!USELESS_ELVIS!>?: (x is Int)<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>inv()
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
fun <T: Any, K: Any> case_1(x: T?, y: K?) {
|
||||
x as T
|
||||
y as K
|
||||
val z = <!DEBUG_INFO_EXPRESSION_TYPE("T? & T?!!")!>x<!> ?: <!DEBUG_INFO_EXPRESSION_TYPE("K? & K?!!")!>y<!>
|
||||
val z = <!DEBUG_INFO_EXPRESSION_TYPE("T? & T?!!")!>x<!> <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("K? & K?!!")!>y<!><!>
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T? & T?!!")!>x<!>.equals(10)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>z<!>
|
||||
|
||||
@@ -34,7 +34,7 @@ fun case_2(x: Any?) {
|
||||
*/
|
||||
fun case_3(x: Any?) {
|
||||
while (true) {
|
||||
x ?: return ?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>
|
||||
x ?: return <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!><!>
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
|
||||
|
||||
@@ -137,7 +137,7 @@ fun case_10(x: Any?, z: Any, b: Boolean?) {
|
||||
// TESTCASE NUMBER: 11
|
||||
fun case_11(x: Any?, z: Any, b: Boolean?) {
|
||||
while (true) {
|
||||
var y = x ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break ?: break::class
|
||||
var y = x ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break <!USELESS_ELVIS!>?: break::class<!>
|
||||
z !== y && if (b == true) return else if (b === false) null!!else throw Exception()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>
|
||||
@@ -148,7 +148,7 @@ fun case_11(x: Any?, z: Any, b: Boolean?) {
|
||||
// TESTCASE NUMBER: 12
|
||||
fun case_12(x: Any?, z: Any, b: Boolean?) {
|
||||
while (true) {
|
||||
var y = select(x) ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break ?: break::class
|
||||
var y = select(x) ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break <!USELESS_ELVIS!>?: break::class<!>
|
||||
select(z) !== y && if (b == true) return else if (b === false) null!!else throw Exception()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>
|
||||
|
||||
@@ -34,7 +34,7 @@ fun case_2(a: Any?) {
|
||||
*/
|
||||
fun case_3(x: Int?) {
|
||||
while (true) {
|
||||
x ?: return ?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
|
||||
x ?: return <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!><!>
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
|
||||
|
||||
@@ -37,7 +37,7 @@ fun case_2(): Int {
|
||||
var c: Int? = null
|
||||
if (c == null || 0 < c) c = 0
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>c<!>
|
||||
return c ?: 0
|
||||
return c <!USELESS_ELVIS!>?: 0<!>
|
||||
}
|
||||
|
||||
var c: Int = 0
|
||||
|
||||
Reference in New Issue
Block a user