-
This question is related to #3608 . To avoid the duplication of default config values in rules I would like to extract the default value that is shown in the documentation from the delegated property in the class RuleA(config: Config = Config.empty) : Rule(config) {
// no problem without type resolution
private val configA: Int by config(defaultValue = 99)
// a little more complicated but still possible without type resolution
private val configB: Int by config(defaultValue = DEFAULT_CONFIG_B)
// ???
private val configC: Int by config(defaultValue = DEFAULT_DEFINED_SOMEWHERE_ELSE)
...
companion object {
const val DEFAULT_CONFIG_B = 15
}
} I have no idea how to extract the default value for the documentation if it is defined somewhere else in the code base without type resolution. A real life example is My preference would be to avoid type resolution here. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That's not possible, unless we restrict how default value are defined.
You should populate the |
Beta Was this translation helpful? Give feedback.
That's not possible, unless we restrict how default value are defined.
What I think it's further complicated to address here is that
defaultValue
could potentially be a function, so you actually need to execute code in order to compute the default value. I'm unsure we want to go this way.You should populate the
classpath
parameter correctly. See https://detekt.github.io/detekt/type-resolution.html