Skip to content

Commit 1e7f4a9

Browse files
committed
Analysis: Resolve kotlin stdlib's sum by deprecated warnings
Warning Message: "'sumBy((T) -> Int): Int' is deprecated. Use sumOf instead." Replacing 'sumBy(...)' with 'sumOf(...)' is the recommended action to resolve this kind of deprecated warnings.
1 parent 8ce75c2 commit 1e7f4a9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/formatting/BlockFormatter.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ class BlockFormatter(editor: AztecText,
823823
for (i in lines.indices) {
824824
val lineLength = lines[i].length
825825

826-
val lineStart = (0 until i).sumBy { lines[it].length + 1 }
826+
val lineStart = (0 until i).sumOf { lines[it].length + 1 }
827827

828828
val lineEnd = (lineStart + lineLength).let {
829829
if ((start + it) != editableText.length) it + 1 else it // include the newline or not
@@ -843,7 +843,7 @@ class BlockFormatter(editor: AztecText,
843843
for (i in lines.indices) {
844844
val splitLength = lines[i].length
845845

846-
val lineStart = start + (0 until i).sumBy { lines[it].length + 1 }
846+
val lineStart = start + (0 until i).sumOf { lines[it].length + 1 }
847847
val lineEnd = (lineStart + splitLength + 1).coerceAtMost(end) // +1 to include the newline
848848

849849
val lineLength = lineEnd - lineStart
@@ -860,7 +860,7 @@ class BlockFormatter(editor: AztecText,
860860
for (i in lines.indices) {
861861
val splitLength = lines[i].length
862862

863-
val lineStart = start + (0 until i).sumBy { lines[it].length + 1 }
863+
val lineStart = start + (0 until i).sumOf { lines[it].length + 1 }
864864
val lineEnd = (lineStart + splitLength + 1).coerceAtMost(end) // +1 to include the newline
865865

866866
val lineLength = lineEnd - lineStart
@@ -901,7 +901,7 @@ class BlockFormatter(editor: AztecText,
901901
val list = ArrayList<Int>()
902902

903903
for (i in lines.indices) {
904-
val lineStart = (0 until i).sumBy { lines[it].length + 1 }
904+
val lineStart = (0 until i).sumOf { lines[it].length + 1 }
905905
val lineEnd = lineStart + lines[i].length
906906

907907
if (lineStart > lineEnd) {
@@ -947,7 +947,7 @@ class BlockFormatter(editor: AztecText,
947947
return emptyList()
948948
}
949949

950-
val start = (0 until index).sumBy { lines[it].length + 1 }
950+
val start = (0 until index).sumOf { lines[it].length + 1 }
951951
val end = start + lines[index].length
952952

953953
if (start > end) {
@@ -983,7 +983,7 @@ class BlockFormatter(editor: AztecText,
983983
val list = ArrayList<Int>()
984984

985985
for (i in lines.indices) {
986-
val lineStart = (0 until i).sumBy { lines[it].length + 1 }
986+
val lineStart = (0 until i).sumOf { lines[it].length + 1 }
987987
val lineEnd = lineStart + lines[i].length
988988

989989
if (lineStart >= lineEnd) {
@@ -1017,7 +1017,7 @@ class BlockFormatter(editor: AztecText,
10171017
return false
10181018
}
10191019

1020-
val start = (0 until index).sumBy { lines[it].length + 1 }
1020+
val start = (0 until index).sumOf { lines[it].length + 1 }
10211021
val end = start + lines[index].length
10221022

10231023
if (start >= end) {
@@ -1113,7 +1113,7 @@ class BlockFormatter(editor: AztecText,
11131113
val list = ArrayList<Int>()
11141114

11151115
for (i in lines.indices) {
1116-
val lineStart = (0 until i).sumBy { lines[it].length + 1 }
1116+
val lineStart = (0 until i).sumOf { lines[it].length + 1 }
11171117
val lineEnd = lineStart + lines[i].length
11181118

11191119
if (lineStart >= lineEnd) {
@@ -1146,7 +1146,7 @@ class BlockFormatter(editor: AztecText,
11461146
return false
11471147
}
11481148

1149-
val start = (0 until index).sumBy { lines[it].length + 1 }
1149+
val start = (0 until index).sumOf { lines[it].length + 1 }
11501150
val end = start + lines[index].length
11511151

11521152
if (start >= end) {

aztec/src/main/kotlin/org/wordpress/aztec/formatting/LineBlockFormatter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LineBlockFormatter(editor: AztecText) : AztecFormatter(editor) {
3030
val list = ArrayList<Int>()
3131

3232
for (i in lines.indices) {
33-
val lineStart = (0..i - 1).sumBy { lines[it].length + 1 }
33+
val lineStart = (0..i - 1).sumOf { lines[it].length + 1 }
3434
val lineEnd = lineStart + lines[i].length
3535

3636
if (lineStart >= lineEnd) {
@@ -64,7 +64,7 @@ class LineBlockFormatter(editor: AztecText) : AztecFormatter(editor) {
6464
return false
6565
}
6666

67-
val start = (0..index - 1).sumBy { lines[it].length + 1 }
67+
val start = (0..index - 1).sumOf { lines[it].length + 1 }
6868
val end = start + lines[index].length
6969

7070
if (start >= end) {

0 commit comments

Comments
 (0)