This repository was archived by the owner on Aug 12, 2025. It is now read-only.
fix(deps): update dependency com.pinterest:ktlint to v0.51.0-final #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.36.0->0.51.0-FINALWarning
Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
Release Notes
pinterest/ktlint (com.pinterest:ktlint)
v0.50.0Compare Source
Deprecation of ktlint-enable and ktlint-disable directives
The
ktlint-disableandktlint-enabledirectives are no longer supported. Ktlint rules can now only be suppressed using the@Suppressor@SuppressWarningsannotations. 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-suppressionrule can not be disabled via the.editorconfignor via@Suppressor@SuppressWarningsannotations.Custom Rule Providers need to prepare for Kotlin 1.9
In Kotlin 1.9 the extension points of the embedded kotlin compiler will change. Ktlint only uses the
org.jetbrains.kotlin.com.intellij.treeCopyHandlerextension 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 manipulatingASTNodes there seems to be no impact. When, manipulatingPsiElements, some functions consistently result in a runtime exception.Based on the refactoring of the rules as provided by
ktlint-ruleset-standardin Ktlint0.49.xthe suggested refactoring is as follows:LeafElement.replaceWithText(String)withLeafElement.rawReplaceWithText(String).PsiElement.addAfter(PsiElement, PsiElement)withAstNode.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 thePsiElement.addAfter(PsiElement, PsiElement).PsiElement.replace(PsiElement)with a sequence ofAstNode.addChild(AstNode, AstNode)andAstNode.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.treeCopyHandleris 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.treeCopyHandlerusing a flag. This flag is available in the Ktlint CLI and in theKtlintRuleEngine. 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 theKtlintRuleEnginedirectly, have to set propertyenableKotlinCompilerExtensionPointtofalse.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.treeCopyHandleris 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.Added
binary-expression-wrapping. This rule wraps a binary expression in case the max line length is exceeded (#1940)org.jetbrains.kotlin.com.intellij.treeCopyHandlerto analyse impact on custom rules #1981no-empty-filefor all code styles. A kotlin (script) file may not be empty (#1074)statement-wrappingwhich 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-suppressionto replace thektlint-disableandktlint-enabledirectives with annotations. This rule can not be disabled via the.editorconfig(#1947)--formatoption of KtLint CLI when finding a violation that can be autocorrected (#1071)Removed
0.49.xis removed. Consult changelog of 0.49.x` released for more information. Summary of removed code:Fixed
property-naming(#2024)serialVersionUIDinproperty-naming(#2045)parameter-list-wrapping(#1324)elsebranch when body contains only chained calls or binary expression (#2057)Changed
RuleIdandRuleSetIdclasses. Those classes were defined as value classes in0.49.0and0.49.1. Although the classes were marked with@JvmInlineit 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:picoclitov4.7.4org.junit.jupiter:junit-jupitertov5.9.31.8.22and Kotlin version to1.8.22.io.github.detekt.sarif4k:sarif4ktov0.4.0org.jetbrains.dokka:dokka-gradle-plugintov1.8.20v0.49.1Compare Source
Added
Removed
Fixed
--code-style=android_studioin Ktlint CLI identical to deprecated parameter--android(#1982)no-consecutive-blank-lines(#1987).editorconfigpropertyktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_thanwhen usingktlint_officialcode stylefunction-signature(#1977)indent(#1993)indent(#1976)ktlint_officialcode style to keep formatting of other code styles consistent with0.48.xand beforeindent(#1971)no-single-line-block-commentfromcomment-wrappingrule. Theno-single-line-block-commentrule is added as experimental rule to thektlint_officialcode style, but it can be enabled explicitly for the other code styles as well. (#1980)Changed
Baselinefromktlint-clitoktlint-cli-reporter-baselineso that Baseline functionality is reusable for API Consumers.v0.49.0Compare Source
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-rulesparameter in KtLint CLI..editorconfigproperties used to enable or disable rule and rule sets. Note that propertiesdisabled_rulesandktlint_disabled_ruleshave been removed in this release. See disabled rules for more information.sourceelement in the KtLint CLIbaseline.xmlfile. Regenerating this file, fixes all rule references automatically.ktlint-enable/ktlint-disableand the@Suppress('ktlint:...')annotations.VisitorModifier.RunAfterRule.Moving experimental rules to standard rule set
The
experimentalrule set has been merged withstandardrule set. The rules which formerly were part of theexperimentalrule set are still being treated as before. The rules will only be run in case.editorconfigpropertyktlint_experimentalis 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-rulesparameter in KtLint CLI..editorconfigproperties used to enable or disable rule and rule sets. Note that propertiesdisabled_rulesandktlint_disabled_ruleshave been removed in this release. See disabled rules for more information.ktlint-enable/ktlint-disableand the@Suppress('ktlint:...')annotations.VisitorModifier.RunAfterRule.Promote experimental rules to non-experimental
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.
API Changes & RuleSet providers & Reporter Providers
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.
Experimental rules
Rules in custom rule sets can now be marked as experimental by implementing the
Rule.Experimentalinterface on the rule. Rules marked with this interface will only be executed by Ktlint if.editorconfigpropertyktlint_experimentalis 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
.editorconfigfiles have to be changed.EditorConfig
Field
defaultAndroidValuein classEditorConfigPropertyhas been renamed toandroidStudioCodeStyleDefaultValue. New fieldsktlintOfficialCodeStyleDefaultValueandintellijIdeaCodeStyleDefaultValuehave been added. Read more about this in the section "Ktlint Official code style".The
.editorconfigpropertiesdisabled_rulesandktlint_disabled_rulesare no longer supported. Specifying those properties in theeditorConfigOverrideoreditorConfigDefaultsresult in warnings at runtime.'Ktlint Official` code style and renaming of existing code styles
A new code style
ktlint_officialis introduced. This code style is work in progress but will become the default code style in the1.0release. Please try out the new code style and provide your feedback via the issue tracker.This
ktlint_officialcode 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
officialcode style has been renamed tointellij_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.editorconfigpropertyktlint_code_stylehas been set toandroidthen do not forget to change the value of that property tointellij_idea. When not set, this is still the default code style of ktlint0.49. Note that the default code style will be changed toktlint_officialin the1.0release.Code style
androidhas been renamed toandroid_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.editorconfigpropertyktlint_code_stylehas been set toandroidthen do not forget to change the value of that property toandroid_studio.Package restructuring and class relocation
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-coreas 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 thektlint-coremodule are deprecated and were kept in this version for backwards compatibility only. Thektlint-coremodule will be removed in Ktlint0.50.x.Classes below have been moved from module
ktlint-coreto the new modulektlint-rule-engine-core:ktlint-corektlint-rule-engine-coreClasses below have been moved from module
ktlint-coreto the new modulektlint-rule-engine:ktlint-corektlint-rule-engineClass
com.pinterest.ktlint.core.KtLint.Code.CodeFilehas been replaced with factory methodcom.pinterest.ktlint.rule.engine.api.Code.fromFile. Likewise, classcom.pinterest.ktlint.core.KtLint.Code.CodeSnippethas been replaced with factory methodcom.pinterest.ktlint.rule.engine.api.Code.fromSnippet.Class below has been moved from module
ktlint-coreto the new modulektlint-cli-ruleset-core:ktlint-corektlint-cli-ruleset-coreClass below has been moved from module
ktlint-coreto the new modulektlint-cli-reporter-core:ktlint-corektlint-cli-reporter-coreClass below has been moved from module
ktlint-coreto the new modulektlint-logger:ktlint-corektlint-loggerClass below has been relocated from module
ktlint-coreto modulektlint-cli:ktlint-corektlint-cliModule
ktlint-reporter-baselinehas been renamed toktlint-cli-reporter-baseline. Class below has been relocated:ktlint-reporter-baselinektlint-cli-reporter-baselineModule
ktlint-reporter-checkstylehas been renamed toktlint-cli-reporter-checkstyle. Class below has been relocated:ktlint-reporter-checkstylektlint-cli-reporter-checkstyleModule
ktlint-reporter-formathas been renamed toktlint-cli-reporter-format. Class below has been relocated:ktlint-reporter-formatktlint-cli-reporter-formatModule
ktlint-reporter-htmlhas been renamed toktlint-cli-reporter-html. Class below has been relocated:ktlint-reporter-htmlktlint-cli-reporter-htmlModule
ktlint-reporter-jsonhas been renamed toktlint-cli-reporter-json. Class below has been relocated:ktlint-reporter-jsonktlint-cli-reporter-jsonModule
ktlint-reporter-plainhas been renamed toktlint-cli-reporter-plain. Class below has been relocated:ktlint-reporter-plainktlint-cli-reporter-plainModule
ktlint-reporter-plain-summaryhas been renamed toktlint-cli-reporter-plain-summary. Class below has been relocated:ktlint-reporter-plain-summaryktlint-cli-reporter-plain-summaryModule
ktlint-reporter-sarifhas been renamed toktlint-cli-reporter-sarif. Class below has been relocated:ktlint-reporter-sarifktlint-cli-reporter-sarifCustom Ruleset Provider
RuleSetProviderV2Custom rule sets build for older versions of KtLint are no longer supported by this version of KtLint. The
com.pinterest.ktlint.core.RuleSetProviderV2interface has been replaced withRuleSetProviderV3. The accompanying interfacescom.pinterest.ktlint.core.RuleProviderandcom.pinterest.ktlint.core.Rulehave been replaced withcom.pinterest.ktlint.ruleset.core.api.RuleProviderandcom.pinterest.ktlint.ruleset.core.api.Rulerespectively.Contrary to
RuleSetProviderV2, theRuleSetProviderV3no longer contains information about the rule set. About information now has to be specified in the newRuleclass. This allows custom rule set providers to combine rules originating from different rule sets into a new rule set without loosing information about its origin. The type of the id of the rule set is changed fromStringtoRuleSetId.Note that due to renaming and relocation of the
RuleSetProviderV3interface the name of the service provider in the custom reporter needs to be changed fromresources/META-INF/services/com.pinterest.ktlint.core.RuleSetProviderV2toresources/META-INF/services/com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3.The rule id's in
com.pinterest.ktlint.ruleset.core.api.Rulehave been changed from typeStringtoRuleId. ARuleIdhas a value that must adhere the convention "rule-set-id:rule-id". The rule set idstandardis 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 thanstandardto 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
ruleIdandaboutfields 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.EditorConfigPropertieshas been replaced withcom.pinterest.ktlint.rule.engine.core.api.EditorConfig. The interfacecom.pinterest.ktlint.core.api.UsesEditorConfigPropertieshas been removed. Instead, the Rule propertyusesEditorConfigPropertiesneeds to be set. As a result of those changes, thebeforeFirstNodefunction in each rule has to changed to something like below:Fields
loadOnlyWhenOtherRuleIsLoadedandrunOnlyWhenOtherRuleIsEnabledhave been removed from classcom.pinterest.ktlint.rule.engine.core.api.Rule.VisitorModifier.RunAfterRuleand are replaced with a single fieldmode. Themodeeither contains valueREGARDLESS_WHETHER_RUN_AFTER_RULE_IS_LOADED_OR_DISABLEDorONLY_WHEN_RUN_AFTER_RULE_IS_LOADED_AND_ENABLED.Custom Reporter Provider
ReporterProviderCustom Reporters build for older versions of KtLint are no longer supported by this version of KtLint. The
com.pinterest.ktlint.core.ReporterProviderinterface has been replaced withcom.pinterest.ktlint.cli.reporter.core.api.ReporterProviderV2. The accompanying interfacecom.pinterest.ktlint.core.Reporterhas been replaced withcom.pinterest.ktlint.cli.reporter.core.api.ReporterV2.Note that due to renaming and relocation of the
ReporterProviderV2interface the name of the service provider in the custom reporter needs to be changed fromresources/META-INF/services/com.pinterest.ktlint.core.ReporterProvidertoresources/META-INF/services/com.pinterest.ktlint.cli.reporter.core.api.ReporterProviderV2.The biggest change in the
ReporterV2is the replacement of theLintErrorclass withKtlintCliErrorclass. 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.Custom rules provided by API Consumer
API Consumers provide a set of rules directly to the Ktlint Rule Engine. The
com.pinterest.ktlint.core.Rulehas been replaced withcom.pinterest.ktlint.ruleset.core.api.Rule.The type of the rule id's has been changed from type
StringtoRuleId. ARuleIdhas a value that must adhere to the convention "rule-set-id:rule-id". Rule set idstandardis reserved for rules which are maintained by the KtLint project. Custom rules created by the API Consumer should use a prefix other thanstandardto clearly mark the origin of rules which are not maintained by the KtLint project.Also, the field
Abouthas 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
ruleIdandaboutfields 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.EditorConfigPropertieshas been replaced withcom.pinterest.ktlint.rule.engine.core.api.EditorConfig. The interfacecom.pinterest.ktlint.core.api.UsesEditorConfigPropertieshas been removed. Instead, the Rule propertyusesEditorConfigPropertiesneeds to be set. As a result of those changes, thebeforeFirstNodefunction in each rule has to changed to something like below:Fields
loadOnlyWhenOtherRuleIsLoadedandrunOnlyWhenOtherRuleIsEnabledhave been removed from classcom.pinterest.ktlint.rule.engine.core.api.Rule.VisitorModifier.RunAfterRuleand are replaced with a single fieldmode. Themodeeither contains valueREGARDLESS_WHETHER_RUN_AFTER_RULE_IS_LOADED_OR_DISABLEDorONLY_WHEN_RUN_AFTER_RULE_IS_LOADED_AND_ENABLED.Like before, the API Consumer can still offer a mix of rules originating from
ktlint-ruleset-standardas well as custom rules..editorconfigpropertymax_line_lengthdefault valuePreviously, the default value for
.editorconfigpropertymax_line_lengthwas set to-1in ktlint unless the property was defined explicitly in the.editorconfigor whenktlint_code_stylewas 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 valueInt.MAX_VALUE(use constantMAX_LINE_LENGTH_PROPERTY_OFFto refer to that value) is used instead.Psi filename replaces FILE_PATH_USER_DATA_KEY
Constant
KtLint.FILE_PATH_USER_DATA_KEYhas been removed. The file path is passed correctly to the node with element type FILE and can be retrieved as follows:Added
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 thektlint_officialcode 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)stdinwith KtLint CLI (#1832)build.gradlelike: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-wrappingfor all code styles. An enum should either be a single line, or each enum entry should be defined on a separate line. (#1903)Removed
.editorconfigpropertiesdisabled_rulesandktlint_disabled_rules. See disabled rules for more information.--print-ast. Use IntelliJ IDEA PsiViewer plugin instead. (#1925)Fixed
no-semi(#1733)function-signature.multiline.function-signature.standard:filenamerule whenever Ktlint CLI is run with option--stdin(#1742)ktlint_officialcode style)indent(#1756)trailing-comma-on-declaration-site(#1711)ktlint_officialcode style onlyindent(#1540).editorconfiguse valueofffor themax_line_lengthproperty instead of value-1to 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..inrange-spacing(#1858).editorconfigpropertyij_kotlin_imports_layoutcontains a|but no import exists that match any pattern before the first|then do not report a violation nor insert a blank lineimport-ordering(#1845)**/*.ktand**/*.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_officialonly.function-signature,parameter-list-wrapping(#1908)annotation(#1909)trailing-comma-on-declaration-site(#1911)ktlint_official.annotation(#1916)annotation(#1917)multiline-if-else(#1904)Changed
ktlint_officialcode style)parameter-list-wrapping(#1681).--patterns-from-stdinis specified (#1793)1.8.20and Kotlin version to1.8.20.ktlint_official, do not allow wildcard importsjava.utilandkotlinx.android.syntheticby default. Important:.editorconfigpropertyij_kotlin_packages_to_use_import_on_demandneeds to be set to valueunsetin order to enforce IntelliJ IDEA default formatter to not generate wildcard importsno-wildcard-imports(#1797)comment-wrapping(#1941)comment-wrapping(#1942)v0.48.2Compare Source
Additional clarification on API Changes in
0.48.0and0.48.1Starting 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
.editorconfigfile. 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
.editorconfigbecomes 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
.editorconfigis a powerful configuration tool which can be used in very different ways. Most projects use a single.editorconfigfile containing one common section for kotlin and kotlin scripts files. For example, the.editorconfigfile of the Ktlint project contains following section:Other projects might contain multiple
.editorconfigfiles for different parts of the project directory hierarchy. Or, use a single.editorconfigfile 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.editorconfigfile 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
editorConfigDefaultproperty:If the user has set property
ktlint_experimentalexplicitly than that value will be used. If the value is not defined, the value provided viaeditorConfigDefaultswill be used.If you do want to ignore the value of
ktlint_experimentalas 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.editorconfigproperty is being ignored (provided that the value set is not equal to the value provided by the API Consumer).Added
Removed
Fixed
annotation(#1765).editorconfigpropertiesdisabled_rulesorktlint_disabled_rulesare set. (#1771)max-line-lengthshould be ignored by rulefunction-signature(#1773)class-naming,function-naming,package-name,property-naming(#1757)file-namerule on code snippets (#1768).editorconfigpropertyij_kotlin_imports_layout's entries (#1770)Changed
v0.48.1Compare Source
Added
Removed
Fixed
no-semi(#1733)standard:filenamerule whenever Ktlint CLI is run with option--stdin(#1742)--log-levelis specified. Throw exception when an invalid value is passed. (#1749)experimentalrule set are disabled by default. (#1747)Changed
1.8.0and Kotlin version to1.8.0.v0.48.0Compare Source
Indent rule
The
indentrule 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..editorconfigproperty to disable rulesIn the previous release (0.47.x), the
.editorconfigpropertydisabled_ruleswas deprecated and replaced withktlint_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
--experimentalto enable KtLint's Experimental rule set, you might want to set.editorconfigpropertyktlint_experimental = enabledinstead.API Changes & RuleSet providers
If you are not an API consumer or Rule Set provider then you can skip this section.
Class relocations
Classes below have been relocated:
com.pinterest.ktlint.core.api.UsesEditorConfigProperties.EditorConfigPropertyhas been replaced withcom.pinterest.ktlint.core.api.editorconfig.EditorConfigProperty.com.pinterest.ktlint.core.KtLintParseExceptionhas been replaced withcom.pinterest.ktlint.core.api.KtLintParseException.com.pinterest.ktlint.core.RuleExecutionExceptionhas been replaced withcom.pinterest.ktlint.core.api.KtLintRuleException.com.pinterest.ktlint.reporter.format.internal.Colorhas been moved tocom.pinterest.ktlint.reporter.format.Color.com.pinterest.ktlint.reporter.plain.internal.Colorhas been moved tocom.pinterest.ktlint.reporter.plain.Color.Invoking
lintandformatThis is the last release that supports the
ExperimentalParamsto invoke thelintandformatfunctions of KtLint. TheExperimentalParamscontains 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
KtLintis deprecated and replaced by classKtLintRuleEnginewhich is configured withKtLintRuleEngineConfiguration. The instance of theKtLintRuleEngineis intended to be reused for scanning all files in a project and should not be recreated per file.Both
lintandformatare simplified and can now be called for a code block or for an entire file.Retrieve
.editorconfigsThe list of
.editorconfigfiles which will be accessed by KtLint when linting or formatting a given path can now be retrieved with the new APIKtLint.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 ac
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.