KT.CLASS_ORDERING
Class contents not ordered
This rule ensures class contents are ordered as follows as recommended by the Kotlin Coding Conventions: Property declarations and initializer blocks Secondary constructors Method declarations Companion object
Noncompliant Code
Copy
class OutOfOrder {
companion object {
const val IMPORTANT_VALUE = 3
}
fun returnX(): Int {
return x
}
private val x = 2
}
Compliant Code
Copy
class InOrder {
private val x = 2
fun returnX(): Int {
return x
}
companion object {
const val IMPORTANT_VALUE = 3
}
}