Skip to content

Commit

Permalink
refactor: replace if with when #1208
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Sep 19, 2020
1 parent d802e09 commit 776e7ca
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ open class PactBrokerLoader(
pactBrokerConsumerVersionSelectors.flatMap {
val tags = parseListExpression(it.tag, resolver)
val parsedLatest = parseListExpression(it.latest, resolver)
val latest = if (parsedLatest.isEmpty()) List(tags.size) { true.toString() }
else if (parsedLatest.size == 1) parsedLatest.padTo(tags.size, parsedLatest[0])
else parsedLatest
val latest = when {
parsedLatest.isEmpty() -> List(tags.size) { true.toString() }
parsedLatest.size == 1 -> parsedLatest.padTo(tags.size, parsedLatest[0])
else -> parsedLatest
}
if (tags.size != latest.size) {
throw IllegalArgumentException("Invalid Consumer version selectors. Each version selector must have a tag " +
"and latest property")
Expand Down

0 comments on commit 776e7ca

Please sign in to comment.