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
@@ -1,6 +1,6 @@
fun foo(arg: Any): Int {
// 1
return arg as? Int
// 2
?: 10
// 2
?: 10
}
@@ -6,5 +6,5 @@ val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fun main() {
val c = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
?: "abcdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf"
?: "abcdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf"
}
@@ -2,37 +2,37 @@
fun test(list: List<Int>): List<Pair<IndexedValue<List<Int>>, IndexedValue<List<Int>>>> {
return list
.asSequence()
.chunked(1)
.distinct()
.distinctBy { it }
.drop(1)
.dropWhile { true }
.filter { true }
.filterIndexed { index, list -> true }
.filterIsInstance<Int>()
.filterNot { true }
.filterNotNull()
.map { it }
.mapIndexed { index, i -> i }
.mapIndexedNotNull { index, i -> i }
.mapNotNull { it }
.minus(1)
.minusElement(1)
.onEach {}
.plus(1)
.plusElement(1)
.requireNoNulls()
.sorted()
.sortedBy { it }
.sortedByDescending { it }
.sortedDescending()
.sortedWith(Comparator { o1, o2 -> 0 })
.take(1)
.takeWhile { true }
.windowed(1, 1, true)
.withIndex()
.zipWithNext()
.zipWithNext { a, b -> a }
.toList()
.asSequence()
.chunked(1)
.distinct()
.distinctBy { it }
.drop(1)
.dropWhile { true }
.filter { true }
.filterIndexed { index, list -> true }
.filterIsInstance<Int>()
.filterNot { true }
.filterNotNull()
.map { it }
.mapIndexed { index, i -> i }
.mapIndexedNotNull { index, i -> i }
.mapNotNull { it }
.minus(1)
.minusElement(1)
.onEach {}
.plus(1)
.plusElement(1)
.requireNoNulls()
.sorted()
.sortedBy { it }
.sortedByDescending { it }
.sortedDescending()
.sortedWith(Comparator { o1, o2 -> 0 })
.take(1)
.takeWhile { true }
.windowed(1, 1, true)
.withIndex()
.zipWithNext()
.zipWithNext { a, b -> a }
.toList()
}
@@ -2,7 +2,7 @@
fun test(list: List<Int>): Int {
return list // comment1
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
}
@@ -2,8 +2,8 @@
fun test(list: List<Int>): Int {
return list // comment1
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 } // comment3
.sum() // comment4
}
@@ -2,6 +2,6 @@
fun test(list: List<Int>): List<Int> {
return list // comment1
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
.<caret>filter { it > 1 } // comment2
.map { it * 2 } // comment3
}
@@ -2,8 +2,8 @@
fun test(list: List<Int>): List<Int> {
return list // comment1
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 }
.toList() // comment3
.asSequence()
.filter { it > 1 } // comment2
.map { it * 2 }
.toList() // comment3
}
@@ -2,7 +2,7 @@
fun test(list: List<List<Int>>): List<Int> {
return list
.<caret>filter { it.count() > 2 }
.map { it + it }
.flatMap { it + it }
.<caret>filter { it.count() > 2 }
.map { it + it }
.flatMap { it + it }
}
@@ -2,9 +2,9 @@
fun test(list: List<List<Int>>): List<Int> {
return list
.asSequence()
.filter { it.count() > 2 }
.map { it + it }
.toList()
.flatMap { it + it }
.asSequence()
.filter { it.count() > 2 }
.map { it + it }
.toList()
.flatMap { it + it }
}
@@ -2,9 +2,9 @@
fun test(): Int {
return listOf(1, 2, 3)
.<caret>filter { it > 1 }
.map { it * 2 }
.let {
it.binarySearch(1)
}
.<caret>filter { it > 1 }
.map { it * 2 }
.let {
it.binarySearch(1)
}
}
@@ -2,11 +2,11 @@
fun test(): Int {
return listOf(1, 2, 3)
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
.let {
it.binarySearch(1)
}
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
.let {
it.binarySearch(1)
}
}
@@ -2,8 +2,8 @@
fun test(list: List<Int>?): List<Int>? {
return list
?.asSequence()
?.filter { it > 1 }
?.map { it * 2 }
?.toList()
?.asSequence()
?.filter { it > 1 }
?.map { it * 2 }
?.toList()
}
@@ -2,11 +2,11 @@
fun test(list: List<Int>): List<Int> {
return list
.asSequence()
.filter { it > 1 }
.mapNotNull {
if (it == 2) return@mapNotNull null
it * 2
}
.toList()
.asSequence()
.filter { it > 1 }
.mapNotNull {
if (it == 2) return@mapNotNull null
it * 2
}
.toList()
}
@@ -3,5 +3,6 @@
// WITH_RUNTIME
fun test(): List<Int> {
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }.toList()
return listOf(1, 2, 3).asSequence().filter { it > 1 }.map { it * 2 }.map { it * 3 }.map { it * 4 }.map { it * 5 }
.toList()
}
@@ -3,8 +3,8 @@
fun test(list: List<Int>): List<Int> {
return list
.filter<caret> { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
.filter<caret> { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
}
@@ -3,10 +3,10 @@
fun test(list: List<Int>): List<Int> {
return list
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
.toList()
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.map { it * 3 }
.map { it * 4 }
.toList()
}
@@ -2,9 +2,9 @@
fun test(list: List<Int>): List<Int> {
return list
.reversed()
.<caret>map { it + 1 }
.map { it + 1 }
.dropLast(1)
.takeLast(2)
.reversed()
.<caret>map { it + 1 }
.map { it + 1 }
.dropLast(1)
.takeLast(2)
}
@@ -2,11 +2,11 @@
fun test(list: List<Int>): List<Int> {
return list
.reversed()
.asSequence()
.map { it + 1 }
.map { it + 1 }
.toList()
.dropLast(1)
.takeLast(2)
}
.reversed()
.asSequence()
.map { it + 1 }
.map { it + 1 }
.toList()
.dropLast(1)
.takeLast(2)
}
@@ -2,10 +2,10 @@
fun test(foo: Foo): List<Int> {
return foo.getList()
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
.asSequence()
.filter { it > 1 }
.map { it * 2 }
.toList()
}
class Foo {
@@ -1,5 +1,6 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }.filterIndexedTo(mutableListOf()) { index, it -> true }
val filterIndexedTo: MutableList<Int> = list.asSequence().filter { it > 1 }
.filterIndexedTo(mutableListOf()) { index, it -> true }
}
@@ -1,5 +1,6 @@
// WITH_RUNTIME
fun test(list: List<Int>) {
val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
val mapIndexedNotNullTo: MutableList<Int> = list.asSequence().filter { it > 1 }
.mapIndexedNotNullTo(mutableListOf()) { index, i -> i }
}
@@ -1,12 +1,12 @@
// WITH_RUNTIME
val x = listOf(1, 2, 3).joinToString(
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
,
// comment1
transform = Int::toString
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
,
// comment1
transform = Int::toString
)
@@ -2,11 +2,11 @@
val sb = StringBuilder()
val x = listOf(1, 2, 3).joinTo(
// comment1
buffer = sb,
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
// comment1
buffer = sb,
// comment2
prefix = "= ",
// comment3
separator = " + "
// comment4
) { "$it*$it" }
@@ -2,7 +2,7 @@
fun test() {
<caret>listOfNotNull(
true, // comment1
null // comment2
true, // comment1
null // comment2
).first()
}
@@ -1,3 +1,3 @@
// WITH_RUNTIME
val v1 = // Some Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } // Some Additional Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 } // Some Additional Comment
@@ -1,3 +1,3 @@
// WITH_RUNTIME
val v1 = // Some Comment
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 }
listOf(1, 2, 3, 11, 33, 25, 100).any { it % 2 == 0 }
@@ -1,6 +1,6 @@
fun foo(p: List<String?>): Int {
val v = p[0]
?: // return -1 if null
<caret>return -1
?: // return -1 if null
<caret>return -1
return v.length
}
@@ -1,8 +1,8 @@
fun foo(p: List<String?>): Int {
val v = p[0]
?: // v is null
// we should do something with it
return -1 // let's return -1
?: // v is null
// we should do something with it
return -1 // let's return -1
// end of if
return v.length
}
@@ -1,6 +1,6 @@
fun foo(): Any {
val yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy = 7
val xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 24
?: return yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
?: return yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
return 42
}
@@ -1,6 +1,6 @@
@Suppress(
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
<caret>"HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
<caret>"HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
)
class Dummy
@@ -1,6 +1,6 @@
@Suppress(
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
"EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
"HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL",
"EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
"HEADER_ENUM_CONSTRUCTOR"
)
class Dummy
@@ -2,6 +2,6 @@
// FIX: Add trailing comma
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add trailing comma
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add trailing comma
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,9 +2,9 @@
// FIX: Add trailing comma
val x = {
x: String,
y
: String,
x: String,
y
: String,
->
val a = 2
}
@@ -2,7 +2,7 @@
// FIX: Fix comma position
fun a(
i: Int, /*
i: Int, /*
*/
b: Boolean,
b: Boolean,
) = Unit
@@ -2,7 +2,7 @@
// FIX: Fix comma position
fun a(
i: Int, /*
i: Int, /*
*/
b: Boolean,
b: Boolean,
) = Unit
@@ -2,8 +2,8 @@
// FIX: Fix comma position
val x = {
x: Comparable<Comparable<Number>>,
y: String,
x: Comparable<Comparable<Number>>,
y: String,
->
val a = 42
}
@@ -2,6 +2,6 @@
// FIX: Add line break
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add line break
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -2,6 +2,6 @@
// FIX: Add line break
fun a(
i: Int,
b: Boolean,
i: Int,
b: Boolean,
) = Unit
@@ -1,2 +1,2 @@
fun getText(): String =// let's return xxx
"xxx" //TODO
"xxx" //TODO
@@ -1,2 +1,2 @@
fun getText(): String =// let's return xxx
"xxx"
"xxx"
@@ -1,2 +1,2 @@
fun getText(): String =/* let's return xxx */
"xxx" /* TODO */
"xxx" /* TODO */
@@ -1,9 +1,9 @@
// HIGHLIGHT: INFORMATION
fun abs(x: Int): Int =// No highlighting here
if (x > 0) {
x
}
else {
-x
}
if (x > 0) {
x
}
else {
-x
}
@@ -1,4 +1,4 @@
fun foo(s1: String, s2: String) = s1 + s2
fun bar(): String =
foo("gjahkrgkjuyrtetyuairytoiuyareoihuyitouy897304hkdjgnba", "uiyiuye987130423toiuywtuiyrwityriwyhw")
foo("gjahkrgkjuyrtetyuairytoiuyareoihuyitouy897304hkdjgnba", "uiyiuye987130423toiuywtuiyrwityriwyhw")