Skip to content

Commit

Permalink
Update ktlint to v1 (major) (#352)
Browse files Browse the repository at this point in the history
* Update ktlint to v1

* update API

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Ittner <gabriel.ittner@gmail.com>
  • Loading branch information
renovate[bot] and gabrielittner committed Jun 13, 2024
1 parent 881bd4f commit b57dd63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish = "0.28.0"
dokka = "1.9.20"

clikt = "4.4.0"
ktlint = "0.50.0"
ktlint = "1.3.0"

junit = "4.13.2"
truth = "1.4.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults
import com.pinterest.ktlint.rule.engine.api.KtLintParseException
import com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine
import com.pinterest.ktlint.rule.engine.api.LintError
import com.pinterest.ktlint.rule.engine.core.api.AutocorrectDecision
import com.pinterest.ktlint.rule.engine.core.api.RuleId
import com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider
import java.nio.file.Path
Expand All @@ -24,8 +25,9 @@ internal class KtLintFormatter(
try {
// need to use fromFile instead of fromPath because the latter drops the final new line
val code = Code.fromFile(path.toFile())
val formattedContent = engine.format(code) { error, corrected ->
check(trySendBlocking(KtLintError(path, error, corrected)).isSuccess)
val formattedContent = engine.format(code) { error ->
check(trySendBlocking(KtLintError(path, error, error.canBeAutoCorrected)).isSuccess)
AutocorrectDecision.ALLOW_AUTOCORRECT
}
path.writeText(formattedContent)
} catch (e: KtLintParseException) {
Expand Down

0 comments on commit b57dd63

Please sign in to comment.