From 93da14da779c40bea1e93e0ce8f3f49550d1ef45 Mon Sep 17 00:00:00 2001 From: TTOzzi Date: Thu, 30 Jan 2025 01:29:40 +0900 Subject: [PATCH] Modify the diagnostic message of DontRepeatTypeInStaticProperties appropriately --- .../DontRepeatTypeInStaticProperties.swift | 2 +- ...ontRepeatTypeInStaticPropertiesTests.swift | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Sources/SwiftFormat/Rules/DontRepeatTypeInStaticProperties.swift b/Sources/SwiftFormat/Rules/DontRepeatTypeInStaticProperties.swift index 3bf853d2f..f5bc5c705 100644 --- a/Sources/SwiftFormat/Rules/DontRepeatTypeInStaticProperties.swift +++ b/Sources/SwiftFormat/Rules/DontRepeatTypeInStaticProperties.swift @@ -66,7 +66,7 @@ public final class DontRepeatTypeInStaticProperties: SyntaxLintRule { extension Finding.Message { fileprivate static func removeTypeFromName(name: String, type: Substring) -> Finding.Message { - "remove the suffix '\(type)' from the name of the variable '\(name)'" + "remove '\(type)' from the name of the variable '\(name)'" } } diff --git a/Tests/SwiftFormatTests/Rules/DontRepeatTypeInStaticPropertiesTests.swift b/Tests/SwiftFormatTests/Rules/DontRepeatTypeInStaticPropertiesTests.swift index 2eb12dd82..5a345aa32 100644 --- a/Tests/SwiftFormatTests/Rules/DontRepeatTypeInStaticPropertiesTests.swift +++ b/Tests/SwiftFormatTests/Rules/DontRepeatTypeInStaticPropertiesTests.swift @@ -36,15 +36,15 @@ final class DontRepeatTypeInStaticPropertiesTests: LintOrFormatRuleTestCase { } """, findings: [ - FindingSpec("1️⃣", message: "remove the suffix 'Color' from the name of the variable 'redColor'"), - FindingSpec("2️⃣", message: "remove the suffix 'Color' from the name of the variable 'blueColor'"), - FindingSpec("3️⃣", message: "remove the suffix 'Sandwich' from the name of the variable 'bolognaSandwich'"), - FindingSpec("4️⃣", message: "remove the suffix 'Sandwich' from the name of the variable 'hamSandwich'"), - FindingSpec("5️⃣", message: "remove the suffix 'Person' from the name of the variable 'youngPerson'"), - FindingSpec("6️⃣", message: "remove the suffix 'Game' from the name of the variable 'basketballGame'"), - FindingSpec("7️⃣", message: "remove the suffix 'Game' from the name of the variable 'baseballGame'"), - FindingSpec("8️⃣", message: "remove the suffix 'Session' from the name of the variable 'sharedSession'"), - FindingSpec("9️⃣", message: "remove the suffix 'Cookie' from the name of the variable 'chocolateChipCookie'"), + FindingSpec("1️⃣", message: "remove 'Color' from the name of the variable 'redColor'"), + FindingSpec("2️⃣", message: "remove 'Color' from the name of the variable 'blueColor'"), + FindingSpec("3️⃣", message: "remove 'Sandwich' from the name of the variable 'bolognaSandwich'"), + FindingSpec("4️⃣", message: "remove 'Sandwich' from the name of the variable 'hamSandwich'"), + FindingSpec("5️⃣", message: "remove 'Person' from the name of the variable 'youngPerson'"), + FindingSpec("6️⃣", message: "remove 'Game' from the name of the variable 'basketballGame'"), + FindingSpec("7️⃣", message: "remove 'Game' from the name of the variable 'baseballGame'"), + FindingSpec("8️⃣", message: "remove 'Session' from the name of the variable 'sharedSession'"), + FindingSpec("9️⃣", message: "remove 'Cookie' from the name of the variable 'chocolateChipCookie'"), ] ) } @@ -70,7 +70,7 @@ final class DontRepeatTypeInStaticPropertiesTests: LintOrFormatRuleTestCase { } """, findings: [ - FindingSpec("1️⃣", message: "remove the suffix 'Thing' from the name of the variable 'defaultThing'") + FindingSpec("1️⃣", message: "remove 'Thing' from the name of the variable 'defaultThing'") ] ) } @@ -86,9 +86,8 @@ final class DontRepeatTypeInStaticPropertiesTests: LintOrFormatRuleTestCase { } """, findings: [ - FindingSpec("1️⃣", message: "remove the suffix 'Foo' from the name of the variable 'alternateFoo'") + FindingSpec("1️⃣", message: "remove 'Foo' from the name of the variable 'alternateFoo'") ] ) } - }