-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Ktlint to v1 (major) #1729
Conversation
23293e9
to
27899f6
Compare
27899f6
to
a4cfff6
Compare
a4cfff6
to
c0a34d9
Compare
- supported artifact names changes - logging upgrades - disabled tests which fails with repeatable run - fixed test for comment when ASTNode.copy() is called
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. ⚠ Warning: custom changes will be lost. |
Codecov Report
@@ Coverage Diff @@
## master #1729 +/- ##
============================================
- Coverage 78.21% 74.76% -3.46%
+ Complexity 2324 2270 -54
============================================
Files 126 126
Lines 8223 8230 +7
Branches 2073 2072 -1
============================================
- Hits 6432 6153 -279
- Misses 876 1163 +287
+ Partials 915 914 -1
|
JUnit Tests (macOS, EnricoMi/publish-unit-test-result-action@v2) 164 files ±0 164 suites ±0 5m 32s ⏱️ +8s Results for commit 5579d78. ± Comparison against base commit 84e380d. This pull request skips 33 tests.
♻️ This comment has been updated with latest results. |
JUnit Tests (Windows, EnricoMi/publish-unit-test-result-action@v2) 164 files ±0 164 suites ±0 5m 15s ⏱️ - 1m 33s Results for commit 5579d78. ± Comparison against base commit 84e380d. This pull request skips 40 tests.
♻️ This comment has been updated with latest results. |
This PR contains the following updates:
0.49.1
->1.0.0
0.49.1
->1.0.0
0.49.1
->1.0.0
⚠ Dependency Lookup Warnings ⚠
Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.
Release Notes
pinterest/ktlint (com.pinterest.ktlint:ktlint-cli-ruleset-core)
v1.0.0
Compare Source
💔 Breaking changes
Update and align Maven coordinates - #2195, by @paul-dingemans
Be sure to update Maven coordinates below, to get latest changes!
Add binary compatibility validator - #2131, by @mateuszkwiecinski
Replace kotlin public
data class
es with Poko compiler plugin generated ones - #2136, by @mateuszkwiecinskiAs a part of public API stabilization, data classes are no longer used in the public API. As of that, functions like
copy()
orcomponentN()
(used for destructuring declarations) are not available anymore.Promote experimental rules - #2218, by @paul-dingemans
The rules below have been promoted to non-experimental rules:
Fix statement-wrapping and align rule classes - #2178, by @paul-dingemans
Rule class
MultilineExpressionWrapping
has been renamed toMultilineExpressionWrappingRule
. Rule classStatementWrapping
has been renamed toStatementWrappingRule
.RULE_ID
constants below are moved to a different Java class at compile time. Each rule provided by Ktlint is to be accompanied by aRULE_ID
constant that can be used in theVisitorModifier.RunAfter
. Filenames did not comply with standard that it should end withRule
suffix.FUNCTION_EXPRESSION_BODY_RULE_ID
FUNCTION_LITERAL_RULE_ID
MULTILINE_EXPRESSION_WRAPPING_RULE_ID
NO_BLANK_LINE_IN_LIST_RULE_ID
NO_EMPTY_FILE_RULE_ID
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.🆕 Features
Change default code style to
ktlint_official
- #2144, by @paul-dingemansAdd new experimental rule
class-signature
- #2119, by @paul-dingemansAdd new experimental rule
function-expression-body
- #2151, by @paul-dingemansAdd new experimental rule
chain-method-continuation
- #2088, by @atulgptAdd new experimental rule
function-literal
- #2137, by @paul-dingemansAdd new experimental rule
function-type-modifier-spacing
rule - #2216, by @t-kameyamaDefine
EditorConfigOverride
for dynamically loaded ruleset - #2194, by @paul-dingemansThe
EditorConfigOverride
parameter of theKtlintRuleEngine
can be defined using the factory methodEditorConfigOverride.from(vararg properties: Pair<EditorConfigProperty<*>, *>)
. This requires theEditorConfigProperty
's to be available at compile time. Some commonEditorConfigProperty
's are defined inktlint-rule-engine-core
which is loaded as transitive dependency ofktlint-rule-engine
and as of that are available at compile.If an
EditorConfigProperty
is defined in aRule
that is only provided via a runtime dependency, it gets a bit more complicated. Thektlint-api-consumer
example has now been updated to show how theEditorConfigProperty
can be retrieved from theRule
.Move wrapping on semicolon from
wrapping
rule tostatement-wrapping
rule - #2222, by @paul-dingemans🔧 Fixes
Do not indent class body for classes having a long super type list - #2116, by @paul-dingemans
Fix indent of explicit constructor - #2118, by @paul-dingemans
Fix incorrect formatting of nested function literal - #2107, by @paul-dingemans
Add property to disable ktlint for a glob in
.editorconfig
- #2108, by @paul-dingemansFix 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-dingemansFix wrapping of multiline postfix expression - #2184, by @paul-dingemans
Do not wrap expression after a spread operator - #2193, by @paul-dingemans
Do not remove parenthesis after explicit class constructor without arguments - #2226, by @paul-dingemans
Fix conflict between rules due to annotated super type call - #2227, by @paul-dingemans
Fix indentation of super type list of class in case it is preceded by a comment - #2228, by @paul-dingemans
Super type list starting with an annotation having a parameters - #2230, by @paul-dingemans
Do not wrap values in a single line enum when it is preceded by a comment or an annotation - #2229, by @paul-dingemans
📦 Dependencies
Update dependency org.codehaus.janino:janino to v3.1.10 - #2110, by @renovate[bot]
Update dependency com.google.jimfs:jimfs to v1.3.0 - #2112, by @renovate[bot]
Update dependency org.junit.jupiter:junit-jupiter to v5.10.0 - #2148, by @renovate[bot]
Update dependency io.github.oshai:kotlin-logging-jvm to v5.1.0 - #2174, by @renovate[bot]
Update dependency dev.drewhamilton.poko:poko-gradle-plugin to v0.15.0 - #2173, by @renovate[bot]
Update plugin org.gradle.toolchains.foojay-resolver-convention to v0.7.0 - #2187, by @renovate[bot]
Update 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]
💬 Other
Setup toolchains, compile project with Java 20 only, run test on various Java versions - #2120, by @mateuszkwiecinski
Add release-changelog-builder-action to temporary workflow - #2196, by @paul-dingemans
v0.50.0
Compare Source
Deprecation of ktlint-enable and ktlint-disable directives
The
ktlint-disable
andktlint-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.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.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 manipulatingASTNode
s there seems to be no impact. When, manipulatingPsiElement
s, some functions consistently result in a runtime exception.Based on the refactoring of the rules as provided by
ktlint-ruleset-standard
in Ktlint0.49.x
the 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.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 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 theKtlintRuleEngine
directly, have to set propertyenableKotlinCompilerExtensionPoint
tofalse
.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.Added
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 thektlint-disable
andktlint-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)Removed
0.49.x
is removed. Consult changelog of 0.49.x` released for more information. Summary of removed code:Fixed
property-naming
(#2024)serialVersionUID
inproperty-naming
(#2045)parameter-list-wrapping
(#1324)else
branch when body contains only chained calls or binary expression (#2057)Changed
RuleId
andRuleSetId
classes. Those classes were defined as value classes in0.49.0
and0.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
tov4.7.4
org.junit.jupiter:junit-jupiter
tov5.9.3
1.8.22
and Kotlin version to1.8.22
.io.github.detekt.sarif4k:sarif4k
tov0.4.0
org.jetbrains.dokka:dokka-gradle-plugin
tov1.8.20
Configuration
📅 Schedule: Branch creation - "before 4am on Monday" (UTC), 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 these updates again.
This PR has been generated by Mend Renovate. View repository job log here.