Add inspection for check/require/checkNotNull/requireNotNull

#KT-30640 Fixed
#KT-22412 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-04-10 10:32:29 +03:00
committed by Mikhail Glukhikh
parent 64780293d3
commit 90b0ea73dc
30 changed files with 458 additions and 40 deletions
@@ -0,0 +1,7 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
<caret>if (b) {
throw IllegalArgumentException("test")
}
}
@@ -0,0 +1,5 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
require(!b) { "test" }
}
@@ -0,0 +1,7 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
<caret>if (b) {
throw java.lang.IllegalArgumentException("test")
}
}
@@ -0,0 +1,5 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
require(!b) { "test" }
}
@@ -0,0 +1,9 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
<caret>if (b) {
// comment1
throw IllegalArgumentException()
// comment2
}
}
@@ -0,0 +1,7 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
// comment1
// comment2
require(!b)
}
@@ -0,0 +1,9 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
<caret>if (b) {
// comment1
throw IllegalArgumentException("test")
// comment2
}
}
@@ -0,0 +1,9 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(b: Boolean) {
require(!b) {
// comment1
"test"
// comment2
}
}
@@ -0,0 +1,5 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(foo: Boolean) {
<caret>if (!foo) throw IllegalArgumentException("test")
}
@@ -0,0 +1,5 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(foo: Boolean) {
require(foo) { "test" }
}
@@ -0,0 +1,5 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(foo: Int) {
<caret>if (foo != 0) throw IllegalArgumentException("test")
}
@@ -0,0 +1,5 @@
// FIX: Replace with 'require()' call
// WITH_RUNTIME
fun test(foo: Int) {
require(foo == 0) { "test" }
}