According to <Kotlin conventions>: Names of consta...
# detekt
n
According to Kotlin conventions: > Names of constants (properties marked with
const
, or top-level or object
val
properties with no custom
get
function that hold deeply immutable data) should use all uppercase, underscore-separated names following the screaming snake case convention There is a Detekt rule ObjectPropertyNaming and TopLevelPropertyNaming that has config options for consts. However I don't see anything that enforces screaming snake case for the vals. There is another rule MayBeConst that reports when a val should be a const but it mainly checks for primitive types. There could be vals which are technically immutable but can't be declared as const due to the way IntelliJ defines a const. For example:
object Classes {
/** JUnit annotations that indicate a setup method. */
val JUNIT_SETUP_ANNOTATED_METHOD = setOf("BeforeEach", "BeforeAll")
}
According to the convention this should be screaming snake case but there's nothing in Detekt to enforce this?
s
There's no differentiation between object val and var. For reference, take a look at the rule implementation. Btw, we happily accept PRs for adding this functionality. https://github.com/detekt/detekt/blob/a7ec7c120eb890c4e18e26ad22e3d3b5d52cd5df/detekt-rules-naming/src/main/kotlin/dev/detekt/rules/naming/ObjectPropertyNaming.kt#L56