Use reference in fallback property delegate (#3982)

Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
Co-authored-by: Brais <braisgabin@gmail.com>
This commit is contained in:
marschwar
2021-09-14 14:12:49 +02:00
committed by GitHub
parent 19b06c96d0
commit 7962979fb3
9 changed files with 74 additions and 137 deletions

View File

@@ -40,30 +40,25 @@ class LongParameterList(config: Config = Config.empty) : Rule(config) {
Debt.TWENTY_MINS
)
@Suppress("unused")
@Deprecated("Use `functionThreshold` and `constructorThreshold` instead")
@Configuration("number of parameters required to trigger the rule")
private val threshold: Int by config(DEFAULT_FUNCTION_THRESHOLD)
@Suppress("DEPRECATION")
@OptIn(UnstableApi::class)
@Configuration("number of function parameters required to trigger the rule")
private val functionThreshold: Int by configWithFallback(
fallbackPropertyName = "threshold",
defaultValue = DEFAULT_FUNCTION_THRESHOLD
)
private val functionThreshold: Int by configWithFallback(::threshold, DEFAULT_FUNCTION_THRESHOLD)
@Suppress("DEPRECATION")
@OptIn(UnstableApi::class)
@Configuration("number of constructor parameters required to trigger the rule")
private val constructorThreshold: Int by configWithFallback(
fallbackPropertyName = "threshold",
defaultValue = DEFAULT_CONSTRUCTOR_THRESHOLD
)
private val constructorThreshold: Int by configWithFallback(::threshold, DEFAULT_CONSTRUCTOR_THRESHOLD)
@Configuration("ignore parameters that have a default value")
private val ignoreDefaultParameters: Boolean by config(defaultValue = false)
private val ignoreDefaultParameters: Boolean by config(false)
@Configuration("ignore long constructor parameters list for data classes")
private val ignoreDataClasses: Boolean by config(defaultValue = true)
private val ignoreDataClasses: Boolean by config(true)
@Configuration(
"ignore long parameters list for constructors, functions or their parameters in the " +