💔 Breaking changes
-
Update and align Maven coordinates - #2195, by @paul-dingemans
Be sure to update Maven coordinates below, to get latest changes!Old Maven coordinates New Maven coordinates com.pinterest.ktlint com.pinterest.ktlint.ktlint-cli com.pinterest.ktlint.ktlint-reporter-baseline com.pinterest.ktlint.ktlint-cli-reporter-baseline com.pinterest.ktlint.ktlint-reporter-checkstyle com.pinterest.ktlint.ktlint-cli-reporter-checkstyle com.pinterest.ktlint.ktlint-cli-reporter com.pinterest.ktlint.ktlint-cli-reporter-core com.pinterest.ktlint.ktlint-reporter-format com.pinterest.ktlint.ktlint-cli-reporter-format com.pinterest.ktlint.ktlint-reporter-html com.pinterest.ktlint.ktlint-cli-reporter-html com.pinterest.ktlint.ktlint-reporter-json com.pinterest.ktlint.ktlint-cli-reporter-json com.pinterest.ktlint.ktlint-reporter-plain com.pinterest.ktlint.ktlint-cli-reporter-plain com.pinterest.ktlint.ktlint-reporter-plain-summary com.pinterest.ktlint.ktlint-cli-reporter-plain-summary com.pinterest.ktlint.ktlint-reporter-sarif com.pinterest.ktlint.ktlint-cli-reporter-sarif -
Add binary compatibility validator - #2131, by @mateuszkwiecinski
-
Replace kotlin public
data class
es with Poko compiler plugin generated ones - #2136, by @mateuszkwiecinski
As a part of public API stabilization, data classes are no longer used in the public API. As of that, functions likecopy()
orcomponentN()
(used for destructuring declarations) are not available anymore. -
Promote experimental rules - #2218, by @paul-dingemans
The rules below have been promoted to non-experimental rules:- blank-line-before-declaration
- context-receiver-wrapping
- discouraged-comment-location
- enum-wrapping
- function-naming
- function-signature
- if-else-bracing
- multiline-expression-wrapping
- if-else-wrapping
- no-blank-line-in-list
- no-consecutive-comments
- no-empty-file
- no-empty-first-line-in-class-body
- no-single-line-block-comment
- parameter-list-spacing
- property-naming
- statement-wrapping
- string-template-indent
- try-catch-finally-spacing
- type-argument-list-spacing
- type-parameter-list-spacing
- unnecessary-parentheses-before-trailing-lambda
-
Fix statement-wrapping and align rule classes - #2178, by @paul-dingemans
Rule classMultilineExpressionWrapping
has been renamed toMultilineExpressionWrappingRule
. Rule classStatementWrapping
has been renamed toStatementWrappingRule
.RULE_ID
constants below are moved to a different Java class at compile time. Each rule provided by Ktlint is to be accompanied by aRULE_ID
constant that can be used in theVisitorModifier.RunAfter
. Filenames did not comply with standard that it should end withRule
suffix.RULE ID Old Java class name New Java class name FUNCTION_EXPRESSION_BODY_RULE_ID
FunctionExpressionBodyKt FunctionExpressionBodyRuleKt FUNCTION_LITERAL_RULE_ID
FunctionLiteralKt FunctionLiteralRuleKt MULTILINE_EXPRESSION_WRAPPING_RULE_ID
MultilineExpressionWrappingKt MultilineExpressionWrappingRuleKt NO_BLANK_LINE_IN_LIST_RULE_ID
NoBlankLineInListKt NoBlankLineInListRuleKt NO_EMPTY_FILE_RULE_ID
(not applicable) NoEmptyFileRuleKt -
Update to Kotlin 1.9 & remove TreeCopyHandler extension - #2113, by @paul-dingemans
Classorg.jetbrains.kotlin.com.intellij.treeCopyHandler
is no longer registered as extension point for the compiler as this is not supported in Kotlin 1.9. Please test your custom rules. In case of unexpected exceptions during formatting of code, see #2044 for possible remediation.
🆕 Features
-
Change default code style to
ktlint_official
- #2144, by @paul-dingemans -
Add new experimental rule
class-signature
- #2119, by @paul-dingemans -
Add new experimental rule
function-expression-body
- #2151, by @paul-dingemans -
Add new experimental rule
chain-method-continuation
- #2088, by @atulgpt -
Add new experimental rule
function-literal
- #2137, by @paul-dingemans -
Add new experimental rule
function-type-modifier-spacing
rule - #2216, by @t-kameyama -
Define
EditorConfigOverride
for dynamically loaded ruleset - #2194, by @paul-dingemans
TheEditorConfigOverride
parameter of theKtlintRuleEngine
can be defined using the factory methodEditorConfigOverride.from(vararg properties: Pair<EditorConfigProperty<*>, *>)
. This requires theEditorConfigProperty
's to be available at compile time. Some commonEditorConfigProperty
's are defined inktlint-rule-engine-core
which is loaded as transitive dependency ofktlint-rule-engine
and as of that are available at compile.
If anEditorConfigProperty
is defined in aRule
that is only provided via a runtime dependency, it gets a bit more complicated. Thektlint-api-consumer
example has now been updated to show how theEditorConfigProperty
can be retrieved from theRule
. -
Move wrapping on semicolon from
wrapping
rule tostatement-wrapping
rule - #2222, by @paul-dingemans
🔧 Fixes
-
Do not indent class body for classes having a long super type list - #2116, by @paul-dingemans
-
Fix indent of explicit constructor - #2118, by @paul-dingemans
-
Fix incorrect formatting of nested function literal - #2107, by @paul-dingemans
-
Add property to disable ktlint for a glob in
.editorconfig
- #2108, by @paul-dingemans -
Fix spacing around colon in annotations - #2126, by @paul-dingemans
-
Fix solving problems in 3 consecutive runs - #2132, by @paul-dingemans
-
Fix indent parenthesized expression - #2127, by @paul-dingemans
-
Fix indent of IS_EXPRESSION, PREFIX_EXPRESSION and POSTFIX_EXPRESSION - #2125, by @paul-dingemans
-
Do not wrap a binary expression after an elvis operator - #2134, by @paul-dingemans
-
Drop obsolete class LintError in ktlint-api-consumer - #2145, by @paul-dingemans
-
Fix null pointer exception for if-else statement with empty THEN block - #2142, by @paul-dingemans
-
Fix false positive in property-naming - #2141, by @paul-dingemans
-
Store relative path of file in baseline file - #2147, by @paul-dingemans
-
Fix url of build status badge - #2162, by @paul-dingemans
-
Fix statement-wrapping and align rule classes - #2178, by @paul-dingemans
-
Fix alignment of type constraints after
where
keyword in function - #2180, by @paul-dingemans -
Fix wrapping of multiline postfix expression - #2184, by @paul-dingemans
-
Do not wrap expression after a spread operator - #2193, by @paul-dingemans
-
Do not remove parenthesis after explicit class constructor without arguments - #2226, by @paul-dingemans
-
Fix conflict between rules due to annotated super type call - #2227, by @paul-dingemans
-
Fix indentation of super type list of class in case it is preceded by a comment - #2228, by @paul-dingemans
-
Super type list starting with an annotation having a parameters - #2230, by @paul-dingemans
-
Do not wrap values in a single line enum when it is preceded by a comment or an annotation - #2229, by @paul-dingemans
📦 Dependencies
-
Update dependency org.codehaus.janino:janino to v3.1.10 - #2110, by @renovate[bot]
-
Update dependency com.google.jimfs:jimfs to v1.3.0 - #2112, by @renovate[bot]
-
Update dependency org.junit.jupiter:junit-jupiter to v5.10.0 - #2148, by @renovate[bot]
-
Update dependency io.github.oshai:kotlin-logging-jvm to v5.1.0 - #2174, by @renovate[bot]
-
Update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.15.0 - #2173, by @renovate[bot]
-
Update plugin org.gradle.toolchains.foojay-resolver-convention to v0.7.0 - #2187, by @renovate[bot]
-
Update kotlin monorepo to v1.9.10 - #2197, by @renovate[bot]
-
Update dependency info.picocli:picocli to v4.7.5 - #2215, by @renovate[bot]
-
Update dependency org.jetbrains.dokka:dokka-gradle-plugin to v1.9.0 - #2221, by @renovate[bot]
-
Update dependency org.slf4j:slf4j-simple to v2.0.9 - #2224, by @renovate[bot]
💬 Other
-
Setup toolchains, compile project with Java 20 only, run test on various Java versions - #2120, by @mateuszkwiecinski
-
Add release-changelog-builder-action to temporary workflow - #2196, by @paul-dingemans