mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Kotlin: Add a Kotlin 2 copy of the testsuite
This commit is contained in:
18
java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt
Normal file
18
java/ql/test-kotlin2/query-tests/UselessNullCheck/Test.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
fun fn(x:Any?, y: Any?) {
|
||||
if (x == null && y == null) {
|
||||
throw Exception()
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
println("x not null")
|
||||
} else if (y != null) {
|
||||
println("y not null")
|
||||
}
|
||||
}
|
||||
|
||||
fun fn0(o: Any?) {
|
||||
if (o != null) {
|
||||
o?.toString()
|
||||
o.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
| Test.kt:15:12:15:21 | ... (value equals) ... | This check is useless. $@ cannot be null at this check, since it is guarded by $@. | Test.kt:15:9:15:9 | tmp0_safe_receiver | tmp0_safe_receiver | Test.kt:14:9:14:17 | ... (value not-equals) ... | ... (value not-equals) ... |
|
||||
@@ -0,0 +1 @@
|
||||
Language Abuse/UselessNullCheck.ql
|
||||
Reference in New Issue
Block a user