From 11bb0f4965e93128b9d57812196988bad7be1cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Ulln=C3=A6ss?= Date: Wed, 2 Mar 2022 09:26:40 +0100 Subject: [PATCH] Simplify check --- common/src/main/kotlin/org/amshove/kluent/Collections.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/common/src/main/kotlin/org/amshove/kluent/Collections.kt b/common/src/main/kotlin/org/amshove/kluent/Collections.kt index 1a7d55c..06569c9 100644 --- a/common/src/main/kotlin/org/amshove/kluent/Collections.kt +++ b/common/src/main/kotlin/org/amshove/kluent/Collections.kt @@ -847,9 +847,7 @@ infix fun > I.shouldContainNone(expected: Array): I = infix fun > I.shouldContainNone(check: (T) -> Boolean): I = apply { val result = this.map { it to check.invoke(it) } - if (result.none { it.second }) { - Unit - } else { + if (result.any { it.second }) { val failedItems = result .filterNot { it.second } .map { it.first } @@ -902,9 +900,7 @@ infix fun > I.shouldNotContainAny(expected: Array): I = infix fun > I.shouldNotContainAny(check: (T) -> Boolean): I = apply { val result = this.map { it to check.invoke(it) } - if (result.none { it.second }) { - Unit - } else { + if (result.any { it.second }) { val failedItems = result .filterNot { it.second } .map { it.first }