Skip to content

Commit

Permalink
Analysis: Resolve kotlin stdlib's sum by deprecated warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ParaskP7 committed Nov 17, 2022
1 parent 8ce75c2 commit 1e7f4a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ class BlockFormatter(editor: AztecText,
for (i in lines.indices) {
val lineLength = lines[i].length

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

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

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

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

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

val lineLength = lineEnd - lineStart
Expand Down Expand Up @@ -901,7 +901,7 @@ class BlockFormatter(editor: AztecText,
val list = ArrayList<Int>()

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

if (lineStart > lineEnd) {
Expand Down Expand Up @@ -947,7 +947,7 @@ class BlockFormatter(editor: AztecText,
return emptyList()
}

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

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

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

if (lineStart >= lineEnd) {
Expand Down Expand Up @@ -1017,7 +1017,7 @@ class BlockFormatter(editor: AztecText,
return false
}

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

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

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

if (lineStart >= lineEnd) {
Expand Down Expand Up @@ -1146,7 +1146,7 @@ class BlockFormatter(editor: AztecText,
return false
}

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

if (start >= end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LineBlockFormatter(editor: AztecText) : AztecFormatter(editor) {
val list = ArrayList<Int>()

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

if (lineStart >= lineEnd) {
Expand Down Expand Up @@ -64,7 +64,7 @@ class LineBlockFormatter(editor: AztecText) : AztecFormatter(editor) {
return false
}

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

if (start >= end) {
Expand Down

0 comments on commit 1e7f4a9

Please sign in to comment.