Skip to content

Commit

Permalink
Bump ktlint to 0.46.1 (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski authored Jun 23, 2022
1 parent 830eda5 commit 1941025
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("com.gradle.plugin-publish") version "0.18.0"
`java-gradle-plugin`
`maven-publish`
id("org.jmailen.kotlinter") version "3.9.0"
id("org.jmailen.kotlinter") version "3.10.0"
idea
}

Expand All @@ -27,7 +27,7 @@ description = projectDescription
object Versions {
const val androidTools = "7.0.4"
const val junit = "4.13.2"
const val ktlint = "0.45.2"
const val ktlint = "0.46.1"
const val mockitoKotlin = "4.0.0"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jmailen.gradle.kotlinter.support

import com.pinterest.ktlint.core.api.DefaultEditorConfigProperties.disabledRulesProperty
import com.pinterest.ktlint.core.api.EditorConfigOverride
import com.pinterest.ktlint.core.api.EditorConfigOverride.Companion.emptyEditorConfigOverride

internal fun editorConfigOverride(ktLintParams: KtLintParams): EditorConfigOverride {
val rules = ktLintParams.disabledRules

return if (rules.isEmpty()) {
emptyEditorConfigOverride
} else {
EditorConfigOverride.from(disabledRulesProperty to rules.joinToString(separator = ","))
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.gradle.workers.WorkAction
import org.jmailen.gradle.kotlinter.support.KotlinterError
import org.jmailen.gradle.kotlinter.support.KtLintParams
import org.jmailen.gradle.kotlinter.support.defaultRuleSetProviders
import org.jmailen.gradle.kotlinter.support.editorConfigOverride
import org.jmailen.gradle.kotlinter.support.resolveRuleSets
import org.jmailen.gradle.kotlinter.support.userData
import org.jmailen.gradle.kotlinter.tasks.FormatTask
import java.io.File

Expand Down Expand Up @@ -76,12 +76,12 @@ abstract class FormatWorkerAction : WorkAction<FormatWorkerParameters> {

private fun format(file: File, ruleSets: List<RuleSet>, onError: ErrorHandler, script: Boolean): String {
return KtLint.format(
KtLint.Params(
KtLint.ExperimentalParams(
fileName = file.path,
text = file.readText(),
ruleSets = ruleSets,
script = script,
userData = userData(ktLintParams),
editorConfigOverride = editorConfigOverride(ktLintParams),
cb = { error, corrected ->
onError(error, corrected)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import org.jmailen.gradle.kotlinter.support.KotlinterError
import org.jmailen.gradle.kotlinter.support.KtLintParams
import org.jmailen.gradle.kotlinter.support.LintFailure
import org.jmailen.gradle.kotlinter.support.defaultRuleSetProviders
import org.jmailen.gradle.kotlinter.support.editorConfigOverride
import org.jmailen.gradle.kotlinter.support.reporterFor
import org.jmailen.gradle.kotlinter.support.reporterPathFor
import org.jmailen.gradle.kotlinter.support.resolveRuleSets
import org.jmailen.gradle.kotlinter.support.userData
import org.jmailen.gradle.kotlinter.tasks.LintTask
import java.io.File

Expand Down Expand Up @@ -76,12 +76,12 @@ abstract class LintWorkerAction : WorkAction<LintWorkerParameters> {

private fun lint(file: File, ruleSets: List<RuleSet>, onError: ErrorHandler, script: Boolean) =
KtLint.lint(
KtLint.Params(
KtLint.ExperimentalParams(
fileName = file.path,
text = file.readText(),
ruleSets = ruleSets,
script = script,
userData = userData(ktLintParams),
editorConfigOverride = editorConfigOverride(ktLintParams),
cb = { error, _ -> onError(error) }
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class RuleSetsTest {
@Test
fun `test compatibility`() {
KtLint.lint(
KtLint.Params(
"/tmp/src/test/KotlinClass.kt",
"""
KtLint.ExperimentalParams(
fileName = "/tmp/src/test/KotlinClass.kt",
text = """
package test
class KotlinClass {
Expand All @@ -53,7 +53,7 @@ class RuleSetsTest {
}
""".trimIndent(),
resolveRuleSets(defaultRuleSetProviders),
ruleSets = resolveRuleSets(defaultRuleSetProviders),
cb = { _, _ -> }
)
)
Expand All @@ -69,5 +69,5 @@ class TestRule(id: String) : Rule(id) {
node: ASTNode,
autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
) {}
) = Unit
}

0 comments on commit 1941025

Please sign in to comment.