Split ReplaceSingleLineLetInspection to SimpleRedundantLet & ComplexRedundantLet
Relates to #KT-32010
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ComplexRedundantLetInspection
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
class Foo(val bar: () -> Int)
|
||||
|
||||
fun bar(foo: Foo?) {
|
||||
foo?.<caret>let { it.bar.invoke() }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
class A {
|
||||
operator fun invoke() {}
|
||||
}
|
||||
|
||||
fun foo(a: A) {
|
||||
a.<caret>let { b -> b.invoke() }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let<caret> {
|
||||
it.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun foo() {
|
||||
val foo: String = ""
|
||||
foo.let<caret> {
|
||||
it.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let<caret> {
|
||||
it.to("")
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let<caret> {
|
||||
it.hashCode().hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let<caret> {
|
||||
text ->
|
||||
text.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun String.test(): Int {
|
||||
return let<caret> {
|
||||
it.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.toString()?.let<caret> {
|
||||
it.to("")
|
||||
}?.let {
|
||||
it.to("")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(s: String?): Int? {
|
||||
return s?.let<caret> {
|
||||
it.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun Int.foo(): Int {
|
||||
return <caret>let { it.hashCode().hashCode() }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
fun Int.foo(): Int {
|
||||
return <caret>let { it.hashCode() }
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ReplaceSingleLineLetInspection
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.SimpleRedundantLetInspection
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun withAssign(arg: String?): String {
|
||||
var result: String = ""
|
||||
arg?.let<caret> { result = it }
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
val x = 1
|
||||
val y = x.<caret>let { it + it?.hashCode() }
|
||||
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(list: List<Int>) {
|
||||
list.filter { it > 1 }.filter { it > 2 }.let<caret> { println(it) }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(list: List<Int>) {
|
||||
list.filter { it > 1 }.filter { it > 2 }
|
||||
.let<caret> { println(it) }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(list: List<Int>) {
|
||||
list.filter { it > 1 }.filter { it > 2 }.let<caret> {
|
||||
println(it)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user