Enhance inspection about SuccessOrFailure (related to KT-25621)

Increase performance by searching first SuccessOrFailure/runCatching/etc
in text of functions without return type.
Remove stdlib false positives, like success() & failure().
For catching extension, check also non-catching members.
Add "rename to *Catching" fix.
This commit is contained in:
Mikhail Glukhikh
2018-08-24 13:17:40 +03:00
parent 7a2d0a3bb2
commit c12f29ae30
16 changed files with 185 additions and 22 deletions
@@ -0,0 +1,10 @@
// FIX: Unwrap 'SuccessOrFailure' return type (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("")
}
abstract class Abstract {
abstract fun <caret>foo(): SuccessOrFailure<Int>
}
@@ -0,0 +1,10 @@
// FIX: Unwrap 'SuccessOrFailure' return type (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("")
}
abstract class Abstract {
abstract fun foo(): Int
}
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
// WITH_RUNTIME
package kotlin
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
// WITH_RUNTIME
package kotlin
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
@@ -0,0 +1,8 @@
// FIX: Rename to 'incorrectCatching'
package kotlin
class SuccessOrFailure<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("")
}
fun <caret>incorrect() = SuccessOrFailure("123")
@@ -0,0 +1,8 @@
// FIX: Rename to 'incorrectCatching'
package kotlin
class SuccessOrFailure<T>(val value: T?) {
fun getOrThrow(): T = value ?: throw AssertionError("")
}
fun <caret>incorrectCatching() = SuccessOrFailure("123")
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {
@@ -1,3 +1,4 @@
// FIX: Add '.getOrThrow()' to function result (breaks use-sites!)
package kotlin
class SuccessOrFailure<T>(val value: T?) {