-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
New rule: ClassOrdering #3088
New rule: ClassOrdering #3088
Conversation
cacac1f
to
5e9e552
Compare
Codecov Report
@@ Coverage Diff @@
## master #3088 +/- ##
============================================
+ Coverage 79.28% 79.30% +0.01%
- Complexity 2567 2577 +10
============================================
Files 434 435 +1
Lines 7735 7756 +21
Branches 1469 1476 +7
============================================
+ Hits 6133 6151 +18
- Misses 816 817 +1
- Partials 786 788 +2
Continue to review full report at Codecov.
|
5e9e552
to
d8121af
Compare
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.
Great rule 👌 I'm just unsure if we want to enabled it by default as it has the risk of raising a lot of warnings for our users. However the logic is really straightforward and aligned with the Kotlin guidelines.
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ClassOrdering.kt
Outdated
Show resolved
Hide resolved
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ClassOrdering.kt
Outdated
Show resolved
Hide resolved
Sorry I wasn't clear. I've enabled it for detekt scans of the detekt project itself, but it's not enabled by default for users - it's I also think that in almost all cases any violations it finds will lead to a more logical class layout so I think there's value in enabling it. It's quick to cut/paste code to fix issues it finds. But for now it's not enabled by default. |
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 like this one a lot! Myabe we could add some configuration later but, let's see what the community think when they test it :)
Thanks for the clarification 👌 Looks good to me 🚀 |
A rule to check the contents of a class match this ordering: https://kotlinlang.org/docs/reference/coding-conventions.html#class-layout
I've enabled this for detekt, and you can see in that second commit the changes that were required to comply with the new rule. I think the changes are mostly not controversial, but for those classes where they are a suppression is probably the right way to go, or perhaps changing some extension properties into extension functions.