Is there a way to customize the order that the Cla...
# detekt
t
Is there a way to customize the order that the ClassOrdering rule enforces? We use companion objects almost exclusively for factory methods, and we want those near the top of our classes next to the constructors. Checking for that order, or at least disabling the ordering rule specifically for companion objects, would be super helpful.
m
No, there is no such option. The
ClassOrdering
rule verifies that the class layout conforms to the conventions from https://kotlinlang.org/docs/coding-conventions.html#class-layout
t
Yeah, I've seen the doc about that being conventional. We still want to break it, uniformly if possible. Or at least, not at the cost of losing consistency for the other member's order.
g
I think you’ll have to make a custom rule that either subclass
ClassOrdering
or you just copy over the body (far from ideal I know).
👍 1
t
Thanks Nicola, I was thinking that would be the road I could go down!
👍 1