tests: apply official code style

#KT-38632 Fixed
This commit is contained in:
Dmitry Gridin
2020-04-28 15:51:57 +07:00
parent d8f9643650
commit 11a3482970
406 changed files with 1785 additions and 1525 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'"
fun f(list: List<Int?>): Int{
val r = list
.filterNotNull()
.sum()
.filterNotNull()
.sum()
return r
}
+3 -3
View File
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().sum()'"
fun f(list: List<Int?>): Int{
val r = list
.asSequence()
.filterNotNull()
.sum()
.asSequence()
.filterNotNull()
.sum()
return r
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
fun foo(list: List<String>) {
val <caret>found = list
.filterIndexed { index, s -> s.length > index }
.any()
.filterIndexed { index, s -> s.length > index }
.any()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.any()'"
fun foo(list: List<String>) {
val <caret>found = list
.asSequence()
.filterIndexed { index, s -> s.length > index }
.any()
.asSequence()
.filterIndexed { index, s -> s.length > index }
.any()
}
@@ -4,9 +4,9 @@
fun getMaxLineWidth(lineCount: Int): Float {
var max_width = 0.0f
<caret>(0..lineCount - 1)
.asSequence()
.filter { getLineWidth(it) > max_width }
.forEach { max_width = getLineWidth(it) }
.asSequence()
.filter { getLineWidth(it) > max_width }
.forEach { max_width = getLineWidth(it) }
return max_width
}
@@ -4,7 +4,7 @@
fun foo(list: List<String>): Long {
var count = 0L
list
.filter { it.length > 10 }
.forEach { count++ }
.filter { it.length > 10 }
.forEach { count++ }
return count
}
@@ -4,8 +4,8 @@
fun foo(list: List<String>): Long {
var count = 0L
list
.asSequence()
.filter { it.length > 10 }
.forEach { count++ }
.asSequence()
.filter { it.length > 10 }
.forEach { count++ }
return count
}
@@ -4,8 +4,8 @@
fun foo(list: List<String>): Int {
var count = 0
list
.asSequence()
.filter { it.length > count }
.forEach { count++ }
.asSequence()
.filter { it.length > count }
.forEach { count++ }
return count
}
@@ -5,7 +5,7 @@ import java.util.ArrayList
fun foo(list: List<String>): MutableList<String> {
val <caret>result = list
.filter { it.length > 0 }
.toMutableList()
.filter { it.length > 0 }
.toMutableList()
return result
}
@@ -5,8 +5,8 @@ import java.util.ArrayList
fun foo(list: List<String>): MutableList<String> {
val <caret>result = list
.asSequence()
.filter { it.length > 0 }
.toMutableList()
.asSequence()
.filter { it.length > 0 }
.toMutableList()
return result
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.asSequence()
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
.asSequence()
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
.asSequence()
.filterIndexed { index, s -> s.length > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
.asSequence()
.filterIndexed { i, s -> s.length > i }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices }
.filter { it != 10 }
.mapTo(target) { it.toString() }
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices }
.filter { it != 10 }
.mapTo(target) { it.toString() }
}
@@ -3,9 +3,9 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...flatMap{}.filter{}.mapTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.asSequence()
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices.asSequence() }
.filter { it != 10 }
.mapTo(target) { it.toString() }
.asSequence()
.filterIndexed { i, s -> i % 10 != 0 }
.flatMap { it.indices.asSequence() }
.filter { it != 10 }
.mapTo(target) { it.toString() }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull()
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull()
.asSequence()
.filterIndexed { index, s -> s.length <= index * 10 && s.length > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
.asSequence()
.filterIndexed { index, s -> !s.isBlank() && s.length > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
.asSequence()
.filterIndexed { index, s -> s.length <= index && s.isNotBlank() }
.firstOrNull()
}
@@ -4,6 +4,6 @@
fun foo(list: List<String>): String? {
var index2 = 0
return list
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
}
@@ -4,7 +4,7 @@
fun foo(list: List<String>): String? {
var index2 = 0
return list
.asSequence()
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
.asSequence()
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIndexed{}.filterIndexedTo(){}'"
fun foo(list: List<String>, target: MutableCollection<String>) {
<caret>list
.asSequence()
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
.asSequence()
.filterIndexed { i, s -> s.length <= i }
.filterIndexedTo(target) { j, s -> s.length % j == 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'"
fun foo(list: List<Any>): Int? {
return list
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'"
fun foo(list: List<Any>): Int? {
return list
.asSequence()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
.asSequence()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
}
@@ -6,6 +6,6 @@
fun foo(list: List<Any>, target: MutableCollection<String>) {
<caret>target += list
.asSequence()
.filterIsInstance<String>()
.asSequence()
.filterIsInstance<String>()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'"
fun foo(list: List<Any>): Int? {
return list
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().map{}.firstOrNull()'"
fun foo(list: List<Any>): Int? {
return list
.asSequence()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
.asSequence()
.filterIsInstance<String>()
.map { it.length }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'"
fun foo(list: List<String?>): Int? {
<caret>return list
.filterNotNull()
.map { it.length }
.firstOrNull()
.filterNotNull()
.map { it.length }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'"
fun foo(list: List<String?>): Int? {
<caret>return list
.asSequence()
.filterNotNull()
.map { it.length }
.firstOrNull()
.asSequence()
.filterNotNull()
.map { it.length }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'"
fun foo(list: List<Any?>): Int? {
<caret>return list
.filterNotNull()
.map { it.hashCode() }
.firstOrNull()
.filterNotNull()
.map { it.hashCode() }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().map{}.firstOrNull()'"
fun foo(list: List<Any?>): Int? {
<caret>return list
.asSequence()
.filterNotNull()
.map { it.hashCode() }
.firstOrNull()
.asSequence()
.filterNotNull()
.map { it.hashCode() }
.firstOrNull()
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull()'"
fun foo(list: List<String>): Int? {
<caret>return list
.filterNot { it.isEmpty() }
.map { it.length }
.firstOrNull()
.filterNot { it.isEmpty() }
.map { it.length }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.map{}.firstOrNull()'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.filterNot { it.isEmpty() }
.map { it.length }
.firstOrNull()
.asSequence()
.filterNot { it.isEmpty() }
.map { it.length }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.asSequence()
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
.asSequence()
.filter { it != null && it.startsWith("IMG:") }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.firstOrNull()'"
fun foo(list: List<String>): String? {
return list
.filter { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" }
.map { it + "x" }
.firstOrNull()
.filter { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" }
.map { it + "x" }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.firstOrNull()'"
fun foo(list: List<String>): String? {
return list
.asSequence()
.filter { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" }
.map { it + "x" }
.firstOrNull()
.asSequence()
.filter { !it.isEmpty() && it.length < 10 && it != "abc" && it != "def" }
.map { it + "x" }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().filterTo(){}'"
fun foo(list: List<Any>, out: MutableList<String>){
list
.filterIsInstance<String>()
.filterTo(out) { it.length > 0 }
.filterIsInstance<String>()
.filterTo(out) { it.length > 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterIsInstance<>().filterTo(){}'"
fun foo(list: List<Any>, out: MutableList<String>){
list
.asSequence()
.filterIsInstance<String>()
.filterTo(out) { it.length > 0 }
.asSequence()
.filterIsInstance<String>()
.filterTo(out) { it.length > 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.asSequence()
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
.asSequence()
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNotNull().filter{}.forEach{}'"
fun foo(list: List<String?>){
list
.asSequence()
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
.asSequence()
.filterNotNull()
.filter { it.startsWith("IMG:") }
.forEach { println(it.hashCode()) }
}
@@ -3,8 +3,8 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String>) {
val <caret>result: String? = list
.firstOrNull { it.length > 0 }
?.let { bar(it) }
.firstOrNull { it.length > 0 }
?.let { bar(it) }
}
fun bar(s: String): String = s
@@ -3,8 +3,8 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String>) {
val <caret>result: String? = list
.firstOrNull { it.length > 0 }
?.let { it.substring(0, it.length - 1) }
.firstOrNull { it.length > 0 }
?.let { it.substring(0, it.length - 1) }
}
fun bar(s: String): String = s
@@ -3,9 +3,9 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String>) {
val <caret>result = list
.firstOrNull { it.length > 0 }
?.let { bar(it) }
?: ""
.firstOrNull { it.length > 0 }
?.let { bar(it) }
?: ""
}
fun bar(s: String): String = s
@@ -3,6 +3,6 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String>): Int? {
<caret>return list
.firstOrNull { it.isNotEmpty() }
?.length
.firstOrNull { it.isNotEmpty() }
?.length
}
@@ -3,7 +3,7 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String>): Int {
<caret>return list
.firstOrNull { it.isNotEmpty() }
?.length
?: -1
.firstOrNull { it.isNotEmpty() }
?.length
?: -1
}
@@ -3,5 +3,5 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String>): String {
<caret>return list.firstOrNull { it.isNotEmpty() }
?: ""
?: ""
}
@@ -3,6 +3,6 @@
// IS_APPLICABLE_2: false
fun foo(list: List<String?>) {
val <caret>result: String? = list
.firstOrNull { it != "" }
?.substring(1)
.firstOrNull { it != "" }
?.substring(1)
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
val <caret>result: String? = list
.flatMap { it.lines() }
.firstOrNull { it.isNotBlank() }
.flatMap { it.lines() }
.firstOrNull { it.isNotBlank() }
return result
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
val <caret>result: String? = list
.asSequence()
.flatMap { it.lines().asSequence() }
.firstOrNull { it.isNotBlank() }
.asSequence()
.flatMap { it.lines().asSequence() }
.firstOrNull { it.isNotBlank() }
return result
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
<caret>return list
.flatMap { it.lines() }
.firstOrNull { !it.isBlank() }
.flatMap { it.lines() }
.firstOrNull { !it.isBlank() }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.flatMap { it.lines().asSequence() }
.firstOrNull { !it.isBlank() }
.asSequence()
.flatMap { it.lines().asSequence() }
.firstOrNull { !it.isBlank() }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMapTo(){}'"
fun foo(list: List<String>, target: MutableList<String>) {
<caret>list
.asSequence()
.flatMapTo(target) { it.lines().asSequence() }
.asSequence()
.flatMapTo(target) { it.lines().asSequence() }
}
@@ -5,7 +5,7 @@ import java.util.ArrayList
fun foo(list: List<String>): List<String> {
val <caret>target = list
.asSequence()
.flatMapTo(ArrayList<String>(100)) { it.lines().asSequence() }
.asSequence()
.flatMapTo(ArrayList<String>(100)) { it.lines().asSequence() }
return target
}
@@ -4,8 +4,8 @@
fun foo(list: List<String>): List<String> {
val target = createCollection()
<caret>list
.asSequence()
.flatMapTo(target) { it.lines().asSequence() }
.asSequence()
.flatMapTo(target) { it.lines().asSequence() }
return target
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
<caret>return list
.mapIndexed { index, s -> s.lines().take(index) }
.flatMap { it }
.firstOrNull { it.isNotBlank() }
.mapIndexed { index, s -> s.lines().take(index) }
.flatMap { it }
.firstOrNull { it.isNotBlank() }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.mapIndexed { index, s -> s.lines().take(index) }
.flatMap { it.asSequence() }
.firstOrNull { it.isNotBlank() }
.asSequence()
.mapIndexed { index, s -> s.lines().take(index) }
.flatMap { it.asSequence() }
.firstOrNull { it.isNotBlank() }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
<caret>return list
.flatMap { it.lines() }
.firstOrNull { it.isNotBlank() }
.flatMap { it.lines() }
.firstOrNull { it.isNotBlank() }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.firstOrNull{}'"
fun foo(list: List<String>): String? {
<caret>return list
.asSequence()
.flatMap { it.lines().asSequence() }
.firstOrNull { it.isNotBlank() }
.asSequence()
.flatMap { it.lines().asSequence() }
.firstOrNull { it.isNotBlank() }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<Int>){
list
.filter { it > 0 }
.forEach { println("positive number") }
.filter { it > 0 }
.forEach { println("positive number") }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<Int>){
list
.asSequence()
.filter { it > 0 }
.forEach { println("positive number") }
.asSequence()
.filter { it > 0 }
.forEach { println("positive number") }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.forEachIndexed{}'"
fun foo(list: List<String>) {
list
.map { it.substring(1) }
.forEachIndexed { index, s1 -> println(s1.hashCode() * index) }
.map { it.substring(1) }
.forEachIndexed { index, s1 -> println(s1.hashCode() * index) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.forEachIndexed{}'"
fun foo(list: List<String>) {
list
.asSequence()
.map { it.substring(1) }
.forEachIndexed { index, s1 -> println(s1.hashCode() * index) }
.asSequence()
.map { it.substring(1) }
.forEachIndexed { index, s1 -> println(s1.hashCode() * index) }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.forEach{}'"
fun foo(list: List<String>) {
list
.mapIndexed { index, s -> s.length * index }
.forEach { println(it) }
.mapIndexed { index, s -> s.length * index }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.forEach{}'"
fun foo(list: List<String>) {
list
.asSequence()
.mapIndexed { index, s -> s.length * index }
.forEach { println(it) }
.asSequence()
.mapIndexed { index, s -> s.length * index }
.forEach { println(it) }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String>) {
list
.filter { it.isNotBlank() }
.forEach { println(it) }
.filter { it.isNotBlank() }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun foo(list: List<String>) {
list
.asSequence()
.filter { it.isNotBlank() }
.forEach { println(it) }
.asSequence()
.filter { it.isNotBlank() }
.forEach { println(it) }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
}
@@ -5,7 +5,7 @@
fun foo(list: List<String>): Int? {
var index = 0
return list
.filterNot { it.isBlank() }
.map { it.length * index++ }
.firstOrNull { it * 100 > index * index }
.filterNot { it.isBlank() }
.map { it.length * index++ }
.firstOrNull { it * 100 > index * index }
}
@@ -5,8 +5,8 @@
fun foo(list: List<String>): Int? {
var index = 0
return list
.asSequence()
.filterNot { it.isBlank() }
.map { it.length * index++ }
.firstOrNull { it * 100 > index * index }
.asSequence()
.filterNot { it.isBlank() }
.map { it.length * index++ }
.firstOrNull { it * 100 > index * index }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...mapIndexed{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it > 1000 }
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it > 1000 }
}
@@ -3,9 +3,9 @@
// INTENTION_TEXT_2: "Replace with 'asSequence()...mapIndexed{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it > 1000 }
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it > 1000 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
return list
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it <= 1000 }
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it <= 1000 }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
return list
.asSequence()
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it <= 1000 }
.asSequence()
.mapIndexed { index, s -> s.length * index }
.mapIndexed { index, x -> x * index }
.firstOrNull { it <= 1000 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.filter{}.mapIndexedTo(){}'"
fun foo(list: List<String>, target: MutableCollection<Int>) {
<caret>list
.flatMap { it.indices }
.filter { it != 10 }
.mapIndexedTo(target) { i, j -> i + j }
.flatMap { it.indices }
.filter { it != 10 }
.mapIndexedTo(target) { i, j -> i + j }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().flatMap{}.filter{}.mapIndexedTo(){}'"
fun foo(list: List<String>, target: MutableCollection<Int>) {
<caret>list
.asSequence()
.flatMap { it.indices.asSequence() }
.filter { it != 10 }
.mapIndexedTo(target) { i, j -> i + j }
.asSequence()
.flatMap { it.indices.asSequence() }
.filter { it != 10 }
.mapIndexedTo(target) { i, j -> i + j }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * (index + 1) }
.firstOrNull { it > 0 }
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * (index + 1) }
.firstOrNull { it > 0 }
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().filterNot{}.mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * (index + 1) }
.firstOrNull { it > 0 }
.asSequence()
.filterNot { it.isBlank() }
.mapIndexed { index, s -> s.length * (index + 1) }
.firstOrNull { it > 0 }
}
@@ -5,7 +5,7 @@ import java.util.ArrayList
fun foo(list: List<String>): List<Int> {
val result = list
.filter { it.length > 0 }
.map { it.hashCode() }
.filter { it.length > 0 }
.map { it.hashCode() }
return result
}
@@ -5,9 +5,9 @@ import java.util.ArrayList
fun foo(list: List<String>): List<Int> {
val result = list
.asSequence()
.filter { it.length > 0 }
.map { it.hashCode() }
.toList()
.asSequence()
.filter { it.length > 0 }
.map { it.hashCode() }
.toList()
return result
}
@@ -5,7 +5,7 @@ import java.util.ArrayList
fun foo(list: List<String>): List<Int> {
val <caret>result = list
.filter { it.length > 0 }
.map { it.hashCode() }
.filter { it.length > 0 }
.map { it.hashCode() }
return result
}
@@ -5,9 +5,9 @@ import java.util.ArrayList
fun foo(list: List<String>): List<Int> {
val <caret>result = list
.asSequence()
.filter { it.length > 0 }
.map { it.hashCode() }
.toList()
.asSequence()
.filter { it.length > 0 }
.map { it.hashCode() }
.toList()
return result
}
+2 -2
View File
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.map { it.length }
.firstOrNull { it > 0 }
.map { it.length }
.firstOrNull { it > 0 }
}
+3 -3
View File
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.map { it.length }
.firstOrNull { it > 0 }
.asSequence()
.map { it.length }
.firstOrNull { it > 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): Int? {
<caret>return list
.map { it.length }
.filterIndexed { index, l -> l > index }
.firstOrNull()
.map { it.length }
.filterIndexed { index, l -> l > index }
.firstOrNull()
}
@@ -3,8 +3,8 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.filterIndexed{}.firstOrNull()'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.map { it.length }
.filterIndexed { index, l -> l > index }
.firstOrNull()
.asSequence()
.map { it.length }
.filterIndexed { index, l -> l > index }
.firstOrNull()
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
}
@@ -3,7 +3,7 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.firstOrNull{}'"
fun foo(list: List<String>): Int? {
<caret>return list
.asSequence()
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
.asSequence()
.mapIndexed { index, s -> s.length * index }
.firstOrNull { it > 0 }
}
@@ -3,6 +3,6 @@
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexedNotNull{}.mapTo(){}'"
fun foo(list: List<String?>, target: MutableList<String>) {
<caret>list
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
.mapTo(target) { it.toString() }
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
.mapTo(target) { it.toString() }
}

Some files were not shown because too many files have changed in this diff Show More