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
Replace KtLintMultiRule
#6094
Replace KtLintMultiRule
#6094
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6094 +/- ##
============================================
- Coverage 84.94% 84.45% -0.49%
+ Complexity 4026 3988 -38
============================================
Files 569 568 -1
Lines 13498 13416 -82
Branches 2381 2366 -15
============================================
- Hits 11466 11331 -135
- Misses 869 935 +66
+ Partials 1163 1150 -13
|
Coming back to your comment @chao2zhang
Looking at the analyzer it seems to me that the execution order of the rules within a rule set is the same as the order returned by the rule set provider. I have not tried to write a test for it though. Do you think there needs to be some more work around that? |
|
||
@Configuration("if rules should auto correct style violation") | ||
val autoCorrect by ruleSetConfig(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property was seemingly unused. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #6094 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this Kotlin property is not used in production
- It is used to generate the docs
- It is used to generate the config: https://github.com/detekt/detekt/blob/main/detekt-formatting/src/main/resources/config/config.yml
- Hence the actual config property "autoCorrect" was previously used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I have reverted the change.
This can be merged after 1.23.0, right? As it is a big change and it doesn't provide any feature for the user. |
Yes, it is just a prerequisite for the deprecation removal and for whatever we end up going with the formatting rule set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍 LGTM!
|
* Currently only RunAsLateAsPossible is supported. | ||
*/ | ||
internal object FormattingRuleComparator : Comparator<FormattingRule> { | ||
override fun compare(o1: FormattingRule, o2: FormattingRule): Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ktlint also defines VisitorModifier.RunAfterRule
, and we should respect that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yap, that is described in #5259
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭. Would you mind if I contribute to this PR as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not mind at all. But I would not want to fix the RunAfterRule
issue with this pr or do you see them as strongly connected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we agreed that this PR can be merged post 1.23
Let me just open a new PR post the merge of this PR.
Thank you for pointing this out. I can see why rules that might change the source code (autocorrect==true) should run first. That totally makes sense. But why must the other formatting rules run before all other rules? Honestly this feels more like a coincidence to me. |
8690bda
to
9f8bada
Compare
9f8bada
to
0d76036
Compare
* remove unused autoCorrect property * WIP * WIP * fix documentation generation * Allow multiple classes in rule set provider file * remove multirule support in docs * fix style and formatting violations * revert removal of autocorrect prop --------- Co-authored-by: Chao Zhang <chao.zhang@instacart.com>
This relates to #5192 and removes the last
MutliRule
usage in the detekt code base.Unfortunately I had to change the documentation generation mechanism here as well as it did not work when the rule list has a function call attached such as
RuleSet("formatting", listOf(Rule1(config).sorted())
.