From 0b043f4f4172c95de865e75c45864a03d7085e65 Mon Sep 17 00:00:00 2001 From: Brian Norman Date: Sun, 29 Nov 2020 16:12:18 -0600 Subject: [PATCH] Fix lint errors --- .github/workflows/lint.yml | 2 +- .../kotlin/com/bnorm/power/IrStackVariable.kt | 40 ++++++++++--------- .../test/kotlin/com/bnorm/power/compiler.kt | 6 +-- .../src/test/kotlin/com/bnorm/power/test.kt | 19 +++------ 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 54f11032686..1b26368cd2a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - name: Run ktlint - uses: ScaCap/action-ktlint@1.1 + uses: ScaCap/action-ktlint@1.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-pr-check diff --git a/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/IrStackVariable.kt b/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/IrStackVariable.kt index 6a889f0d438..aa0a5b4a259 100644 --- a/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/IrStackVariable.kt +++ b/kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/IrStackVariable.kt @@ -66,30 +66,34 @@ fun IrBuilderWithScope.buildMessage( val rowValues = valuesByRow[row]?.let { values -> values.sortedBy { it.indent } } ?: emptyList() val indentations = rowValues.map { it.indent } - addArgument(irString { - appendLine() - append(rowSource) - if (indentations.isNotEmpty()) { + addArgument( + irString { appendLine() - var last = -1 - for (i in indentations) { - if (i > last) indent(i - last - 1).append("|") - last = i + append(rowSource) + if (indentations.isNotEmpty()) { + appendLine() + var last = -1 + for (i in indentations) { + if (i > last) indent(i - last - 1).append("|") + last = i + } } } - }) + ) for (tmp in rowValues.asReversed()) { - addArgument(irString { - appendLine() - var last = -1 - for (i in indentations) { - if (i == tmp.indent) break - if (i > last) indent(i - last - 1).append("|") - last = i + addArgument( + irString { + appendLine() + var last = -1 + for (i in indentations) { + if (i == tmp.indent) break + if (i > last) indent(i - last - 1).append("|") + last = i + } + indent(tmp.indent - last - 1) } - indent(tmp.indent - last - 1) - }) + ) addArgument(irGet(tmp.value)) } } diff --git a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/compiler.kt b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/compiler.kt index 1fe0c37d623..5726ed12b5f 100644 --- a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/compiler.kt +++ b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/compiler.kt @@ -9,13 +9,13 @@ import java.lang.reflect.InvocationTargetException import kotlin.test.assertEquals import kotlin.test.fail -val DEFAULT_COMPONENT_REGISTRARS = arrayOf( - PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert"))), +private val DEFAULT_COMPONENT_REGISTRARS = arrayOf( + PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert"))) ) fun compile( list: List, - vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS, + vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS ): KotlinCompilation.Result { return KotlinCompilation().apply { sources = list diff --git a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/test.kt b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/test.kt index 96c4fc46f95..556305bea79 100644 --- a/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/test.kt +++ b/kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/test.kt @@ -16,15 +16,8 @@ package com.bnorm.power -import com.tschuchort.compiletesting.KotlinCompilation -import com.tschuchort.compiletesting.SourceFile -import org.intellij.lang.annotations.Language -import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar import org.jetbrains.kotlin.name.FqName import org.junit.Test -import java.lang.reflect.InvocationTargetException -import kotlin.test.assertEquals -import kotlin.test.fail class CompilerTest { @Test @@ -279,12 +272,12 @@ fun main() { assert(1.shl(1) == 4) }""", """ -Assertion failed -assert(1.shl(1) == 4) - | | - | false - 2 -""".trimIndent() + Assertion failed + assert(1.shl(1) == 4) + | | + | false + 2 + """.trimIndent() ) assertMessage(