All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
modifier-list-spacing
and context-receiver-list-wrapping
- #3077, by @paul-dingemansoperand-expression-wrapping
rule as experimental - #3081, by @paul-dingemansWith upgrade to Kotlin 2.2.0, Ktlint 1.7.0 supports context parameters.
Add context-receiver-list-wrapping
rule - #3034, by @paul-dingemans
Add context receiver list to modifier-order
rule - #3031, by @paul-dingemans
Ignore context parameters in rule context-receiver-wrapping
- #3033, by @paul-dingemans
Do not run no-unused-imports
rule by default - #3039, by @paul-dingemans
The no-unused-import
rule is no longer run by default as it keeps causing problems. It will be removed in Ktlint 2.0
. Until then, the rule can still be run, when enabled explicitly in .editorconfig
.
Add experimental rule expression-operand-wrapping
- #3056, by @paul-dingemans
This rule aligns wrapping of arithmetic and logical multiline expressions. The condition-wrapping
rule which did something similar for logical multiline expressions only no longer reports and fixes violations. It will be removed in Ktlint 2.0
.
Deprecate functions in ASTNodeExtensions
, and where applicable provide property accessors - #3026, by @paul-dingemans
When using ASTNodeExtensions
please replace function calls with the new (temporary) property accessors. The temporary property accessors are needed to maintain backwards compatability with Java integration. In Ktlint 2.0
the functions will be removed, and the temporary property accessors will be replaced with final names.
Suppress warning “sun.misc.Unsafe::objectFieldOffset” in Ktlint CLI (Java24+) - #3040, by @paul-dingemans
Suppress error “A restricted method in java.lang.System has been called” on Java 24 in KtLint CLI only - #3043, by @paul-dingemans
Remove unneeded “--add-opens=java.base/java.lang=ALL-UNNAMED” - #3044, by @paul-dingemans
Do not remove an empty value parameter list from a call expression when it is nested - #3017, by @paul-dingemans
Clarify violation message in filename
rule - #3046, by @paul-dingemans
chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v1 - #2989, by @renovate[bot]
chore(deps): update plugin com.gradle.develocity to v4.0.2 - #2996, by @renovate[bot]
fix(deps): update junit5 monorepo - #3005, by @renovate[bot]
fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugin to v2.2.0-rc3 - #3015, by @renovate[bot]
fix(deps): update dependency org.junit.jupiter:junit-jupiter to v5.13.2 - #3020, by @renovate[bot]
fix(deps): update dependency org.junit.platform:junit-platform-launcher to v1.13.2 - #3021, by @renovate[bot]
fix(deps): update kotlin monorepo to v2.2.0 - #3018, by @renovate[bot]
chore(deps): update plugin shadow to v8.3.8 - #3030, by @renovate[bot]
fix(deps): update junit-framework monorepo - #3037, by @renovate[bot]
chore(deps): update plugin kotlinx-binary-compatibiltiy-validator to v0.18.1 - #3050, by @renovate[bot]
fix(deps): update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.19.1 - #3053, by @renovate[bot]
fix(deps): update dependency com.google.jimfs:jimfs to v1.3.1 - #3054, by @renovate[bot]
chore(deps): update dependency gradle to v9.0.0-rc-2 - #3055, by @renovate[bot]
Update publishing URLs to point to Central Portal OSSRH staging API - #3006, by @shashachu
Update publishing credentials to use new Central Portal username/token - #3007, by @shashachu
Improve build - #3025, by @mateuszkwiecinski
Bump poko-gradle-plugin
with a workaround (enforce compatible Kotlin version) - #3035, by @mateuszkwiecinski
Java 24 - #3049, by @paul-dingemans
Make build-logic
plugins expose binary plugins - #3047, by @mateuszkwiecinski
Cleanup Java 24 bump - #3051, by @mateuszkwiecinski
🆕 Features
Add configuration option to handle (certain) annotation with parameters identical to annotations without parameters - #2950, by @paul-dingemans
Set system properties to prevent failure when running in ktlint-intellij-plugin with custom installation - #2970, by @paul-dingemans
🔧 Fixes
Deprecations in 1.5.0 - #2913, by @paul-dingemans
Fix incorrect error message in PropertyNamingRule when enforcing PascalCase - #2934, by @lsurvila
Sort RuleProvider declarations in StandardRuleSetProvider - #2941, by @3flex
Remove usages of getPsi() - #2901, by @mgroth0
Refactor KotlinPsiFileFactory to KotlinCompiler - #2951, by @paul-dingemans
Reduces the number of conversions between “psi” and ASTNode - #2964, by @paul-dingemans
Fix slow response of the git pre commit hook as generated by ktlint - #2978, by @paul-dingemans
Move logic of missing whitespace before block comment to NoSingleLineBlockCommentRule - #2979, by @paul-dingemans
Report and fix a single line condition wrapped between parentheses with an unexpected newline - #2980, by @paul-dingemans
Do not wrap an operation reference after an annotated expression to a separate new line - #2983, by @paul-dingemans
📦 Dependencies
fix(deps): update dependency org.jetbrains.dokka:dokka-gradle-plugin to v2 - #2906, by @renovate[bot]
chore(deps): update plugin kotlinx-binary-compatibiltiy-validator to v0.17.0 - #2907, by @renovate[bot]
Complete upgrade Dokka to V2 - #2914, by @paul-dingemans
fix(deps): update dependency ch.qos.logback:logback-classic to v1.3.15 - #2917, by @renovate[bot]
fix(deps): update dependency org.assertj:assertj-core to v3.27.3 - #2927, by @renovate[bot]
chore(deps): update plugin shadow to v8.3.6 - #2935, by @renovate[bot]
fix(deps): update dependency com.github.ajalt.clikt:clikt to v5.0.3 - #2938, by @renovate[bot]
fix(deps): update dependency org.slf4j:slf4j-simple to v2.0.17 - #2947, by @renovate[bot]
chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v0.10.0 - #2963, by @renovate[bot]
fix(deps): update dependency org.junit.jupiter:junit-jupiter to v5.12.2 - #2945, by @renovate[bot]
fix(deps): update dependency io.github.oshai:kotlin-logging-jvm to v7.0.7 - #2965, by @renovate[bot]
fix(deps): update dependency io.github.hakky54:logcaptor to v2.11.0 - #2968, by @renovate[bot]
chore(deps): update dependency gradle to v8.14 - #2971, by @renovate[bot]
chore(deps): update plugin com.gradle.develocity to v4.0.1 - #2972, by @renovate[bot]
fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugin to v2.2.0-beta2 - #2977, by @renovate[bot]
fix(deps): update dependency org.ec4j.core:ec4j-core to v1.1.1 - #2987, by @renovate[bot]
fix(deps): update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.18.7 - #2986, by @renovate[bot]
fix(deps): update kotlin monorepo to 2.1.21 - #2985, by @renovate[bot]
💬 Other
The release of Kotlin 2.1 is the primary reason for publishing this release earlier than planned. Because of the removal of some language elements in Kotlin 2.1, the embedded Kotlin compiler in KtLint blocked Kotlinter users from upgrading to Kotlin 2.1.
Add missing space between fun
keyword and identifier when latter is wrapped between backticks - #2890, by @paul-dingemans
Add configuration setting for constant names in property-naming
rule - #2893, by @paul-dingemans
Allow backing property to be defined in the companion object (backing-property-naming
) - #2895, by @paul-dingemans
Ignore multi dollar string interpolation prefix in string-template-indent
rule - #2888, by @paul-dingemans
Wrap the expression body in case .editorconfig
property ktlint_function_signature_body_expression_wrapping
is set to always
- #2873, by @paul-dingemans
Fix false positive when empty parameter list is in between trailing lambda's of a nested call expression - #2891, by @paul-dingemans
Do not wrap a context receiver in a function parameter type reference - #2892, by @paul-dingemans
Allow comment before parameter list in function literal (function-literal
) - #2894, by @paul-dingemans
chore(deps): update plugin com.gradle.develocity to v3.18.2 - #2865, by @renovate[bot]
chore(deps): update dependency gradle to v8.11.1 - #2875, by @renovate[bot]
fix(deps): update dependency io.github.hakky54:logcaptor to v2.10.0 - #2874, by @renovate[bot]
fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugin to v2.1.0-rc2 - #2871, by @renovate[bot]
fix(deps): update dependency io.github.oshai:kotlin-logging-jvm to v7.0.3 - #2883, by @renovate[bot]
fix(deps): update kotlin monorepo to v2.1.0 - #2880, by @renovate[bot]
fix(deps): update dependency com.github.ajalt.clikt:clikt to v5.0.2 - #2886, by @renovate[bot]
chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v0.9.0 - #2887, by @renovate[bot]
fix(deps): update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.18.0 - #2889, by @renovate[bot]
Suppress backing-property-naming
on @Suppress("PropertyName")
- #2741, by @paul-dingemans
Check that code can still be parsed after a format - #2742, by @paul-dingemans
Support suppressing backing-property-naming via ObjectPropertyName - #2751, by @Goooler
Ignore properties starting with _
in backing-property-naming
rule - #2753, by @paul-dingemans
Suppress backing-property-naming
rule with @Suppress("LocalVariableName")
- #2785, by @paul-dingemans
Do not repeat formatting if file is unchanged - #2805, by @paul-dingemans
Add new rule when-entry-bracing
- #2829, by @paul-dingemans
Add .editorconfig
property ij_kotlin_indent_before_arrow_on_new_line
- #2838, by @paul-dingemans
Add CLI option --stdin-path
to provide a virtual file location for stdin - #2836, by @adecker89
Add property .editorconfig
property ktlint_enum_entry_name_casing
- #2839, by @paul-dingemans
Prevent line separators to be changed from CRLF to LF - #2752, by @paul-dingemans
fix: don't remove arrow from lambdas that are when/if leaf nodes - #2758, by @tKe
Fix false positive in no-semi
rule for enum class without enum entries - #2774, by @paul-dingemans
Prevent conflict between multiline-expression-wrapping
and function-signature
- #2775, by @paul-dingemans
Ignore max_line_length
property unless max-line-length
rule is enabled - #2783, by @paul-dingemans
Fix false positive in class-signature
when EOL comment is between a class annotation and other class modifier - #2786, by @paul-dingemans
Fix globs ending with **
- #2787, by @paul-dingemans
Return exit code 1 in case violations have been found but file is unchanged - #2803, by @paul-dingemans
Ignore missing whitespace after trailing comma in single line parameter value list - #2806, by @paul-dingemans
Remove HEADER_KEYWORD & IMPL_KEYWORD - #2810, by @3flex
Function signature rule ignores context receiver when on separate line - #2814, by @paul-dingemans
Do not remove imports for which the fully qualified path is identical to the package name - #2822, by @paul-dingemans
Fix indentation of a multiline parameter list inside a function literal for code style ktlint_official
- #2823, by @paul-dingemans
Do not insert a trailing comma in a multiline when-entry containing a guard - #2825, by @paul-dingemans
Fix wrapping of expression body when max_line_length
not set - #2833, by @paul-dingemans
Update dependency io.github.oshai:kotlin-logging-jvm to v7 - #2701, by @renovate[bot]
Update dependency org.assertj:assertj-core to v3.26.3 - #2738, by @renovate[bot]
Update mikepenz/release-changelog-builder-action action to v5 - #2756, by @renovate[bot]
chore(deps): update plugin kotlinx-binary-compatibiltiy-validator to v0.16.3 - #2759, by @renovate[bot]
fix(deps): update dependency org.slf4j:slf4j-simple to v2.0.16 - #2764, by @renovate[bot]
Migrate to com.gradleup.shadow - #2763, by @Goooler
chore(deps): update gradle/actions action to v4 - #2760, by @renovate[bot]
chore(deps): update plugin com.gradle.develocity to v3.18.1 - #2792, by @renovate[bot]
chore(deps): update dependency gradle to v8.10.2 - #2812, by @renovate[bot]
chore(deps): update plugin shadow to v8.3.3 - #2820, by @renovate[bot]
fix(deps): update dependency com.github.ajalt.clikt:clikt to v5.0.1 - #2828, by @renovate[bot]
chore(deps): update kotlin monorepo to v2.0.21 - #2831, by @renovate[bot]
fix(deps): update dependency org.ec4j.core:ec4j-core to v1.1.0 - #2832, by @renovate[bot]
fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugin to v2.1.0-beta2 - #2834, by @renovate[bot]
fix(deps): update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.17.2 - #2837, by @renovate[bot]
fix(deps): update dependency org.junit.jupiter:junit-jupiter to v5.11.3 - #2840, by @renovate[bot]
chore(deps): update actions/checkout digest to 11bd719 - #2841, by @renovate[bot]
no-unused-imports
- #2725, by @paul-dingemansFormat was not able to resolve all violations which (theoretically) can be autocorrected
- #2727, by @paul-dingemansSupport partial formatting - #2631, by @paul-dingemans
Suppress property-name
rule for ObjectPropertyName
or PrivatePropertyName
- #2643, by @paul-dingemans
Let API Consumer decide whether a LintError has to be autocorrected, or not - #2671, by @paul-dingemans
Promote experimental rules to non-experimental - #2674, by @paul-dingemans
Do not wrap operation reference after multiline string template - #2591, by @paul-dingemans
Ignore max line length in case the line contains only a string template followed by a comma - #2598, by @paul-dingemans
Ignore nested reference expressions in chain-method-continuation
- #2606, by @paul-dingemans
Prevent exception in binary-expression-wrapping
rule - #2607, by @paul-dingemans
Do not merge opening quotes of multiline string template with (single line) function signature - #2609, by @paul-dingemans
Fix replacement of redundant curly braces - #2617, by @paul-dingemans
Set and reset Locale to pass test for non-english contributor. - #2622, by @Jaehwa-Noh
Fix unwanted whitespace between super class constructor and its argument list - #2630, by @tKe
Fix typo's - #2641, by @paul-dingemans
Handle trailing space on preceding line in call to lineLengthWithoutNewlinePrefix
- #2644, by @paul-dingemans
Fix KDoc for RuleSetProviderV3 - #2645, by @gumimin
Fix not checking for spacing around binary operators inside unary expression - #2653, by @cflee
Fix blank line before declarations
rule code example - #2657, by @k-taro56
Fixed [{ }] notation for issue #2675 - #2677, by @Jolanrensen
Simplify default properties loading - #2679, by @Goooler
Update dependency org.jetbrains.dokka:dokka-gradle-plugin to v1.9.20 - #2590, by @renovate[bot]
Update softprops/action-gh-release action to v2 - #2600, by @renovate[bot]
Update dependency io.github.detekt.sarif4k:sarif4k to v0.6.0 - #2605, by @renovate[bot]
Update dependency gradle to v8.7 - #2616, by @renovate[bot]
Migrate to develocity plugin - #2625, by @Goooler
Update dependency org.slf4j:slf4j-simple to v2.0.13 - #2632, by @renovate[bot]
Update gradle/wrapper-validation-action action to v3 - #2633, by @renovate[bot]
Update dependency io.github.oshai:kotlin-logging-jvm to v6.0.9 - #2634, by @renovate[bot]
Update dependency com.github.ajalt.clikt:clikt to v4.4.0 - #2647, by @renovate[bot]
Update kotlin monorepo to v1.9.24 - #2649, by @renovate[bot]
Update plugin com.gradle.develocity to v3.17.4 - #2660, by @renovate[bot]
Update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.15.3 - #2662, by @renovate[bot]
Update actions/checkout digest to a5ac7e5 - #2664, by @renovate[bot]
Update dependency org.assertj:assertj-core to v3.26.0 - #2669, by @renovate[bot]
None
Break dependency between string-template-indent and multiline-expression-wrapping - #2505, by @paul-dingemans
Allow string template to exceed max line length when it is the only element on a line - #2480, by @paul-dingemans
Add configuration setting for ignoring argument-list-wrapping
above threshold of argument - #2481, by @paul-dingemans
NOTE: In code style ktlint_official
this threshold is unset
so that arguments are always wrapped. If this impacts your code too much, you can make it backward compatible by setting .editorconfig
property ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than
to value 8
. For other code styles this property is initialized with value 8
and as of that backward compatible by default.
Ignore EOL comment that causes max_line_length to be exceeded, except in max-line-length rule - #2516, by @paul-dingemans
Add new rule for disallowing KDoc at non-whitelisted locations - #2548, by @paul-dingemans
Improve insert of suppression - #2546, by @paul-dingemans
Ignore modifier of backing property in android_studio
code style - #2552, by @paul-dingemans
Add rule to check spacing around square brackets ‘square-brackets-spacing’ - #2555, by @paul-dingemans
Add rule blank-line-between-when-conditions
- #2564, by @paul-dingemans
Prevent IllegalArgumentException in argument-list-wrapping
rule - #2500, by @paul-dingemans
Ignore function which is returned as result in a function body - #2526, by @paul-dingemans
Fix false positive newline expected before comment in enum - #2527, by @paul-dingemans
Report violation when parameter list is preceded by a comment - #2541, by @paul-dingemans
Ignore EOL comments in value-argument-comment
and value-parameter-comment
- #2551, by @paul-dingemans
Do not indent string template starting at first position of line - #2553, by @paul-dingemans
Prevent conflict when curly closing brace is followed by range (until) operator - #2554, by @paul-dingemans
Run argument-list-wrapping after function-signature - #2568, by @paul-dingemans
Ignore simple reference expressions in chain-method-continuation
- #2569, by @paul-dingemans
chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v0.8.0 - #2503, by @renovate[bot]
fix(deps): update dependency io.github.oshai:kotlin-logging-jvm to v6 - #2440, by @renovate[bot]
Replace gradle/gradle-build-action@v3 with gradle/actions/setup-gradle@v3 - #2518, by @paul-dingemans
chore(deps): update plugin kotlinx-binary-compatibiltiy-validator to v0.14.0 - #2522, by @renovate[bot]
chore(deps): update gradle/wrapper-validation-action action to v2 - #2523, by @renovate[bot]
chore(deps): update ffurrer2/extract-release-notes action to v2 - #2515, by @renovate[bot]
chore(deps): update dependency gradle to v8.6 - #2531, by @renovate[bot]
fix(deps): update dependency org.assertj:assertj-core to v3.25.3 - #2536, by @renovate[bot]
fix(deps): update dependency org.junit.jupiter:junit-jupiter to v5.10.2 - #2534, by @renovate[bot]
fix(deps): update dependency org.slf4j:slf4j-simple to v2.0.12 - #2538, by @renovate[bot]
fix(deps): update dependency org.codehaus.janino:janino to v3.1.12 - #2559, by @renovate[bot]
None
Fix incorrect generateEditorConfig example in documentation - #2444, by @stay7
Fix insert of suppression on binary expression - #2463, by @paul-dingemans
Loosen dependency between chain-method-continuation and argument-list-wrapping - #2468, by @paul-dingemans
Keep arrow when both parameter list and block of function literal are empty - #2469, by @paul-dingemans
Improve wrapping of binary expressions - #2479, by @paul-dingemans
Resolve conflict between parameter-list-spacing and parameter-list-wrapping - #2491, by @paul-dingemans
Do not wrap binary expression value argument if it is already preceded by a newline - #2493, by @paul-dingemans
Fix operator spacing - #2473, by @paul-dingemans
Run argument-list-wrapping
, class-signature
and function-signature
when comment rules are disabled - #2466, by @paul-dingemans
fix(deps): update kotlin monorepo to v1.9.22 - #2456, by @renovate[bot]
chore(deps): update actions/setup-python action to v5 - #2417, by @renovate[bot]
fix(deps): update dependency org.slf4j:slf4j-simple to v2.0.10 - #2470, by @renovate[bot]
fix(deps): update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.15.2 - #2485, by @renovate[bot]
fix(deps): update dependency org.assertj:assertj-core to v3.25.1 - #2486, by @renovate[bot]
Compile with java 21 instead of 20 - #2320, by @paul-dingemans
Improve checking on backing property - #2346, by @paul-dingemans
Add multiline-loop to complement multiline-if-else - #2298, by @hendraanggrian
Add “UnusedImport” as @Suppress alias - #2357, by @paul-dingemans
Allow backing property to be correlated to a public function - #2356, by @paul-dingemans
Add helper function ‘fromSnippetWithPath’ to create a Code instance - #2359, by @paul-dingemans
Support logging and exception throwing when loading baseline - #2362, by @paul-dingemans
Allow factory methods to use generics, and to overload other factory … - #2366, by @paul-dingemans
Remove dependencies on discouraged-comment-location rule - #2371, by @paul-dingemans
Ignore imports for rangeUntil
in no-unused-imports
rule - #2376, by @paul-dingemans
Ignore imports for assign
in no-unused-imports
rule - #2382, by @paul-dingemans
Ignore invalid function names when importing from “junit.framework” - #2386, by @paul-dingemans
Add experimental rules condition-wrapping
and mixed-condition-operators
- #2401, by @paul-dingemans
Allow property, function and class name to be same as keyword wrapped with backticks - #2405, by @paul-dingemans
Set offset of max-line-length
violation to the last position at which a newline can be inserted to fix the violation - #2419, by @paul-dingemans
Add support for API Consumers to add suppressions - #2428, by @paul-dingemans
Disallow else-if (..) <statement>
as single line construct - #2430, by @paul-dingemans
Allow empty constructor for expected class declaration - #2431, by @paul-dingemans
Disallow comments in try-catch-finally at unexpected locations - #2432, by @paul-dingemans
Make ktlint.bat more environment agnostic - #2421, by @TWiStErRob
Suppress property-naming rule via @Suppress("ConstPropertyName")
- #2442, by @paul-dingemans
Remove obsolete configuration files - #2321, by @paul-dingemans
De-indent the closing angle bracket of the type argument list and type parameter lists in ktlint_official code style - #2302, by @paul-dingemans
docs: Fix artifact url of Maven Central Badge - #2327, by @guicamest
Remove redundant arrow in function literal without parameters / fix documentation - #2365, by @paul-dingemans
Move curly brace before all consecutive comments preceding that curly brace - #2375, by @paul-dingemans
Prevent stack overflow exception when code provided via stdin can not be parsed as Kotlin, nor Kotlin script - #2380, by @paul-dingemans
Fix searching from inside a hidden directory - #2377, by @kitterion
Prevent unwanted joining of KDoc with preceding type-parameter-list - #2381, by @paul-dingemans
Fix false positive violation in annotation
rule - #2400, by @paul-dingemans
Replace all function bodies with body expressions in a single run - #2395, by @paul-dingemans
Fix offset for violation when final newline is missing - #2407, by @paul-dingemans
Fix path to ktlint JAR file in ktlint.bat
- #2408, by @paul-dingemans
Simplify max-line-length
implementation - #2410, by @paul-dingemans
Remove deprecated cli parameters --experimental
, --code-style
, --disabled-rules
- #2411, by @paul-dingemans
Fix adding blank line between declaration and an annotated declaration which is preceded by comment - #2429, by @paul-dingemans
Update CODE_OF_CONDUCT with correct path - #2437, by @OriginalMHV
fix(deps): update dependency org.jetbrains.dokka:dokka-gradle-plugin to v1.9.10 - #2323, by @renovate[bot]
fix(deps): update dependency org.junit.jupiter:junit-jupiter to v5.10.1 - #2342, by @renovate[bot]
fix(deps): update kotlin monorepo to v1.9.21 - #2374, by @renovate[bot]
fix(deps): update dependency org.codehaus.janino:janino to v3.1.11 - #2387, by @renovate[bot]
fix(deps): update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.15.1 - #2389, by @renovate[bot]
chore(deps): update dependency gradle to v8.5 - #2392, by @renovate[bot]
chore(deps): update actions/checkout digest to b4ffde6 - #2329, by @renovate[bot]
chore(deps): update actions/setup-java action to v4 - #2393, by @renovate[bot]
fix(deps): update dependency ch.qos.logback:logback-classic to v1.3.14 - #2406, by @renovate[bot]
fix(deps): update dependency io.github.hakky54:logcaptor to v2.9.2 - #2409, by @renovate[bot]
fix(deps): update dependency io.github.oshai:kotlin-logging-jvm to v5.1.4 - #2439, by @renovate[bot]
.editorconfig
property ktlint_function_naming_ignore_when_annotated_with
so that rule function-naming
can be ignored based on annotations on that rule. See function-naming.Update badge for Maven Central - #2245, by @Goooler
Fix code style parameter in cli - #2241, by @paul-dingemans
Anonymous function in assignment - #2263, by @paul-dingemans
Fix indent of multiline object declaration inside class - #2266, by @paul-dingemans
Do not replace function body with multiple exit points - #2273, by @paul-dingemans
Ignore override of function in rule function-naming
- #2274, by @paul-dingemans
Suppress function-naming
based on annotations - #2275, by @paul-dingemans
Force blank line before object declaration - #2287, by @paul-dingemans
Multiline expression wrapping - #2290, by @paul-dingemans
Ignore function naming in Kotest classes - #2291, by @paul-dingemans
Improve violation message in discouraged-comment-location
- #2293, by @paul-dingemans
Fix malformed AST when &&
or ||
is at start of line chain-wrapping
- #2300, by @paul-dingemans
Do not report false positives type-argument-list-spacing
and type-parameter-list-spacing
- #2303, by @paul-dingemans
Fix chain method continuation containing higher order function call - #2305, by @paul-dingemans
Update dependency io.github.detekt.sarif4k:sarif4k to v0.5.0 - #2277, by @renovate[bot]
Update dependency gradle to v8.4 - #2294, by @renovate[bot]
Update actions/checkout action to v4 - #2225, by @renovate[bot]
Update actions/checkout digest to 8ade135 - #2295, by @renovate[bot]
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 like copy()
or componentN()
(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:
Fix statement-wrapping and align rule classes - #2178, by @paul-dingemans
Rule class MultilineExpressionWrapping
has been renamed to MultilineExpressionWrappingRule
. Rule class StatementWrapping
has been renamed to StatementWrappingRule
. RULE_ID
constants below are moved to a different Java class at compile time. Each rule provided by Ktlint is to be accompanied by a RULE_ID
constant that can be used in the VisitorModifier.RunAfter
. Filenames did not comply with standard that it should end with Rule
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
Class org.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.
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 The EditorConfigOverride
parameter of the KtlintRuleEngine
can be defined using the factory method EditorConfigOverride.from(vararg properties: Pair<EditorConfigProperty<*>, *>)
. This requires the EditorConfigProperty
's to be available at compile time. Some common EditorConfigProperty
's are defined in ktlint-rule-engine-core
which is loaded as transitive dependency of ktlint-rule-engine
and as of that are available at compile. If an EditorConfigProperty
is defined in a Rule
that is only provided via a runtime dependency, it gets a bit more complicated. The ktlint-api-consumer
example has now been updated to show how the EditorConfigProperty
can be retrieved from the Rule
.
Move wrapping on semicolon from wrapping
rule to statement-wrapping
rule - #2222, by @paul-dingemans
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
Update CONTRIBUTING.md - #2163, by @oshai
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
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 dependency gradle to v8.3 - #2186, 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]
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
The ktlint-disable
and ktlint-enable
directives are no longer supported. Ktlint rules can now only be suppressed using the @Suppress
or @SuppressWarnings
annotations. A new rule, internal:ktlint-suppression
, is provided to replace the directives with annotations.
API consumers do not need to provide this rule, but it does no harm when done.
The internal:ktlint-suppression
rule can not be disabled via the .editorconfig
nor via @Suppress
or @SuppressWarnings
annotations.
In Kotlin 1.9 the extension points of the embedded kotlin compiler will change. Ktlint only uses the org.jetbrains.kotlin.com.intellij.treeCopyHandler
extension point. This extension is not yet supported in 1.9, neither is it documented (#KT-58704). Without this extension point it might happen that your custom rules will throw exceptions during runtime. See #1981.
In Ktlint, 7 out of 77 rules needed small and sometimes bigger changes to become independent of the extension point org.jetbrains.kotlin.com.intellij.treeCopyHandler
. The impact on your custom rules may vary dependent on the way the autocorrect has been implemented. When manipulating ASTNode
s there seems to be no impact. When, manipulating PsiElement
s, some functions consistently result in a runtime exception.
Based on the refactoring of the rules as provided by ktlint-ruleset-standard
in Ktlint 0.49.x
the suggested refactoring is as follows:
LeafElement.replaceWithText(String)
with LeafElement.rawReplaceWithText(String)
.PsiElement.addAfter(PsiElement, PsiElement)
with AstNode.addChild(AstNode, AstNode)
. Note that this method inserts the new node (first) argument before the second argument node and as of that is not a simple replacement of the PsiElement.addAfter(PsiElement, PsiElement)
.PsiElement.replace(PsiElement)
with a sequence of AstNode.addChild(AstNode, AstNode)
and AstNode.removeChild(AstNode)
.Be aware that your custom rules might use other functions which also throw exceptions when the extension point org.jetbrains.kotlin.com.intellij.treeCopyHandler
is no longer supported.
In order to help you to analyse and fix the problems with your custom rules, ktlint temporarily supports to disable the extension point org.jetbrains.kotlin.com.intellij.treeCopyHandler
using a flag. This flag is available in the Ktlint CLI and in the KtlintRuleEngine
. By default, the extension point is enabled like it was in previous versions of ktlint.
At least you should analyse the problems by running your test suits by running ktlint and disabling the extension point. Next you can start with fixing and releasing the updated rules. All rules in this version of ktlint have already been refactored and are not dependent on the extension point anymore. In Ktlint CLI the flag is to be activated with parameter --disable-kotlin-extension-point
. API Consumers that use the KtlintRuleEngine
directly, have to set property enableKotlinCompilerExtensionPoint
to false
.
At this point in time, it is not yet decided what the next steps will be. Ktlint might drop the support of the extension points entirely. Or, if the extension point org.jetbrains.kotlin.com.intellij.treeCopyHandler
is fully supported at the time that ktlint will be based on kotlin 1.9 it might be kept. In either case, the flag will be dropped in a next version of ktlint.
binary-expression-wrapping
. This rule wraps a binary expression in case the max line length is exceeded (#1940)org.jetbrains.kotlin.com.intellij.treeCopyHandler
to analyse impact on custom rules #1981no-empty-file
for all code styles. A kotlin (script) file may not be empty (#1074)statement-wrapping
which ensures function, class, or other blocks statement body doesn't start or end at starting or ending braces of the block (#1938). Note, although this rule is added in this release, it is never executed except in unit tests.blank-line-before-declaration
. This rule requires a blank line before class, function or property declarations (#1939)wrapping
(#1078)ktlint-suppression
to replace the ktlint-disable
and ktlint-enable
directives with annotations. This rule can not be disabled via the .editorconfig
(#1947)--format
option of KtLint CLI when finding a violation that can be autocorrected (#1071)0.49.x
is removed. Consult changelog of 0.49.x` released for more information. Summary of removed code:property-naming
(#2024)serialVersionUID
in property-naming
(#2045)parameter-list-wrapping
(#1324)else
branch when body contains only chained calls or binary expression (#2057)RuleId
and RuleSetId
classes. Those classes were defined as value classes in 0.49.0
and 0.49.1
. Although the classes were marked with @JvmInline
it seems that it is not possible to uses those classes from Java base API Consumers like Spotless. The classes have now been replaced with data classes (#2041)info.picocli:picocli
to v4.7.4
org.junit.jupiter:junit-jupiter
to v5.9.3
1.8.22
and Kotlin version to 1.8.22
.io.github.detekt.sarif4k:sarif4k
to v0.4.0
org.jetbrains.dokka:dokka-gradle-plugin
to v1.8.20
--code-style=android_studio
in Ktlint CLI identical to deprecated parameter --android
(#1982)no-consecutive-blank-lines
(#1987).editorconfig
property ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than
when using ktlint_official
code style function-signature
(#1977)indent
(#1993)indent
(#1976)ktlint_official
code style to keep formatting of other code styles consistent with 0.48.x
and before indent
(#1971)no-single-line-block-comment
from comment-wrapping
rule. The no-single-line-block-comment
rule is added as experimental rule to the ktlint_official
code style, but it can be enabled explicitly for the other code styles as well. (#1980)Baseline
from ktlint-cli
to ktlint-cli-reporter-baseline
so that Baseline functionality is reusable for API Consumers.WARNING: This version of KtLint contains a number of breaking changes in KtLint CLI and KtLint API. If you are using KtLint with custom ruleset jars or custom reporter jars, then those need to be upgraded before you can use them with this version of ktlint. Please contact the maintainers of those jars and ask them to upgrade a.s.a.p.
All rule id's in the output of Ktlint are now prefixed with a rule set. Although KtLint currently supports standard rules to be unqualified, users are encouraged to include the rule set id in all references to rules. This includes following:
--disabled-rules
parameter in KtLint CLI..editorconfig
properties used to enable or disable rule and rule sets. Note that properties disabled_rules
and ktlint_disabled_rules
have been removed in this release. See disabled rules for more information.source
element in the KtLint CLI baseline.xml
file. Regenerating this file, fixes all rule references automatically.ktlint-enable
/ ktlint-disable
and the @Suppress('ktlint:...')
annotations.VisitorModifier.RunAfterRule
.The experimental
rule set has been merged with standard
rule set. The rules which formerly were part of the experimental
rule set are still being treated as before. The rules will only be run in case .editorconfig
property ktlint_experimental
is enabled or in case the rule is explicitly enabled.
Note that the prefix experimental:
has to be removed from all references to this rule. Check references in:
--disabled-rules
parameter in KtLint CLI..editorconfig
properties used to enable or disable rule and rule sets. Note that properties disabled_rules
and ktlint_disabled_rules
have been removed in this release. See disabled rules for more information.ktlint-enable
/ ktlint-disable
and the @Suppress('ktlint:...')
annotations.VisitorModifier.RunAfterRule
.The rules below have been promoted to non-experimental rules:
Note that this only affects users that have enabled the standard ruleset while having the experimental rules disabled.
This release is intended to be the last release before the 1.0.x release of ktlint. If all goes as planned, the 1.0.x release does not contain any new breaking changes with except of removal of functionality which is deprecated in this release.
This release contains a lot of breaking changes which aims to improve the future maintainability of Ktlint. If you get stuck while migrating, please reach out to us by creating an issue.
Rules in custom rule sets can now be marked as experimental by implementing the Rule.Experimental
interface on the rule. Rules marked with this interface will only be executed by Ktlint if .editorconfig
property ktlint_experimental
is enabled or if the rule itself has been enabled explicitly.
When using this feature, experimental rules should not be defined in a separate rule set as that would require a distinct rule set id. When moving a rule from an experimental rule set to a non-experimental rule set this would mean that the qualified rule id changes. For users of such rules this means that ktlint directives to suppress the rule and properties in the .editorconfig
files have to be changed.
Field defaultAndroidValue
in class EditorConfigProperty
has been renamed to androidStudioCodeStyleDefaultValue
. New fields ktlintOfficialCodeStyleDefaultValue
and intellijIdeaCodeStyleDefaultValue
have been added. Read more about this in the section “Ktlint Official code style”.
The .editorconfig
properties disabled_rules
and ktlint_disabled_rules
are no longer supported. Specifying those properties in the editorConfigOverride
or editorConfigDefaults
result in warnings at runtime.
A new code style ktlint_official
is introduced. This code style is work in progress but will become the default code style in the 1.0
release. Please try out the new code style and provide your feedback via the issue tracker.
This ktlint_official
code style combines the best elements from the Kotlin Coding conventions and Android's Kotlin styleguide. This code style also provides additional formatting on topics which are not (explicitly) mentioned in those conventions and style guide. But do note that this code style sometimes formats code in a way which is not accepted by the default code formatters in IntelliJ IDEA and Android Studio. The formatters of those editors produce nicely formatted code in the vast majority of cases. But in a number of edge cases, the formatting contains bugs which are waiting to be fixed for several years. The new code style formats code in a way which is compatible with the default formatting of the editors whenever possible. When using this codestyle, it is best to disable (e.g. not use) code formatting in the editor.
The existing code styles have been renamed to make more clear what the basis of the code style is.
The official
code style has been renamed to intellij_idea
. Code formatted with this code style aims to be compatible with default formatter of IntelliJ IDEA. This code style is based on Kotlin Coding conventions. If .editorconfig
property ktlint_code_style
has been set to android
then do not forget to change the value of that property to intellij_idea
. When not set, this is still the default code style of ktlint 0.49
. Note that the default code style will be changed to ktlint_official
in the 1.0
release.
Code style android
has been renamed to android_studio
. Code formatted with this code style aims to be compatible with default formatter of Android Studio. This code style is based on Android's Kotlin styleguide. If .editorconfig
property ktlint_code_style
has been set to android
then do not forget to change the value of that property to android_studio
.
The internal structure of the Ktlint project has been revised. The Ktlint CLI and KtLint API modules have been decoupled where possible. Modules have been restructured and renamed. See API Overview for more information.
This is the last release that contains module ktlint-core
as it had too many responsibilities. All classes in this module are relocated to other modules. Some classes have also been renamed. See tables below for details. Classes that are left behind in the ktlint-core
module are deprecated and were kept in this version for backwards compatibility only. The ktlint-core
module will be removed in Ktlint 0.50.x
.
Classes below have been moved from module ktlint-core
to the new module ktlint-rule-engine-core
:
Old class/package name in ktlint-core | New class/package name in ktlint-rule-engine-core |
---|---|
com.pinterest.ktlint.core.api.editorconfig | com.pinterest.ktlint.rule.engine.core.api.editorconfig |
com.pinterest.ktlint.core.api.EditorConfigProperties | com.pinterest.ktlint.rule.engine.core.api.EditorConfig |
com.pinterest.ktlint.core.api.OptInFeatures | com.pinterest.ktlint.rule.engine.core.api.OptInFeatures |
com.pinterest.ktlint.core.ast.ElementType | com.pinterest.ktlint.rule.engine.core.api.ElementType |
com.pinterest.ktlint.core.ast.package | com.pinterest.ktlint.rule.engine.core.api.ASTNodeExtension |
com.pinterest.ktlint.core.IndentConfig | com.pinterest.ktlint.rule.engine.core.api.IndentConfig |
com.pinterest.ktlint.core.Rule | com.pinterest.ktlint.rule.engine.core.api.Rule |
com.pinterest.ktlint.core.RuleProvider | com.pinterest.ktlint.rule.engine.core.api.RuleProvider |
Classes below have been moved from module ktlint-core
to the new module ktlint-rule-engine
:
Old class/package name in ktlint-core | New class/package name in ktlint-rule-engine |
---|---|
com.pinterest.ktlint.core.api.EditorConfigDefaults | com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults |
com.pinterest.ktlint.core.api.EditorConfigOverride | com.pinterest.ktlint.rule.engine.api.EditorConfigOverride |
com.pinterest.ktlint.core.api.KtLintParseException | com.pinterest.ktlint.rule.engine.api.KtLintParseException |
com.pinterest.ktlint.core.api.KtLintRuleException | com.pinterest.ktlint.rule.engine.api.KtLintRuleException |
com.pinterest.ktlint.core.KtLint | com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine |
com.pinterest.ktlint.core.LintError | com.pinterest.ktlint.rule.engine.api.LintError |
Class com.pinterest.ktlint.core.KtLint.Code.CodeFile
has been replaced with factory method com.pinterest.ktlint.rule.engine.api.Code.fromFile
. Likewise, class com.pinterest.ktlint.core.KtLint.Code.CodeSnippet
has been replaced with factory method com.pinterest.ktlint.rule.engine.api.Code.fromSnippet
.
Class below has been moved from module ktlint-core
to the new module ktlint-cli-ruleset-core
:
Old class/package name in ktlint-core | New class/package name in ktlint-cli-ruleset-core |
---|---|
com.pinterest.ktlint.core.RuleSetProviderV2 | com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3 |
Class below has been moved from module ktlint-core
to the new module ktlint-cli-reporter-core
:
Old class/package name in ktlint-core | New class/package name in ktlint-cli-reporter-core |
---|---|
com.pinterest.ktlint.core.KtlintVersion | com.pinterest.ktlint.cli.reporter.core.api.KtlintVersion |
Class below has been moved from module ktlint-core
to the new module ktlint-logger
:
Old class/package name in ktlint-core | New class/package name in ktlint-logger |
---|---|
com.pinterest.ktlint.core.KtLintKLoggerInitializer.kt | com.pinterest.ktlint.logger.api.KtLintKLoggerInitializer.kt |
Class below has been relocated from module ktlint-core
to module ktlint-cli
:
Old class/package name in ktlint-core | New class/package name in ktlint-cli |
---|---|
com.pinterest.ktlint.core.api.Baseline | com.pinterest.ktlint.cli.api.Baseline |
Module ktlint-reporter-baseline
has been renamed to ktlint-cli-reporter-baseline
. Class below has been relocated:
Old class/package name in ktlint-reporter-baseline | New class/package name in ktlint-cli-reporter-baseline |
---|---|
com.pinterest.ktlint.reporter.baseline | com.pinterest.ktlint.cli.reporter.baseline |
Module ktlint-reporter-checkstyle
has been renamed to ktlint-cli-reporter-checkstyle
. Class below has been relocated:
Old class/package name in ktlint-reporter-checkstyle | New class/package name in ktlint-cli-reporter-checkstyle |
---|---|
com.pinterest.ktlint.reporter.checkstyle | com.pinterest.ktlint.cli.reporter.checkstyle |
Module ktlint-reporter-format
has been renamed to ktlint-cli-reporter-format
. Class below has been relocated:
Old class/package name in ktlint-reporter-format | New class/package name in ktlint-cli-reporter-format |
---|---|
com.pinterest.ktlint.reporter.format | com.pinterest.ktlint.cli.reporter.format |
Module ktlint-reporter-html
has been renamed to ktlint-cli-reporter-html
. Class below has been relocated:
Old class/package name in ktlint-reporter-html | New class/package name in ktlint-cli-reporter-html |
---|---|
com.pinterest.ktlint.reporter.html | com.pinterest.ktlint.cli.reporter.html |
Module ktlint-reporter-json
has been renamed to ktlint-cli-reporter-json
. Class below has been relocated:
Old class/package name in ktlint-reporter-json | New class/package name in ktlint-cli-reporter-json |
---|---|
com.pinterest.ktlint.reporter.json | com.pinterest.ktlint.cli.reporter.json |
Module ktlint-reporter-plain
has been renamed to ktlint-cli-reporter-plain
. Class below has been relocated:
Old class/package name in ktlint-reporter-plain | New class/package name in ktlint-cli-reporter-plain |
---|---|
com.pinterest.ktlint.reporter.plain | com.pinterest.ktlint.cli.reporter.plain |
Module ktlint-reporter-plain-summary
has been renamed to ktlint-cli-reporter-plain-summary
. Class below has been relocated:
Old class/package name in ktlint-reporter-plain-summary | New class/package name in ktlint-cli-reporter-plain-summary |
---|---|
com.pinterest.ktlint.reporter.plain | com.pinterest.ktlint.cli.reporter.plainsummary |
Module ktlint-reporter-sarif
has been renamed to ktlint-cli-reporter-sarif
. Class below has been relocated:
Old class/package name in ktlint-reporter-sarif | New class/package name in ktlint-cli-reporter-sarif |
---|---|
com.pinterest.ktlint.reporter.sarif | com.pinterest.ktlint.cli.reporter.sarif |
RuleSetProviderV2
Custom rule sets build for older versions of KtLint are no longer supported by this version of KtLint. The com.pinterest.ktlint.core.RuleSetProviderV2
interface has been replaced with RuleSetProviderV3
. The accompanying interfaces com.pinterest.ktlint.core.RuleProvider
and com.pinterest.ktlint.core.Rule
have been replaced with com.pinterest.ktlint.ruleset.core.api.RuleProvider
and com.pinterest.ktlint.ruleset.core.api.Rule
respectively.
Contrary to RuleSetProviderV2
, the RuleSetProviderV3
no longer contains information about the rule set. About information now has to be specified in the new Rule
class. This allows custom rule set providers to combine rules originating from different rule sets into a new rule set without losing information about its origin. The type of the id of the rule set is changed from String
to RuleSetId
.
Note that due to renaming and relocation of the RuleSetProviderV3
interface the name of the service provider in the custom reporter needs to be changed from resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProviderV2
to resources/META-INF/services/com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3
.
The rule id's in com.pinterest.ktlint.ruleset.core.api.Rule
have been changed from type String
to RuleId
. A RuleId
has a value that must adhere the convention “rule-set-id
:rule-id
”. The rule set id standard
is reserved for rules which are maintained by the KtLint project. Rules created by custom rule set providers and API Consumers should use a prefix other than standard
to mark the origin of rules which are not maintained by the KtLint project.
When wrapping a rule from the ktlint project and modifying its behavior, please change the ruleId
and about
fields in the wrapped rule, so that it is clear to users whenever they use the original rule provided by KtLint versus a modified version which is not maintained by the KtLint project.
The typealias com.pinterest.ktlint.core.api.EditorConfigProperties
has been replaced with com.pinterest.ktlint.rule.engine.core.api.EditorConfig
. The interface com.pinterest.ktlint.core.api.UsesEditorConfigProperties
has been removed. Instead, the Rule property usesEditorConfigProperties
needs to be set. As a result of those changes, the beforeFirstNode
function in each rule has to changed to something like below:
class SomeRule : Rule( ruleId = RuleId("some-rule-set:some-rule"), usesEditorConfigProperties = setOf(MY_EDITOR_CONFIG_PROPERTY), ) { private lateinit var myEditorConfigProperty: MyEditorConfigProperty override fun beforeFirstNode(editorConfig: EditorConfig) { myEditorConfigProperty = editorConfig[MY_EDITOR_CONFIG_PROPERTY] } ... }
Fields loadOnlyWhenOtherRuleIsLoaded
and runOnlyWhenOtherRuleIsEnabled
have been removed from class com.pinterest.ktlint.rule.engine.core.api.Rule.VisitorModifier.RunAfterRule
and are replaced with a single field mode
. The mode
either contains value REGARDLESS_WHETHER_RUN_AFTER_RULE_IS_LOADED_OR_DISABLED
or ONLY_WHEN_RUN_AFTER_RULE_IS_LOADED_AND_ENABLED
.
ReporterProvider
Custom Reporters build for older versions of KtLint are no longer supported by this version of KtLint. The com.pinterest.ktlint.core.ReporterProvider
interface has been replaced with com.pinterest.ktlint.cli.reporter.core.api.ReporterProviderV2
. The accompanying interface com.pinterest.ktlint.core.Reporter
has been replaced with com.pinterest.ktlint.cli.reporter.core.api.ReporterV2
.
Note that due to renaming and relocation of the ReporterProviderV2
interface the name of the service provider in the custom reporter needs to be changed from resources/META-INF/services/com.pinterest.ktlint.core.ReporterProvider
to resources/META-INF/services/com.pinterest.ktlint.cli.reporter.core.api.ReporterProviderV2
.
The biggest change in the ReporterV2
is the replacement of the LintError
class with KtlintCliError
class. The latter class now contains a status field which more clearly explains the difference between a lint error which can be autocorrected versus a lint error that actually has been autocorrected.
API Consumers provide a set of rules directly to the Ktlint Rule Engine. The com.pinterest.ktlint.core.Rule
has been replaced with com.pinterest.ktlint.ruleset.core.api.Rule
.
The type of the rule id's has been changed from type String
to RuleId
. A RuleId
has a value that must adhere to the convention “rule-set-id
:rule-id
”. Rule set id standard
is reserved for rules which are maintained by the KtLint project. Custom rules created by the API Consumer should use a prefix other than standard
to clearly mark the origin of rules which are not maintained by the KtLint project.
Also, the field About
has been added. This field specifies the name of the maintainer, and the repository url and issue tracker url of the rule. The about information of a rule is printed whenever a rule throws an exception which is caught by the Ktlint Rule Engine.
When wrapping a rule from the ktlint project and modifying its behavior, please change the ruleId
and about
fields in the wrapped rule, so that it is clear to users whenever they use the original rule provided by KtLint versus a modified version which is not maintained by the KtLint project.
The typealias com.pinterest.ktlint.core.api.EditorConfigProperties
has been replaced with com.pinterest.ktlint.rule.engine.core.api.EditorConfig
. The interface com.pinterest.ktlint.core.api.UsesEditorConfigProperties
has been removed. Instead, the Rule property usesEditorConfigProperties
needs to be set. As a result of those changes, the beforeFirstNode
function in each rule has to changed to something like below:
class SomeRule : Rule( ruleId = RuleId("some-rule-set:some-rule"), usesEditorConfigProperties = setOf(MY_EDITOR_CONFIG_PROPERTY), ) { private lateinit var myEditorConfigProperty: MyEditorConfigProperty override fun beforeFirstNode(editorConfig: EditorConfig) { myEditorConfigProperty = editorConfig[MY_EDITOR_CONFIG_PROPERTY] } ... }
Fields loadOnlyWhenOtherRuleIsLoaded
and runOnlyWhenOtherRuleIsEnabled
have been removed from class com.pinterest.ktlint.rule.engine.core.api.Rule.VisitorModifier.RunAfterRule
and are replaced with a single field mode
. The mode
either contains value REGARDLESS_WHETHER_RUN_AFTER_RULE_IS_LOADED_OR_DISABLED
or ONLY_WHEN_RUN_AFTER_RULE_IS_LOADED_AND_ENABLED
.
Like before, the API Consumer can still offer a mix of rules originating from ktlint-ruleset-standard
as well as custom rules.
.editorconfig
property max_line_length
default valuePreviously, the default value for .editorconfig
property max_line_length
was set to -1
in ktlint unless the property was defined explicitly in the .editorconfig
or when ktlint_code_style
was set to Android. As a result of that rules have to check that max_line_length contains a positive value before checking that the actual line length is exceeding the maximum. Now the value Int.MAX_VALUE
(use constant MAX_LINE_LENGTH_PROPERTY_OFF
to refer to that value) is used instead.
Constant KtLint.FILE_PATH_USER_DATA_KEY
has been removed. The file path is passed correctly to the node with element type FILE and can be retrieved as follows:
if (node.isRoot()) { val filePath = (node.psi as? KtFile)?.virtualFilePath ... }
ktlint_offical
. The code style is work in progress and should be considered a preview. It is intended to become the default code style in the next release. Please try it out and give your feedback. See code styles for more information. The following rules have been added to the ktlint_official
code style (the rules can also be run for other code styles when enabled explicitly):no-empty-first-line-in-class-body
. This rule disallows a class to start with a blank line.if-else-bracing
. This rules enforces consistent usage of braces in all branches of a single if, if-else or if-else-if statement.no-consecutive-comments
. This rule disallows consecutive comments except EOL comments (see [examples](See https://pinterest.github.io/ktlint/rules/experimental/#disallow-consecutive-comments)).try-catch-finally-spacing
. This rule enforces consistent spacing in try-catch, try-finally and try-catch-finally statement. This rule can also be run for other code styles, but then it needs to be enabled explicitly.no-blank-line-in-list
. This rule disallows blank lines to be used in super type lists, type argument lists, type constraint lists, type parameter lists, value argument lists, and value parameter lists. (#1224)multiline-expression-wrapping
. This forces a multiline expression as value in an assignment to start on a separate line. (#1217)string-template-indent
. This forces multiline string templates which are post-fixed with .trimIndent()
to be formatted consistently. The opening and closing """
are placed on separate lines and the indentation of the content of the template is aligned with the """
. (#925)if-else-wrapping
. This enforces that a single line if-statement is kept simple. A single line if-statement may contain no more than one else-branch. The branches a single line if-statement may not be wrapped in a block. (#812)parameter-wrapping
(#1846)property-wrapping
(#1846)stdin
with KtLint CLI (#1832)build.gradle
like:dependencies { implementation(platform("com.pinterest:ktlint-bom:0.49.0")) implementation("com.pinterest:ktlint-core") implementation("com.pinterest:ktlint-reporter-html") implementation("com.pinterest:ktlint-ruleset-standard") ... }
enum-wrapping
for all code styles. An enum should either be a single line, or each enum entry should be defined on a separate line. (#1903).editorconfig
properties disabled_rules
and ktlint_disabled_rules
. See disabled rules for more information.--print-ast
. Use IntelliJ IDEA PsiViewer plugin instead. (#1925)no-semi
(#1733)function-signature
.multiline
. function-signature
.standard:filename
rule whenever Ktlint CLI is run with option --stdin
(#1742)ktlint_official
code style) indent
(#1756)trailing-comma-on-declaration-site
(#1711)ktlint_official
code style only indent
(#1540).editorconfig
use value off
for the max_line_length
property instead of value -1
to denote that lines are not restricted to a maximum length (#1824)trailing-comma-on-declaration-site
(#1786)function-return-type-spacing
(#1764)annotation
, wrapping
(#1725)indent
(#1788)indent
(#1788)spacing-between-declarations-with-annotations
(#1802)wrapping
(#1808)indent
(#1830)..<
similar to the range operator ..
in range-spacing
(#1858).editorconfig
property ij_kotlin_imports_layout
contains a |
but no import exists that match any pattern before the first |
then do not report a violation nor insert a blank line import-ordering
(#1845)**/*.kt
and **/*.kts
) so that all Kotlin files excluding the files matching the negate-patterns will be processed (#1847)type-parameter-list-spacing
(#1867)wrapping
(#1867)indent
(#1217)trailing-comma-on-declaration-site
(#1905)ktlint_official
only. function-signature
, parameter-list-wrapping
(#1908)annotation
(#1909)trailing-comma-on-declaration-site
(#1911)ktlint_official
. annotation
(#1916)annotation
(#1917)multiline-if-else
(#1904)ktlint_official
code style) parameter-list-wrapping
(#1681).--patterns-from-stdin
is specified (#1793)1.8.20
and Kotlin version to 1.8.20
.ktlint_official
, do not allow wildcard imports java.util
and kotlinx.android.synthetic
by default. Important: .editorconfig
property ij_kotlin_packages_to_use_import_on_demand
needs to be set to value unset
in order to enforce IntelliJ IDEA default formatter to not generate wildcard imports no-wildcard-imports
(#1797)comment-wrapping
(#1941)comment-wrapping
(#1942)0.48.0
and 0.48.1
Starting with Ktlint 0.48.x
, rule and rule sets can be enabled/disabled with a separate property per rule (set). Please read deprecation of (ktlint_)disable_rules property for more information.
API Consumers that provide experimental rules to the KtLintRuleEngine, must also enable the experimental rules or instruct their users to do so in the .editorconfig
file. From the perspective of the API Consumer it might be confusing or unnecessary to do so as the experimental rule was already provided explicitly.
Ktlint wants to provide the user (e.g. a developer) a uniform and consistent user experience. The .editorconfig
becomes more and more central to store configuration for Ktlint. This to ensure that all team members use the exact same configuration when running ktlint regardless whether the Ktlint CLI or an API Consumer is being used.
The .editorconfig
is a powerful configuration tool which can be used in very different ways. Most projects use a single .editorconfig
file containing one common section for kotlin and kotlin scripts files. For example, the .editorconfig
file of the Ktlint project contains following section:
[*.{kt,kts}] ij_kotlin_imports_layout = * ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma_on_call_site = true
Other projects might contain multiple .editorconfig
files for different parts of the project directory hierarchy. Or, use a single .editorconfig
file containing multiple sections with different globs. Like all other configuration settings in Ktlint, the user should be able to enable and disable the experimental rules. Both for the entire set of experimental rules and for individual experimental rules.
Ktlint allows API Consumers to set default values and override values for the .editorconfig
. Specifying a default value means that the user does not need to define the property in the .editorconfig
file but if the user specifies the value, it will take precedence. Specifying the override value ensures that this takes precedence on a value specified by the user in the .editorconfig
.
From the Ktlint perspective, it is advised that API Consumers provide the default value. See example below, for how to specify the editorConfigDefault
property:
KtLintRuleEngine( ruleProviders = ruleProviders, editorConfigDefaults = EditorConfigDefaults( EditorConfig .builder() .section( Section .builder() .glob(Glob("*.{kt,kts}")) .properties( Property .builder() .name("ktlint_experimental") .value("enabled"), ), ) .build() ) )
If the user has set property ktlint_experimental
explicitly than that value will be used. If the value is not defined, the value provided via editorConfigDefaults
will be used.
If you do want to ignore the value of ktlint_experimental
as set by the user, than you can set the EditorConfigOverride property. But as said before that is discouraged as the user might not understand why the .editorconfig
property is being ignored (provided that the value set is not equal to the value provided by the API Consumer).
annotation
(#1765).editorconfig
properties disabled_rules
or ktlint_disabled_rules
are set. (#1771)max-line-length
should be ignored by rule function-signature
(#1773)class-naming
, function-naming
, package-name
, property-naming
(#1757)file-name
rule on code snippets (#1768).editorconfig
property ij_kotlin_imports_layout
's entries (#1770)no-semi
(#1733)standard:filename
rule whenever Ktlint CLI is run with option --stdin
(#1742)--log-level
is specified. Throw exception when an invalid value is passed. (#1749)experimental
rule set are disabled by default. (#1747)1.8.0
and Kotlin version to 1.8.0
.The indent
rule has been rewritten from scratch. Solving problems in the old algorithm was very difficult. With the new algorithm this becomes a lot easier. Although the new implementation of the rule has been compared against several open source projects containing over 400,000 lines of code, it is still likely that new issues will be discovered. Please report your indentation issues so that these can be fixed as well.
.editorconfig
property to disable rulesIn the previous release (0.47.x), the .editorconfig
property disabled_rules
was deprecated and replaced with ktlint_disabled_rules
. This latter property has now been deprecated as well in favour of a more flexible and better maintainable solution. Rule and rule sets can now be enabled/disabled with a separate property per rule (set). Please read deprecation of (ktlint_)disable_rules property for more information.
The KtLint CLI has not been changed. Although you can still use parameter --experimental
to enable KtLint's Experimental rule set, you might want to set .editorconfig
property ktlint_experimental = enabled
instead.
If you are not an API consumer or Rule Set provider then you can skip this section.
Classes below have been relocated:
com.pinterest.ktlint.core.api.UsesEditorConfigProperties.EditorConfigProperty
has been replaced with com.pinterest.ktlint.core.api.editorconfig.EditorConfigProperty
.com.pinterest.ktlint.core.KtLintParseException
has been replaced with com.pinterest.ktlint.core.api.KtLintParseException
.com.pinterest.ktlint.core.RuleExecutionException
has been replaced with com.pinterest.ktlint.core.api.KtLintRuleException
.com.pinterest.ktlint.reporter.format.internal.Color
has been moved to com.pinterest.ktlint.reporter.format.Color
.com.pinterest.ktlint.reporter.plain.internal.Color
has been moved to com.pinterest.ktlint.reporter.plain.Color
.lint
and format
This is the last release that supports the ExperimentalParams
to invoke the lint
and format
functions of KtLint. The ExperimentalParams
contains a mix of configuration settings which are not dependent on the file/code which is to be processed. Other parameters in that class describe the code/file to be processed but can be configured inconsistently (for example a file with name “foo.kt” could be marked as a Kotlin Script file).
The static object KtLint
is deprecated and replaced by class KtLintRuleEngine
which is configured with KtLintRuleEngineConfiguration
. The instance of the KtLintRuleEngine
is intended to be reused for scanning all files in a project and should not be recreated per file.
Both lint
and format
are simplified and can now be called for a code block or for an entire file.
import java.io.File // Define a reusable instance of the KtLint Rule Engine val ktLintRuleEngine = KtLintRuleEngine( // Define configuration ) // Process a collection of files val files: Set<File> // Collect files in a convenient way files.forEach(file in files) { ktLintRuleEngine.lint(file) { // Handle lint violations } } // or process a code sample for a given filepath ktLintRuleEngine.lint( code = "code to be linted", filePath = Path("/path/to/source/file") ) { // Handle lint violations }
.editorconfig
sThe list of .editorconfig
files which will be accessed by KtLint when linting or formatting a given path can now be retrieved with the new API KtLint.editorConfigFilePaths(path: Path): List<Path>
.
This API can be called with either a file or a directory. It's intended usage is that it is called once with the root directory of a project before actually linting or formatting files of that project. When called with a directory path, all .editorconfig
files in the directory or any of its subdirectories (except hidden directories) are returned. In case the given directory does not contain an .editorconfig
file or if it does not contain the root=true
setting, the parent directories are scanned as well until a root .editorconfig
file is found.
Calling this API with a file path results in the .editorconfig
files that will be accessed when processing that specific file. In case the directory in which the file resides does not contain an .editorconfig
file or if it does not contain the root=true
setting, the parent directories are scanned until a root .editorconfig
file is found.
Constant KtLint.FILE_PATH_USER_DATA_KEY
is deprecated and will be removed in KtLint version 0.49.0. The file name will be passed correctly to the node with element type FILE and can be retrieved as follows:
if (node.isRoot()) { val fileName = (node.psi as? KtFile)?.name ... }
wrapping
(#1643)stdin
with the --patterns-from-stdin
command line options/flags (#1606)indent
rule and new experimental rule context-receiver-wrapping
(#1672)class-naming
), functions (function-naming
) and properties (property-naming
) (#44)plain-summary
which prints a summary the number of violation which have been autocorrected or could not be autocorrected, both split by rule..editorconfig
when running CLI with options --stdin
and --editorconfig
(#1651)trailing-comma-on-call-site
(#1642)ktlint_disabled_rules
to exposed editorConfigProperties
(#1671)trailing-comma-on-declaration-site
and trailing-comma-on-call-site
(#1676)function-signature
(#1690)1.8.0-RC
and Kotlin version to 1.7.21
.true
unless the android codestyle
is enabled. Note that KtLint from a consistency viewpoint enforces the trailing comma on call site while default IntelliJ IDEA formatting only allows the trailing comma but leaves it up to the developer's discretion. (#1670)true
unless the android codestyle
is enabled. Note that KtLint from a consistency viewpoint enforces the trailing comma on declaration site while default IntelliJ IDEA formatting only allows the trailing comma but leaves it up to the developer's discretion. (#1669)--debug
, --trace
, --verbose
and -v
are replaced with --log-level=<level>
or the short version `-l=, see CLI log-level. (#1632)--log-level=none
or -l=none
(#1652)indent
rule. Solving problems in the old algorithm was very difficult. With the new algorithm this becomes a lot easier. Although the new implementation of the rule has been compared against several open source projects containing over 400,000 lines of code, it is still likely that new issues will be discovered. Please report your indentation issues so that these can be fixed as well. (#1682, #1321, #1200, #1562, #1563, #1639)indent
rule. Solving problems in the old algorithm was very difficult. With the new algorithm this becomes a lot easier. Although the new implementation of the rule has been compared against several open source projects containing over 400,000 lines of code, it is still likely that new issues will be discovered. Please report your indentation issues so that these can be fixed as well. (#1682, #1321, #1200, #1562, #1563, #1639, #1688)java 19
, remove support for running tests on java 18
.io.github.detekt.sarif4k:sarif4k
version to 0.2.0
(#1701).trailing-comma-on-call-site
, trailing-comma-on-declaration-site
) (#1602)--disabled-rules
(#1599)@file:Suppress
on all toplevel declarations (#1623)If you are not an API consumer nor a RuleSet provider, then you can safely skip this section. Otherwise, please read below carefully and upgrade your usage of ktlint. In this and coming releases, we are changing and adapting important parts of our API in order to increase maintainability and flexibility for future changes. Please avoid skipping a releases as that will make it harder to migrate.
Up until ktlint 0.46 the Rule class provided only one life cycle hook. This “visit” hook was called in a depth-first-approach on all nodes in the file. A rule like the IndentationRule used the RunOnRootOnly visitor modifier to call this lifecycle hook for the root node only in combination with an alternative way of traversing the ASTNodes. Downside of this approach was that suppression of the rule on blocks inside a file was not possible (#631). More generically, this applied to all rules, applying alternative traversals of the AST.
The Rule class now offers new life cycle hooks:
Optionally, a rule can stop the traversal of the remainder of the AST whenever the goal of the rule has been achieved. See KDoc on Rule class for more information.
The “visit” life cycle hook will be removed in Ktlint 0.48. In KtLint 0.47 the “visit” life cycle hook will be called only when hook “beforeVisitChildNodes” is not overridden. It is recommended to migrate to the new lifecycle hooks in KtLint 0.47. Please create an issue, in case you need additional assistance to implement the new life cycle hooks in your rules.
The KtLint engine needs a more fine-grained control on the instantiation of new Rule instances. Currently, a new instance of a rule can be created only once per file. However, when formatting files the same rule instance is reused for a second processing iteration in case a Lint violation has been autocorrected. By re-using the same rule instance, state of that rule might leak from the first to the second processing iteration.
Providers of custom rule sets have to migrate the custom rule set JAR file. The current RuleSetProvider interface which is implemented in the custom rule set is deprecated and marked for removal in KtLint 0.48. Custom rule sets using the old RuleSetProvider interface will not be run in KtLint 0.48 or above.
For now, it is advised to implement the new RuleSetProviderV2 interface without removing the old RuleSetProvider interface. In this way, KtLint 0.47 and above use the RuleSetProviderV2 interface and ignore the old RuleSetProvider interface completely. KtLint 0.46 and below only use the old RuleSetProvider interface.
Adding the new interface is straight forward, as can be seen below:
// Current implementation public class CustomRuleSetProvider : RuleSetProvider { override fun get(): RuleSet = RuleSet( "custom", CustomRule1(), CustomRule2(), ) } // New implementation public class CustomRuleSetProvider : RuleSetProviderV2(CUSTOM_RULE_SET_ID), RuleSetProvider { override fun get(): RuleSet = RuleSet( CUSTOM_RULE_SET_ID, CustomRule1(), CustomRule2() ) override fun getRuleProviders(): Set<RuleProvider> = setOf( RuleProvider { CustomRule1() }, RuleProvider { CustomRule2() } ) private companion object { const val CUSTOM_RULE_SET_ID = custom" } }
Also note that file ‘resource/META-INF/services/com.pinterest.ktlint.core.RuleSetProviderV2’ needs to be added. In case your custom rule set provider implements both RuleSetProvider and RuleSetProviderV2, the resource directory contains files for both implementation. The content of those files is identical as the interfaces are implemented on the same class.
Once above has been implemented, rules no longer have to clean up their internal state as the KtLint rule engine can request a new instance of the Rule at any time it suspects that the internal state of the Rule is tampered with (e.g. as soon as the Rule instance is used for traversing the AST).
The KtLint engine needs a more fine-grained control on the instantiation of new Rule instances. Currently, a new instance of a rule can be created only once per file. However, when formatting files the same rule instance is reused for a second processing iteration in case a Lint violation has been autocorrected. By re-using the same rule instance, state of that rule might leak from the first to the second processing iteration.
The ExperimentalParams parameter which is used to invoke “KtLint.lint” and “KtLint.format” contains a new parameter “ruleProviders” which will replace the “ruleSets” parameter in KtLint 0.48. Exactly one of those parameters should be a non-empty set. It is preferred that API consumers migrate to using “ruleProviders”.
// Old style using "ruleSets" KtLint.format( KtLint.ExperimentalParams( ... ruleSets = listOf( RuleSet( "custom", CustomRule1(), CustomRule2() ) ), ... ) ) // New style using "ruleProviders" KtLint.format( KtLint.ExperimentalParams( ... ruleProviders = setOf( RuleProvider { CustomRule1() }, RuleProvider { CustomRule2() } ), cb = { _, _ -> } ) )
Once above has been implemented, rules no longer have to clean up their internal state as the KtLint rule engine can request a new instance of the Rule at any time it suspects that the internal state of the Rule is tampered with (e.g. as soon as the Rule instance is used for traversing the AST).
The callback function provided as parameter to the format function is now called for all errors regardless whether the error has been autocorrected. Existing consumers of the format function should now explicitly check the autocorrected
flag in the callback result and handle it appropriately (in most case this will be ignoring the callback results for which autocorrected
has value true
).
Class com.pinterest.ktlint.core.internal.CurrentBaseline
has been replaced with com.pinterest.ktlint.core.api.Baseline
.
Noteworthy changes:
baselineRules
(nullable) is replaced with `lintErrorsPerFile (non-nullable).baselineGenerationNeeded
(boolean) is replaced with status
(type Baseline.Status
).The utility functions provided via com.pinterest.ktlint.core.internal.CurrentBaseline
are moved to the new class. One new method List<LintError>.doesNotContain(lintError: LintError)
is added.
The .editorconfig
property disabled_rules
(api property DefaultEditorConfigProperties.disabledRulesProperty
) has been deprecated and will be removed in a future version. Use ktlint_disabled_rules
(api property DefaultEditorConfigProperties.ktlintDisabledRulesProperty
) instead as it more clearly identifies that ktlint is the owner of the property. This property is to be renamed in .editorconfig
files and ExperimentalParams.editorConfigOverride
.
Although, Ktlint 0.47.0 falls back on property disabled_rules
whenever ktlint_disabled_rules
is not found, this result in a warning message being printed.
Parameter “ExperimentalParams.editorConfigPath” is deprecated in favor of the new parameter “ExperimentalParams.editorConfigDefaults”. When used in the old implementation this resulted in ignoring all “.editorconfig” files on the path to the file. The new implementation uses properties from the “editorConfigDefaults”parameter only when no “.editorconfig” files on the path to the file supplies this property for the filepath.
API consumers can easily create the EditConfigDefaults by calling “EditConfigDefaults.load(path)” or creating it programmatically.
.editorconfig
fileSome API Consumers keep a long-running instance of the KtLint engine alive. In case an .editorconfig
file is changed, which was already loaded into the internal cache of the KtLint engine this change would not be taken into account by KtLint. One way to deal with this, was to clear the entire KtLint cache after each change in an .editorconfig
file.
Now, the API consumer can reload an .editorconfig
. If the .editorconfig
with given path is actually found in the cached, it will be replaced with the new value directly. If the file is not yet loaded in the cache, loading will be deferred until the file is actually requested again.
Example:
KtLint.reloadEditorConfigFile("/some/path/to/.editorconfig")
Several methods for which it is unlikely that they are used by API consumers have been marked for removal from the public API in KtLint 0.48.0. Please create an issue in case you have a valid business case to keep such methods in the public API.
format
reporter. This reporter prints a one-line-summary of the formatting status per file. (#621).filename
(#1521).indent
) #631enum-entry-name-case
, filename
) (#1530).ktlint
cli on default kotlin extensions only when an (existing) path to a directory is given. (#917).format
function for all errors including errors that are autocorrected (#1491)function-signature
(#1527)multiline-if-else
(#1560)multiline-if-else
(#828)ktlint_code_style
(#1559)trailing-comma
(#1542)trailing-comma
into trailing-comma-on-call-site
and trailing-comma-on-declaration-site
(#1555)wrapping
(#1578)format
function for all errors including errors that are autocorrected (#1491)annotation
(#1574).editorconfig
property disabled_rules
to ktlint_disabled_rules
(#701)1.7.20-beta
and Kotlin version to 1.7.10
.7.5.1
versionMinor release to address some regressions introduced in 0.46.0
-Xuse-k2
as it forces API Consumers to compile their projects with this same flag (#1506).indent
(#1510)The rules below are promoted from the experimental
ruleset to the standard
ruleset.
annotation
annotation-spacing
argument-list-wrapping
double-colon-spacing
enum-entry-name-case
multiline-if-else
no-empty-first-line-in-method-block
package-name
trailing-comma
spacing-around-angle-brackets
spacing-between-declarations-with-annotations
spacing-between-declarations-with-comments
unary-op-spacing
Note that as a result of moving the rules that the prefix experimental:
has to be removed from all references to this rule. Check references in:
.editorconfig
setting disabled_rules
.VisitorModifier.RunAfterRule
.If your project did not run with the experimental
ruleset enabled before, you might expect new lint violations to be reported. Please note that rules can be disabled via the the .editorconfig
in case you do not want the rules to be applied on your project.
If you are not an API user nor a RuleSet provider, then you can safely skip this section. Otherwise, please read below carefully and upgrade your usage of ktlint. In this and coming releases, we are changing and adapting important parts of our API in order to increase maintainability and flexibility for future changes. Please avoid skipping a releases as that will make it harder to migrate.
The lint and formatting changes no longer accept parameters of type Params
but only ExperimentalParams
. Also, the VisitorProvider parameter has been removed. Because of this, your integration with KtLint breaks. Based on feedback with ktlint 0.45.x, we now prefer to break at compile time instead of trying to keep the interface backwards compatible. Please raise an issue, in case you help to convert to the new API.
The interface UsesEditorConfigProperties
provides method getEditorConfigValue
to retrieve a named .editorconfig
property for a given ASTNode. When implementing this interface, the value editorConfigProperties
needs to be overridden. Previously it was not checked whether a retrieved property was actually recorded in this list. Now, retrieval of unregistered properties results in an exception.
Property Ktlint.DISABLED
has been removed. The property value can now be retrieved as follows:
astNode .getEditorConfigValue(DefaultEditorConfigProperties.disabledRulesProperty) .split(",")
and be supplied via the ExperimentalParams
as follows:
ExperimentalParams( ... editorConfigOverride = EditorConfigOverride.from( DefaultEditorConfigProperties.disabledRulesProperty to "some-rule-id,experimental:some-other-rule-id" ) ... )
Property Ktlint.ANDROID_USER_DATA_KEY
has been removed. The property value can now be retrieved as follows:
astNode .getEditorConfigValue(DefaultEditorConfigProperties.codeStyleProperty)
and be supplied via the ExperimentalParams
as follows:
ExperimentalParams( ... editorConfigOverride = EditorConfigOverride.from( DefaultEditorConfigProperties.codeStyleProperty to "android" ) ... )
This property defaults to the official
Kotlin code style when not set.
An AssertJ style API for testing KtLint rules (#1444) has been added. Usage of this API is encouraged in favor of using the old RuleExtension API. For more information, see KtLintAssertThat API
spacing-between-function-name-and-opening-parenthesis
) (#1341)parameter-list-spacing
) (#1341)function-return-type-spacing
) (#1341)nullable-type-spacing
) (#1341)type-parameter-list-spacing
) (#1435)function-start-of-body-spacing
) (#1341)@Suppress
(more information) (#765)function-signature
) (#1341)no-consecutive-blank-lines
to new rule (no-blank-lines-in-chained-method-calls
) (#1248)wrapping
(#1457)indent
(#1340)indent
) and a newline in the expression in a for-statement should not force to wrap it wrapping
(#1350)indent
(#1335).editorconfig
setting indentSize
is set to value tab
then return the default tab width as value for indentSize
(#1485)@file:Suppress(...)
(#1029)1.7.0
and Kotlin version to 1.7.0
.7.1.2
release4.6.3
releasefilename
(#1004)annotation
, annotation-spacing
, argument-list-wrapping
, double-colon-spacing
, enum-entry-name-case
, multiline-if-else
, no-empty-first-line-in-method-block
, package-name
, traling-comma
, spacing-around-angle-brackets
, spacing-between-declarations-with-annotations
, spacing-between-declarations-with-comments
, unary-op-spacing
(#1481)--android
can be omitted when the .editorconfig
property ktlint_code_style = android
is defined1.6.20
and Kotlin version to 1.6.20
.Minor release to fix a breaking issue with ktlint
API consumers
If you are not an API user nor a RuleSet provider, then you can safely skip this section. Otherwise, please read below carefully and upgrade your usage of ktlint. In this and coming releases, we are changing and adapting important parts of our API in order to increase maintainability and flexibility for future changes. Please avoid skipping a releases as that will make it harder to migrate.
This section is applicable when providing rules that depend on one or more values of “.editorconfig” properties. Property values should no longer be retrieved via EditConfig or directly via userData[EDITOR_CONFIG_USER_DATA_KEY]
. Property values should now only be retrieved using method ASTNode.getEditorConfigValue(editorConfigProperty)
of interface UsesEditorConfigProperties
which is provided in this release. Starting from next release after the current release, the EditConfig and/or userData[EDITOR_CONFIG_USER_DATA_KEY]
may be removed without further notice which will break your API or rule. To prevent disruption of your end user, you should migrate a.s.a.p.
function-type-reference-spacing
) (#1341)type-parameter-list-spacing
) (#1366)discouraged-comment-location
) (#1365)fun-keyword-spacing
) (#1362)experimental:block-comment-initial-star-alignment
(#297).editorconfig
property ij_kotlin_packages_to_use_import_on_demand
(no-wildcard-imports
) (#1272)comment-wrapping
) (#1403)kdoc-wrapping
) (#1403)type-parameter-list-spacing
) (#1366)no-multi-spaces
) (#1394)indent
) (#1375)no-unused-imports
) (#1277), (#1393), (#1256)indent
rule to the new rule wrapping
(as part of the standard
ruleset). In case you currently have disabled the indent
rule, you may want to reconsider whether this is still necessary or that you also want to disable the new wrapping
rule to keep the status quo. Both rules can be run independent of each other. (#835)Please welcome paul-dingemans as an official maintainer of ktlint!
trailing-comma
) (#1280)no-trailing-spaces
) (#1270)no-unused-imports
) (#1282)indent
) (#1222)trailing-comma
) (#1312)indent
) (#1210)indent
) (#1262)no-trailing-spaces
) (#1334)parameter-list-wrapping
) (#1255)indent
) (#1330)parameter-list-wrapping
, argument-list-wrapping
) (#897, #1045, #1119, #1255, #1267, #1319, #1320, #1337parameter-list-wrapping
) (#1255)1.6.0
release1.6.0
release7.1.1
release7.4
versiontrailing-comma
rule (#709) (prior art by paul-dingemans)indent
) (#1202)no-trailing-spaces
) (#1197).idea
folder presence when using applyToIDEA
globally (#1186)paren-spacing
) (#1207)indent
) (#1210)no-unused-imports
) (#1256)indent
) (#850)argument-list-wrapping
)(#1159)7.2
version7.1
version1.5.31
version. Default Kotlin API version was changed to 1.4
!Dot release to fix regressions in indent
rule introduced in 0.42.0 release. Thanks to t-kameyama for the fixes!
indent
) (#1189)indent
) (#1188)Thank you to the following contributors for this release:
annotation-spacing
) (#1124)indent
) (#1162)indent
) (#764)argument-list-wrapping
) (#1112)indent
) (#1165)import-ordering
) (#1106)chain-wrapping
) (#1055)chain-wrapping
) (#1130)Note: This release contains breaking changes to globs passed to ktlint via the command line. See (#999) and the README.
Thank you to t-kameyama and paul-dingemans for your contributions to this release!
ktlint_ignore_back_ticked_identifier
EditorConfig option for max-line-length
rule to ignore long method names inside backticks (primarily used in tests) (#1007).editorconfig
values via ExperimentalParams#editorConfigOverride
(#1016)ReporterProvider
, LintError
, RuleSetProvider
now implement Serializable
interfaceimport-ordering
(#1011)no-unused-imports
) (#996)argument-list-wrapping
) (#893)indent
) (#918)no-line-break-before-assignment
) (#1039)no-unused-imports
(#1040)spacing-between-declarations-with-comments
) (#1053)else
keyword (argument-list-wrapping
) (#1047)colon-spacing
) (#1057)argument-list-wrapping-rule
formatting file with many corrections (#1081)multiline-if-else
) (#1079)6.1.0
versionkotlin_imports_layout
EditorConfig property. Please use ij_kotlin_imports_layout
to ensure that the Kotlin IDE plugin and ktlint use same imports layout (#753)idea
and ascii
shortcuts as the ij_kotlin_imports_layout
property does not support those. Please check README on how to achieve those with patterns (#753)6.8.3
version1.4.31
version. Fixes #1063.Special thanks to t-kameyama for the huge number of bugfixes in this release!
generateEditorConfig
to generate ‘.editorconfig’ content for Kotlin files (#701)--baseline
cli option (#707)@receiver
annotations with parameters are not required to be on a separate line (#885)Missing newline after "->"
when when
entry has a nested if/else block (#901)argument-list-wrapping
(#926)argument-list-wrapping
(#861) (#870)argument-list-wrapping
(#854) (#864)argument-list-wrapping
(#842) (#859)spacing-between-declarations-with-comments
(#865)multiline-if-else
) (#944)indent
) (#871) (#900)parameter-list-wrapping
) (#921) (#938)indent
) (#939)no-semicolons
) (#957)indent
) (#960) (#963) (#877)indent
) (#964)parameter-list-wrapping
) (#965)spacing-between-declarations-with-annotations
(#970)no-line-break-before-assignment
) (#956)spacing-around-keyword
) (#978)no-semicolons
) (#955)indent
) (#959)spacing-around-comma
) (#975)6.7.1
versionargument-list-wrapping
rule into experimental rulesetannotation-spacing
into separate experimental ruleparameter-list-wrapping
(#680).editorconfig
path is ignored on stdin input (#869)no-unused-imports
(#845)no-unused-imports
(#872)Ktlint
object internal code cleanupKtlint
object that should not be exposed as public apiRuleSet
class open so it can be inheritedMinor release to support projects using mixed 1.3/1.4 Kotlin versions (e.g. Gradle plugins)
apiLevel = 1.3
New release with Kotlin 1.4.0 support and several enhancements and bugfixes.
parameter-list-wrapping
rule now also considers function arguments while wrapping (#620)provideDelegate
imports are not marked as unused anymore (#669).editorconfig
file on failed parsing and allow empty .editorconfig
files.Minor release to fix further bugs in ImportOrderingRule
.
Minor release to fix some bugs in the 0.37.0 release.
as
no longer removed (#766)Thank you to Tapchicoma and romtsn for all their hard work on this release!
SpacingAroundDoubleColon
rule (#722]SpacingBetweenDeclarationsWithCommentsRule
and SpacingBetweenDeclarationsWithAnnotationsRule
. Fixes ([#721]https://github.com/pinterest/ktlint/issues/721)kotlin_imports_layout
config for .editorconfig
file so that import ordering is configurable. Fixes (#527).editorconfig
was fully delegated to ec4j library. This fixes ability to override properties for specific files/directories (#742)AnnotationRule
now handles file annotations as well (#714)FinalNewlineRule
no longer reports error for empty files (#723)AnnotationRule
to report an error (#736)NoLineBreakBeforeAssignmentRule
(#693)IndentRule
@Suppress("RemoveCurlyBracesFromTemplate")
now respected (#263).git
directory now discovered instead of hardcoded (#623)(
followed by a comment (#664)--color-name
command line flag. (#585)--apply-to-idea
flag; use applyToIDEA
subcommand instead (#554)--apply-to-idea-project
flag; use applyToIDEAProject
subcommand instead (#593)0.0.0-SNAPSHOT
builds; snapshot builds are now versioned, e.g. 0.35.0-SNAPSHOT (#588)kotlin-compiler-embeddable
to your ruleset project.AnnotationRule
(#552) (#601IndentationRule
(#597) (#599)}
and ]
(#596)--version
output with gradle-built JAR (#613)Minor bugfix release for 0.34.0. (Note: 0.34.1 deprecated/deleted due to regression in disabled_flags .editorconfig support.)
--disabled_rules
command line flag. (#534)--stdin
flag for printAST
command (#528)NoUnusedImports
rule (#531, #526)disabled_rules
property in .editorconfig
(#503)experimental:no-empty-first-line-in-method-block
(#474)no-wildcard-import
(Re-enabled after temporarily disabling in 0.33.0)experimental:annotation
(#509)experimental:multiline-if-else
(no autocorrection)experimental:package-name
(currently only disallows underscores in package names)MavenDependencyResolver
. Scheduled to be removed in 0.35.0 (#468)--install-git-pre-commit-hook
flag; use installGitPreCommitHook
subcommand instead (#487)--print-ast
flag; use printAST
subcommand instead (#500)--ruleset-repository
and --ruleset-update
flagsimport-ordering
will now refuse to format import lists that contain top-level comments (#408)no-unused-imports
reporting false negatives or false positives in some cases (#405) and (#506)experimental:indent
incorrectly formatting a lambda's closing brace (#479)->
in some cases (#403)SpacingAroundCommaRule
will no longer move code into comments=
less aggressive (#368) (#380)experimental/import-ordering
rule (#189). Use ktlint --experimental
to enabled.ktlint
now part of Homebrew core (shyiko/ktlint
tap deprecated)super
(#369).com.pinterest
packagecom.pinterest
META-INF.services
file must be renamed to com.pinterest.ktlint.core.RuleSetProvider
<
& >
operators.no-multi-spaces
rule (horizontal alignment of comments is no longer allowed) (#269).colon-spacing
rule (:
must not appear at the beginning of the line).package-name
rule (disabled until #208 is resolved).--print-ast
to output com.pinterest.ktlint.core.ast.ElementType.* as node.elementType
, e.g.$ echo 'fun f() {}' | ./ktlint/target/ktlint --print-ast --color --stdin 1: ~.psi.KtFile (FILE) 1: ~.psi.KtPackageDirective (PACKAGE_DIRECTIVE) "" 1: ~.psi.KtImportList (IMPORT_LIST) "" 1: ~.psi.KtScript (SCRIPT) 1: ~.psi.KtBlockExpression (BLOCK) 1: ~.psi.KtNamedFunction (FUN) 1: ~.c.i.p.impl.source.tree.LeafPsiElement (FUN_KEYWORD) "fun" 1: ~.c.i.p.impl.source.tree.PsiWhiteSpaceImpl (WHITE_SPACE) " " 1: ~.c.i.p.impl.source.tree.LeafPsiElement (IDENTIFIER) "f" 1: ~.psi.KtParameterList (VALUE_PARAMETER_LIST) 1: ~.c.i.p.impl.source.tree.LeafPsiElement (LPAR) "(" 1: ~.c.i.p.impl.source.tree.LeafPsiElement (RPAR) ")" 1: ~.c.i.p.impl.source.tree.PsiWhiteSpaceImpl (WHITE_SPACE) " " 1: ~.psi.KtBlockExpression (BLOCK) 1: ~.c.i.p.impl.source.tree.LeafPsiElement (LBRACE) "{" 1: ~.c.i.p.impl.source.tree.LeafPsiElement (RBRACE) "}" 1: ~.c.i.p.impl.source.tree.PsiWhiteSpaceImpl (WHITE_SPACE) "\n" format: <line_number:> <node.psi::class> (<node.elementType>) "<node.text>" legend: ~ = org.jetbrains.kotlin, c.i.p = com.intellij.psi
kotlin-compiler
version to 1.3.21 (from 1.3.20).Missing newline before ")"
(#327).kotlin-compiler
version to 1.3.20 (from 1.2.71) (#331).--ruleset
/--reporter
switched to HTTPS (#332).no-semi
rule to preserve semicolon after companion object;
(see #281 for details).end_of_line=CRLF
is used (#286).package-name
rule not to check file location (until #280 can be properly addressed).comment-spacing
rule not to flag //region
& //endregion
comments (#278).kotlin-compiler
version to 1.2.71 (from 1.2.51).package-name
rule (directories containing .
in their names are no longer considered to be invalid) (#276).max-line-length
rule (multi-line strings are no longer checked) (#262).json
reporter \ and control characters escaping (#256).package-name
rule (#246).--editorconfig=path/to/.editorconfig
(#250).end_of_line=native
(.editorconfig
) (#225).tab -> space * indent_size
auto-correction (--format
/-F
).(cannot be auto-corrected)
reporting.--debug
mode while trying to print root=true <- root=false
.editorconfig
chain.kotlin-compiler
version to 1.2.51 (from 1.2.50).paren-spacing
rule (#223).ktlint --install-git-pre-commit-hook
)ktlint --install-git-pre-push-hook
to install) (#229).end_of_line=crlf
(.editorconfig
) (#225)..editorconfig
path resolution.editorconfig
to be loaded) (#207).comment-spacing
rule to exclude //noinspection
(#212).kotlin-compiler
version to 1.2.50 (from 1.2.41) (#226).ClassCastException: cannot be cast to LeafPsiElement
(#205).comment-spacing
(#198),filename
(#194) rules.parameter-list-wrapping
left parenthesis placement check (#201).parameter-list-wrapping
auto-correction when max_line_length
is exceeded (#200).kotlin-compiler
version to 1.2.41 (from 1.2.40).--apply-to-idea-project
(as an alternative to (global) --apply-to-idea
) (#178).--format
commenting out operators (chain-wrapping
rule) (#193).indent
rule (continuation_indent_size
is now ignored) (#171).continuation_indent_size
(and gcd(indent_size, continuation_indent_size) == 1
) ktlint won't check the indentation.--apply-to-idea
to inherit “Predefined style / Kotlin style guide” (Kotlin plugin 1.2.20+).kotlin-compiler
version to 1.2.40 (from 1.2.30).indent
rule to ignore where <type constraint list>
clause (#180).--reporter=<name>,artifact=<group_id>:<artifact_id>:<version>
) (#176).--ruleset
/--reporter
dependency tree validation.--reporter=...,output=<path_to_a_file>
(#177).+
, -
, *
, /
, %
, &&
, ||
wrapping (#168).comma-spacing
rule to be more strict (#173).no-line-break-after-else
rule to allow multi-line if/else
without curly braces.kotlin-compiler
version to 1.2.30 (from 1.2.20).Internal Error (parameter-list-wrapping)
when indent_size=unset
(#165).+
/-
wrapping inside catch
block, after else
and if (..)
(#160).indent
rule.ktlint --format/-F
when some of the errors cannot be auto-corrected (previously it was 0 instead of expected 1) (#162).when
block (#160).parameter-list-wrapping
rule (#130).+
, -
, *
, /
, %
, &&
, ||
wrapping check (now part of chain-wrapping
rule).componentN
import (where N > 5) false positive (#142).modifier-order
rule to match official Kotlin Coding Conventions (#146)override
modifier should be placed before suspend
/tailrec
, not after)no-line-break-after-else
rule (#125).kotlin-compiler
version to 1.2.20 (from 1.2.0).continuation_indent_size
to 4 when --android
profile is used (android/kotlin-guides#37).no-line-break-before-assignment
(#105),chain-wrapping
(#23) (when wrapping chained calls .
, ?.
and ?:
should be placed on the next line),range-spacing
(no spaces around range (..
) operator) rules.--print-ast
CLI option which can be used to dump AST of the file--color
CLI option for colored output (where supported, e.g. --print-ast, default (plain) reporter, etc).editorconfig
property resolution.[*.{kt,kts}]
is not required anymore (ktlint looks for sections containing *.kt
(or *.kts
) and will fallback to [*]
whenever property cannot be found elsewhere)..editorconfig
(unless it contains root=true
).max-line-length
rule to assume max_line_length=100
when ktlint --android ...
is usedkotlin-compiler
version to 1.2.0 (from 1.1.51).no-empty-class-body
auto-correction at the end of file (#109).max-line-length
rule when applied to KDoc (#112)max-line-length
even though regular comments were not).=
in @annotation|s (op-spacing
).fun <T>f(): T {}
-> fun <T> f(): T {}
).no-consecutive-blank-lines
not triggering at the end of file (when exactly 2 blank lines are present) (#108)indent
continuation_indent_size % indent_size != 0
case (#76)indent
rule skipping first parameter indentation check.final-newline
rule in the context of kotlin script.org.eclipse.aether:aether-*:1.1.0
and org.eclipse.aether:aether-*:1.0.0.v20140518
(#100).--android
(-a
) CLI option (turns on Android Kotlin Style Guide compatibility)ktlint --apply-to-idea
).ktlint --apply-to-idea
to account for indent_size
& continuation_indent_size
in .editorconfig
(if any).ktlint-intellij-idea-integration
binary (deprecated in 0.9.0).component1
..component5
).--reporter
's output
handling (previously parent directory was expected to exist) (#97).no-blank-line-before-rbrace
rule (#65).}
and ::
(curly-spacing).This release contains changes that were meant for 0.11.0 and so it was retagged as such.
}
and [key]
/(...)
(curly-spacing) (#91).ktlint --install-git-pre-commit-hook
to install).--reporter=<name>,output=<path/to/file>
) (#71).indent_size=unset
(.editorconfig
) (#70).( {
formatting( {
and ({
were accepted as correct, while only ({
should be) (curly-spacing
rule) (#80).if\nfn {}\nelse
formatting (curly-spacing
rule).max_line_length=off
& max_line_length=unset
handling (.editorconfig
).kotlin-compiler
version to 1.1.51 (from 1.1.3-2).ktlint --apply-to-idea
to include OPTIMIZE_IMPORTS_ON_THE_FLY=true
.: Unit =
formatting (: Unit
is no longer dropped when =
is used) (#77).${super.toString()}
linting (string-template
rule) (#69).ktlint
comes with 3 built-in reporters: plain
(default; ?group_by_file
can be appended to enable grouping by file (shown below)), json
and checkstyle
.$ ktlint --reporter=plain?group_by_file path/to/file.kt 1:10 Unused import. 2:10 Unnecessary "Unit" return type. path/to/another-file.kt 1:10 Unnecessary semicolon.
insert_final_newline
is set in .editorconfig
(under [*.{kt,kts}]
)) rules.--limit
CLI option (e.g. use --limit=10
to limit the number of errors to display).--relative
CLI flag which makes ktlint
output file paths relative to working directory (e.g. dir/file.kt
instead of /home/269/project/dir/file.kt
).kotlin-compiler
to 1.1.3-2 (from 1.1.0)).--ruleset-repository
and --ruleset-update
CLI arguments in favour of --repository
and --repository-update
respectively (--ruleset-*
will be removed in 1.0.0).ktlint-intellij-idea-integration
binaryktlint
(as ktlint --apply-to-idea
)).setValue
) (#55).get
/set
ter spacing (#56).getValue
) (#54).ktlint --stdin
(#51).indent_size
is honored and only if it's set in [*{kt,kts}]
section).else/catch/finally
on the same line as }
check (now part of “keyword-spacing” rule).ktlint-intellij-idea-integration
binary for easy Intellij IDEA config injection.kotlin-compiler
version to 1.1.0 (from 1.1-M04).super<T>
(#34).}
and !!
(curly-spacing).indent
rule to allow “Method declaration parameters -> Align when multiline” (as this option is (unfortunately) “on” by default in Intellij IDEA) (#26).kotlin-compiler
version to 1.1-M04 (from 1.0.6).*.kts
(script) support.kotlin-compiler
version to 1.0.6 (from 1.0.3).no-wildcard-imports
rule (kotlinx.android.synthetic excluded from check) (#16).curly-spacing
false negative in case of }?.
.ktlint -F
output (it now includes lint errors that cannot be fixed automatically).ktlint -F --debug
error count.