A val in an object or at the top level holds a literal and could be a const val

tx0/kotlin:val-could-be-constallwarningstyle/conventionsdepth faststyle

What it finds

A const val is inlined at compile time and can be used in annotations. A top-level or object val that is initialized with a number, boolean, character or string literal and has no getter, delegate or annotation can be one.

From the rule's source, could_be_const.rs.

Example from the rule's tests
val TIMEOUT = 30tx0 reports: TIMEOUT holds a literal and could be constconst val LIMIT = 10val label = "x"tx0 reports: label holds a literalval list = listOf(1)object Config {    val PORT = 8080tx0 reports: PORT holds a literal    @JvmField val HOST = "h"}class Holder {    val size = 3}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:val-could-be-const" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:val-could-be-const] reason="..."

tx0 explain tx0/kotlin:val-could-be-const shows the same in the terminal. Found a false positive? Report it.