From 0e4b1997297dce5df0d06050511799e6d007fc3c Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 20 Aug 2024 07:35:03 +0200 Subject: [PATCH] use emptyList() instead of listOf() to make it clear it is intentional otherwise it could also be that we were interrupted and forgot to add elements, i.e. it could be a bug --- .../atrium/reporting/translating/UsingDefaultTranslator.kt | 2 +- .../reporting/TextNextLineAssertionPairFormatterSpec.kt | 4 ++-- .../reporting/translating/TranslatableWithArgsSpec.kt | 6 +++--- .../atrium/reporting/erroradjusters/AdjustStackSpec.kt | 4 ++-- gradle/build-logic/dev/src/main/kotlin/generation.kt | 2 +- .../creating/transformers/impl/DefaultFeatureExtractor.kt | 4 ++-- .../EmptyNameAndSubjectAssertionGroupFormatterSpec.kt | 2 +- .../reporting/SingleAssertionGroupTypeFormatterSpec.kt | 6 +++--- .../reporting/TextIndentBasedAssertionGroupFormatterSpec.kt | 2 +- .../reporting/TextSummaryAssertionGroupFormatterSpec.kt | 2 +- .../reporting/TextFeatureAssertionGroupFormatterSpec.kt | 2 +- .../reporting/TextListBasedAssertionGroupFormatterSpec.kt | 2 +- .../kotlin/readme/examples/OwnExpectationFunctionsSpec.kt | 6 +++--- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/translating/UsingDefaultTranslator.kt b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/translating/UsingDefaultTranslator.kt index 4353d3b5d4..1c8902c717 100644 --- a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/translating/UsingDefaultTranslator.kt +++ b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/translating/UsingDefaultTranslator.kt @@ -14,7 +14,7 @@ import ch.tutteli.atrium.core.polyfills.format */ class UsingDefaultTranslator( primaryLocale: Locale = getDefaultLocale() -) : ArgumentsSupportingTranslator(primaryLocale, listOf()) { +) : ArgumentsSupportingTranslator(primaryLocale, emptyList()) { override fun translateWithoutArgs(translatable: Translatable) = translatable.getDefault() } diff --git a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/TextNextLineAssertionPairFormatterSpec.kt b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/TextNextLineAssertionPairFormatterSpec.kt index 6d8fb79a03..2d4555ca9c 100644 --- a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/TextNextLineAssertionPairFormatterSpec.kt +++ b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/TextNextLineAssertionPairFormatterSpec.kt @@ -33,7 +33,7 @@ class TextNextLineAssertionPairFormatterSpec : AssertionFormatterSpecBase({ val newParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint) val assertionGroup = assertionBuilder.root .withDescriptionAndRepresentation(name, subject) - .withAssertions(listOf()) + .withAssertions(emptyList()) .build() testee.formatGroupHeader(parameterObject, assertionGroup, newParameterObject) expect(sb.toString()) toEqual "$name:$lineSeparator$indentBulletPoint$subject" @@ -42,7 +42,7 @@ class TextNextLineAssertionPairFormatterSpec : AssertionFormatterSpecBase({ it("does not append a new line if the subject is ${Text::class.simpleName}${Text.Companion::EMPTY.name}") { val assertionGroup = assertionBuilder.root .withDescriptionAndEmptyRepresentation(name) - .withAssertions(listOf()) + .withAssertions(emptyList()) .build() val newParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint) testee.formatGroupHeader(parameterObject, assertionGroup, newParameterObject) diff --git a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt index 78c7f1ea6e..eeb73d833c 100644 --- a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt +++ b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt @@ -11,7 +11,7 @@ class TranslatableWithArgsSpec : Spek({ context("for a translatable without args") { it("no arguments given; throws") { expect { - TranslatableWithArgs(HELLO, listOf()) + TranslatableWithArgs(HELLO, emptyList()) }.toThrow { its messageToContain values( "No arguments specified" @@ -33,7 +33,7 @@ class TranslatableWithArgsSpec : Spek({ context("for a translatable with 1 arg") { it("no arguments given; throws") { expect { - TranslatableWithArgs(WITH_1_ARG, listOf()) + TranslatableWithArgs(WITH_1_ARG, emptyList()) }.toThrow { its messageToContain values( "No arguments specified" @@ -59,7 +59,7 @@ class TranslatableWithArgsSpec : Spek({ context("for a translatable with 2 args") { it("no arguments given; throws") { expect { - TranslatableWithArgs(WITH_2_ARGS, listOf()) + TranslatableWithArgs(WITH_2_ARGS, emptyList()) }.toThrow { its messageToContain values( "No arguments specified" diff --git a/atrium-core/src/jvmTest/kotlin/ch/tutteli/atrium/reporting/erroradjusters/AdjustStackSpec.kt b/atrium-core/src/jvmTest/kotlin/ch/tutteli/atrium/reporting/erroradjusters/AdjustStackSpec.kt index 2480ef8f83..66bd8104a1 100644 --- a/atrium-core/src/jvmTest/kotlin/ch/tutteli/atrium/reporting/erroradjusters/AdjustStackSpec.kt +++ b/atrium-core/src/jvmTest/kotlin/ch/tutteli/atrium/reporting/erroradjusters/AdjustStackSpec.kt @@ -143,7 +143,7 @@ class AdjustStackSpec : Spek({ MultiAtriumErrorAdjuster( c.build(), c.build(), - listOf() + emptyList() ) }, "combine remove atrium adjuster and remove runner adjuster" to @@ -151,7 +151,7 @@ class AdjustStackSpec : Spek({ MultiAtriumErrorAdjuster( c.build(), c.build(), - listOf() + emptyList() ) }, "combine noop adjust, remove atrium adjuster and remove runner adjuster" to diff --git a/gradle/build-logic/dev/src/main/kotlin/generation.kt b/gradle/build-logic/dev/src/main/kotlin/generation.kt index 1a7cd9a01d..660c020615 100644 --- a/gradle/build-logic/dev/src/main/kotlin/generation.kt +++ b/gradle/build-logic/dev/src/main/kotlin/generation.kt @@ -116,7 +116,7 @@ fun Project.registerGenerateLogicTaskForPackage( val typeIdentifier = Regex(""" *fun (?<.+?> )?(?$identifier)\((?:$newLineAndIndent)?$identifier *: (?$identifier(?:\.$identifier)*<.+>)""") val patterns = (6 downTo 0).map { numOfParams -> - val params = if (numOfParams > 0) (1..numOfParams).toList() else listOf() + val params = if (numOfParams > 0) (1..numOfParams).toList() else emptyList() Triple( Regex(typeIdentifier.pattern + params.joinToString("") { paramNumber -> parameter(paramNumber).pattern } + returnType.pattern), """fun ${"$"}{generics}${"$"}{type}\.${"$"}{funcName}\(""" + diff --git a/logic/atrium-logic/src/commonMain/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultFeatureExtractor.kt b/logic/atrium-logic/src/commonMain/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultFeatureExtractor.kt index c32af85f60..358d9a24b2 100644 --- a/logic/atrium-logic/src/commonMain/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultFeatureExtractor.kt +++ b/logic/atrium-logic/src/commonMain/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultFeatureExtractor.kt @@ -51,7 +51,7 @@ class DefaultFeatureExtractor : FeatureExtractor { }) val subAssertions = maybeSubAssertions.fold({ - listOf() + emptyList() }) { assertionCreator -> // TODO 1.3.0: factor out in common pattern, should not be the concern of the average expectation // function writer @@ -85,7 +85,7 @@ class DefaultFeatureExtractor : FeatureExtractor { // shows why the extraction went wrong (e.g. index out of bound) container.append(fixedClaimGroup) }) - createFeatureExpect(None, listOf()) + createFeatureExpect(None, emptyList()) }, { subject -> createFeatureExpect(Some(subject), maybeSubAssertions.fold({ diff --git a/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt b/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt index 15fe1b86e9..d3cb689b53 100644 --- a/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt +++ b/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt @@ -47,7 +47,7 @@ abstract class EmptyNameAndSubjectAssertionGroupFormatterSpec } val unsupportedAssertionGroup = assertionBuilder.customType(object : AssertionGroupType {}) .withDescriptionAndRepresentation(Untranslatable.EMPTY, 1) - .withAssertions(listOf()) + .withAssertions(emptyList()) .build() val supportedAssertionGroupWithAnonymousType = assertionBuilder.customType(supportedAnonymousAssertionGroupType) .withDescriptionAndRepresentation(Untranslatable.EMPTY, 1) - .withAssertions(listOf()) + .withAssertions(emptyList()) .build() val supportedAnonymousAssertionGroupWithAnonymousType = object : AssertionGroup { override val description = Untranslatable("test") @@ -58,7 +58,7 @@ abstract class SingleAssertionGroupTypeFormatterSpec } val supportedAssertionGroup = assertionBuilder.customType(supportedAssertionGroupType) .withDescriptionAndRepresentation(Untranslatable.EMPTY, 1) - .withAssertions(listOf()) + .withAssertions(emptyList()) .build() val supportedAnonymousAssertionGroup = object : AssertionGroup { override val description = Untranslatable("test") diff --git a/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt b/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt index f93e9958e6..73fe6b03ac 100644 --- a/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt +++ b/misc/atrium-specs/src/commonMain/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt @@ -41,7 +41,7 @@ abstract class TextIndentBasedAssertionGroupFormatterSpec( val result = testee.canFormat( assertionBuilder.customType(anonymousAssertionGroupType) .withDescriptionAndRepresentation(Untranslatable.EMPTY, 1) - .withAssertions(listOf()) + .withAssertions(emptyList()) .build() ) expect(result).toEqual(true) diff --git a/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt b/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt index e2e38b4f7f..9341edb65f 100644 --- a/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt +++ b/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt @@ -72,7 +72,7 @@ object OwnExpectationFunctionsSpec : Spek({ } test("ex-own-compose-3") { - expect(Person("Susanne", "Whitley", 43, listOf())) + expect(Person("Susanne", "Whitley", 43, emptyList())) .toHaveNumberOfChildren(2) } @@ -89,7 +89,7 @@ object OwnExpectationFunctionsSpec : Spek({ //snippet-own-compose-4-insert } test("ex-own-compose-4") { - expect(Person("Susanne", "Whitley", 43, listOf())) + expect(Person("Susanne", "Whitley", 43, emptyList())) .toHaveAdultChildren() } @@ -99,7 +99,7 @@ object OwnExpectationFunctionsSpec : Spek({ } //@formatter:off test("ex-own-compose-5"){ - expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, listOf())))) + expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, emptyList())))) .children { // using the fun -> expectation-group, ergo sub expectations don't fail fast toHaveElementsAndNone { feature { f(it::firstName) }.toStartWith("Ro")