Skip to content
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 dependency com.pinterest.ktlint:ktlint-ruleset-standard to v0.50.0 #6239

Merged
merged 4 commits into from Jul 4, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jun 29, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
com.pinterest.ktlint:ktlint-ruleset-standard 0.49.1 -> 0.50.0 age adoption passing confidence

Release Notes

pinterest/ktlint (com.pinterest.ktlint:ktlint-ruleset-standard)

v0.50.0

Compare Source

Deprecation of ktlint-enable and ktlint-disable directives

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.

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 manipulating ASTNodes there seems to be no impact. When, manipulating PsiElements, 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:

  • Replace LeafElement.replaceWithText(String) with LeafElement.rawReplaceWithText(String).
  • Replace 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).
  • Replace 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.

Added
  • Add new experimental rule binary-expression-wrapping. This rule wraps a binary expression in case the max line length is exceeded (#​1940)
  • Add flag to disable extension point org.jetbrains.kotlin.com.intellij.treeCopyHandler to analyse impact on custom rules #​1981
  • Add new experimental rule no-empty-file for all code styles. A kotlin (script) file may not be empty (#​1074)
  • Add new experimental rule 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)
  • Add new experimental rule blank-line-before-declaration. This rule requires a blank line before class, function or property declarations (#​1939)
  • Wrap multiple statements on same line wrapping (#​1078)
  • Add new rule ktlint-suppression to replace the ktlint-disable and ktlint-enable directives with annotations. This rule can not be disabled via the .editorconfig (#​1947)
  • Inform user about using --format option of KtLint CLI when finding a violation that can be autocorrected (#​1071)
Removed
  • Code which was deprecated in 0.49.x is removed. Consult changelog of 0.49.x` released for more information. Summary of removed code:
Fixed
  • Do not flag a (potential) mutable extension property in case the getter is annotated or prefixed with a modifier property-naming (#​2024)
  • Do not merge an annotated expression body with the function signature even if it fits on a single line (#​2043)
  • Ignore property with name serialVersionUID in property-naming (#​2045)
  • Prevent incorrect reporting of violations in case a nullable function type reference exceeds the maximum line length parameter-list-wrapping (#​1324)
  • Prevent false negative on else branch when body contains only chained calls or binary expression (#​2057)
  • Fix indent when property value is wrapped to next line (#​2095)
Changed
  • Fix Java interoperability issues with 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)
  • Update dependency info.picocli:picocli to v4.7.4
  • Update dependency org.junit.jupiter:junit-jupiter to v5.9.3
  • Update Kotlin development version to 1.8.22 and Kotlin version to 1.8.22.
  • Update dependency io.github.detekt.sarif4k:sarif4k to v0.4.0
  • Update dependency org.jetbrains.dokka:dokka-gradle-plugin to v1.8.20
  • Run format up to 3 times in case formatting introduces changes which also can be autocorrected (#​2084)

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.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the dependencies Pull requests that update a dependency file label Jun 29, 2023
@3flex 3flex self-assigned this Jun 30, 2023
@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #6239 (b129d8f) into main (d403ff9) will decrease coverage by 0.03%.
The diff coverage is 30.00%.

@@             Coverage Diff              @@
##               main    #6239      +/-   ##
============================================
- Coverage     84.45%   84.42%   -0.03%     
  Complexity     4001     4001              
============================================
  Files           568      568              
  Lines         13440    13447       +7     
  Branches       2378     2379       +1     
============================================
+ Hits          11351    11353       +2     
- Misses          934      939       +5     
  Partials       1155     1155              
Impacted Files Coverage Δ
...io/gitlab/arturbosch/detekt/core/KtTreeCompiler.kt 72.72% <0.00%> (-4.70%) ⬇️
...itlab/arturbosch/detekt/core/extensions/Loading.kt 15.38% <0.00%> (-4.62%) ⬇️
...etekt/rules/complexity/StringLiteralDuplication.kt 95.91% <100.00%> (+0.17%) ⬆️

@3flex 3flex removed their assignment Jul 4, 2023
@renovate
Copy link
Contributor Author

renovate bot commented Jul 4, 2023

Edited/Blocked Notification

Renovate 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.

@3flex 3flex merged commit 0209143 into main Jul 4, 2023
22 of 23 checks passed
@3flex 3flex deleted the renovate/ktlint branch July 4, 2023 02:09
@detekt-ci
Copy link
Collaborator

Warnings
⚠️ This PR is approved with no milestone set. If merged, it won't appear in the detekt release notes.

Generated by 🚫 dangerJS against b129d8f

@3flex 3flex added this to the 2.0.0 milestone Jul 4, 2023
@cortinico cortinico added the pick request Marker for PRs that should be ported to the 1.0 release branch label Jul 15, 2023
cortinico pushed a commit to cortinico/detekt that referenced this pull request Jul 15, 2023
…50.0 (detekt#6239)

* Update dependency com.pinterest.ktlint:ktlint-ruleset-standard to v0.50.0

* Update test code to align to new rule behaviour

* Fix new issues raised by ktlint

* Fix a typo

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Matthew Haughton <3flex@users.noreply.github.com>
mgroth0 pushed a commit to mgroth0/detekt that referenced this pull request Feb 11, 2024
…50.0 (detekt#6239)

* Update dependency com.pinterest.ktlint:ktlint-ruleset-standard to v0.50.0

* Update test code to align to new rule behaviour

* Fix new issues raised by ktlint

* Fix a typo

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Matthew Haughton <3flex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core dependencies Pull requests that update a dependency file formatting pick request Marker for PRs that should be ported to the 1.0 release branch rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants