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

KtLint: migrate from RuleSetProvider to RuleSetProviderV2 #1543

Closed
6 of 7 tasks
Tracked by #1561
0x6675636b796f75676974687562 opened this issue Oct 31, 2022 · 2 comments · Fixed by #1570 or #1571
Closed
6 of 7 tasks
Tracked by #1561

KtLint: migrate from RuleSetProvider to RuleSetProviderV2 #1543

0x6675636b796f75676974687562 opened this issue Oct 31, 2022 · 2 comments · Fixed by #1570 or #1571
Assignees
Labels
bug Something isn't working epic Major feature, could be decomposed into smaller tasks
Milestone

Comments

@0x6675636b796f75676974687562
Copy link
Member

0x6675636b796f75676974687562 commented Oct 31, 2022

KtLint has introduced a major API change in the 0.47 release (see the Release Notes).

In particular, RuleSet and RuleSetProvider interfaces have been marked as deprecated, scheduled for removal in 0.48.

We'll need to rewrite DiktatRuleSetProvider and OrderedRuleSet implementations accordingly.

  • Stop using any deprecated API Migrate to the new rule set API #1570
  • stop extending com.pinterest.ktlint.core.Rule
  • leave org.cqfn.diktat.ruleset.rules.DiktatRule as is
  • introduce something like RuleProxy for running org.cqfn.diktat.ruleset.rules.DiktatRule as com.pinterest.ktlint.core.Rule
  • introduce something like DiktatRuleProxyFactory which creates com.pinterest.ktlint.core.Rule using configRules and creates visitorModifiers which are required for ordering.
    • Combine DiktatRuleSetProviderV2 and OrderedRuleSet: Diktat's proxy to RuleSetProviderV2 should keep ordering
    • Add Rule.VisitorModifier only when creating RuleSetProviderV2 and it's only KtLint-specific. Preserve all logic related to creating KtLint Rule's in a single place.
  • Change the DiktatRuleSetProviderTest#check DiktatRuleSetProviderTest contain all rules test which reads the source code of Rule and/or DiktatRule implementors to determine which rules are available at compile time.
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 added bug Something isn't working epic Major feature, could be decomposed into smaller tasks labels Oct 31, 2022
@nulls
Copy link
Member

nulls commented Oct 31, 2022

A common suggestion:

  • remove extending com.pinterest.ktlint.core.Rule
  • leave org.cqfn.diktat.ruleset.rules.DiktatRule as is
  • introduce something like RuleProxy for running org.cqfn.diktat.ruleset.rules.DiktatRule as com.pinterest.ktlint.core.Rule
  • introduce something like DiktatRuleProxyFactory which creates com.pinterest.ktlint.core.Rule using configRules and creates visitorModifiers which are required for ordering

@akuleshov7 @petertrr @0x6675636b796f75676974687562, what do you thing?

@petertrr
Copy link
Member

petertrr commented Nov 7, 2022

introduce something like RuleProxy
introduce something like DiktatRuleProxyFactory

Sounds like a good idea. Not only will it help us adapt to changes in RuleSetProvider-related APIs (e.g. ordering) but will also decouple diktat from ktlint a bit and maybe even let us try Detekt as a framework

@nulls nulls mentioned this issue Nov 15, 2022
8 tasks
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 added this to the ktlint-wrapper milestone Nov 17, 2022
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 linked a pull request Nov 17, 2022 that will close this issue
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 18, 2022
### What's done:

 - Deprecated API usages removed (except for `DiktatBaseMojo`).
 - @Suppress("Deprecation") annotations removed (except for `DiktatBaseMojo`).
 - A part of #1543.
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 18, 2022
### What's done:

 - Deprecated API usages removed (except for `DiktatBaseMojo`).
 - @Suppress("Deprecation") annotations removed (except for `DiktatBaseMojo`).
 - A part of #1543.
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 18, 2022
### What's done:

 - Deprecated API usages removed (except for `DiktatBaseMojo`).
 - @Suppress("Deprecation") annotations removed (except for `DiktatBaseMojo`).
 - A part of #1543.
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 linked a pull request Nov 18, 2022 that will close this issue
@nulls nulls mentioned this issue Apr 6, 2023
4 tasks
@nulls nulls modified the milestones: ktlint-wrapper, 2.0.0 Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working epic Major feature, could be decomposed into smaller tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants