Extract method to fix detekt ComplexMethod failure

This commit is contained in:
Joseph Zuniga-Daly 2020-08-19 17:18:39 +01:00
parent e79f4ab8e2
commit 6a776a267b

View File

@ -124,12 +124,7 @@ interface ObjectBuilder {
}.toMutableMap()
if (includeAllConstructorParameters) {
// Add constructor parameters not in the list of properties
// so we can use them in object evolution
for ((parameterIndex, parameter) in constructor.parameters.withIndex()) {
// Only use the parameters not already matched to properties
constructorIndices.putIfAbsent(parameter.name, parameterIndex)
}
addMissingConstructorParameters(constructorIndices, constructor)
}
val propertySlots = constructorIndices.keys.mapIndexed { slot, name -> name to slot }.toMap()
@ -139,6 +134,15 @@ interface ObjectBuilder {
}
}
private fun addMissingConstructorParameters(constructorIndices: MutableMap<String, Int>, constructor: LocalConstructorInformation) {
// Add constructor parameters not in the list of properties
// so we can use them in object evolution
for ((parameterIndex, parameter) in constructor.parameters.withIndex()) {
// Only use the parameters not already matched to properties
constructorIndices.putIfAbsent(parameter.name, parameterIndex)
}
}
private fun makeSetterBasedProvider(
properties: Map<String, LocalPropertyInformation>,
typeIdentifier: TypeIdentifier,