From 0765da5f9d4bcb7b4a0fce8d97d993a00f7abc07 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Fri, 28 Aug 2020 10:11:33 +0100 Subject: [PATCH] Rename `multilineSwitchCases` rule to `wrapSwitchCases` --- Rules.md | 48 +++++++++++++++++++++--------------------- Sources/Examples.swift | 2 +- Sources/Rules.swift | 2 +- Tests/RulesTests.swift | 12 +++++------ 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Rules.md b/Rules.md index ae3a8ad3..03b013cd 100644 --- a/Rules.md +++ b/Rules.md @@ -21,7 +21,6 @@ * [linebreakAtEndOfFile](#linebreakAtEndOfFile) * [linebreaks](#linebreaks) * [modifierOrder](#modifierOrder) -* [multilineSwitchCases](#multilineSwitchCases) * [numberFormatting](#numberFormatting) * [organizeDeclarations](#organizeDeclarations) * [preferKeyPath](#preferKeyPath) @@ -70,6 +69,7 @@ * [wrapAttributes](#wrapAttributes) * [wrapEnumCases](#wrapEnumCases) * [wrapMultilineStatementBraces](#wrapMultilineStatementBraces) +* [wrapSwitchCases](#wrapSwitchCases) * [yodaConditions](#yodaConditions) ---------- @@ -632,29 +632,6 @@ Option | Description
-## multilineSwitchCases - -Writes one switch case per line. - -
-Examples - -```diff - switch foo { -- case .bar, .baz: - break - } - - switch foo { -+ case .foo, -+ .bar: - break - } -``` - -
-
- ## numberFormatting Use consistent grouping for numeric literals. Groups will be separated by `_` @@ -1879,6 +1856,29 @@ Wrap the opening brace of multiline statements.
+## wrapSwitchCases + +Writes one switch case per line. + +
+Examples + +```diff + switch foo { +- case .bar, .baz: + break + } + + switch foo { ++ case .foo, ++ .bar: + break + } +``` + +
+
+ ## yodaConditions Prefer constant values to be on the right-hand-side of expressions. diff --git a/Sources/Examples.swift b/Sources/Examples.swift index 9b182193..6cd8df74 100644 --- a/Sources/Examples.swift +++ b/Sources/Examples.swift @@ -922,7 +922,7 @@ private struct Examples { ``` """ - let multilineSwitchCases = """ + let wrapSwitchCases = """ ```diff switch foo { - case .bar, .baz: diff --git a/Sources/Rules.swift b/Sources/Rules.swift index 5bc241b4..b17568e0 100644 --- a/Sources/Rules.swift +++ b/Sources/Rules.swift @@ -3542,7 +3542,7 @@ public struct _FormatRules { } /// Writes one switch case per line - public let multilineSwitchCases = FormatRule( + public let wrapSwitchCases = FormatRule( help: "Writes one switch case per line.", disabledByDefault: true, sharedOptions: ["linebreaks", "tabwidth", "indent", "smarttabs"] diff --git a/Tests/RulesTests.swift b/Tests/RulesTests.swift index b88015a2..bea5474a 100644 --- a/Tests/RulesTests.swift +++ b/Tests/RulesTests.swift @@ -5011,7 +5011,7 @@ class RulesTests: XCTestCase { testFormatting(for: input, rule: FormatRules.wrapEnumCases) } - // MARK: multilineSwitchCases + // MARK: wrapSwitchCases func testMultilineSwitchCases() { let input = """ @@ -5036,7 +5036,7 @@ class RulesTests: XCTestCase { } } """ - testFormatting(for: input, output, rule: FormatRules.multilineSwitchCases) + testFormatting(for: input, output, rule: FormatRules.wrapSwitchCases) } func testIfAfterSwitchCaseNotWrapped() { @@ -5051,7 +5051,7 @@ class RulesTests: XCTestCase { throw error } """ - testFormatting(for: input, rule: FormatRules.multilineSwitchCases) + testFormatting(for: input, rule: FormatRules.wrapSwitchCases) } // MARK: - void @@ -8753,7 +8753,7 @@ class RulesTests: XCTestCase { let input = "switch foo {\ncase .foo(let bar), .bar(let bar):\n}" let output = "switch foo {\ncase let .foo(bar), let .bar(bar):\n}" testFormatting(for: input, output, rule: FormatRules.hoistPatternLet, - exclude: ["multilineSwitchCases"]) + exclude: ["wrapSwitchCases"]) } func testHoistCatchLet() { @@ -8877,7 +8877,7 @@ class RulesTests: XCTestCase { let output = "switch foo {\ncase .foo(let bar), .bar(let bar):\n}" let options = FormatOptions(hoistPatternLet: false) testFormatting(for: input, output, rule: FormatRules.hoistPatternLet, options: options, - exclude: ["multilineSwitchCases"]) + exclude: ["wrapSwitchCases"]) } func testUnhoistCommaSeparatedSwitchCaseLets2() { @@ -8885,7 +8885,7 @@ class RulesTests: XCTestCase { let output = "switch foo {\ncase Foo.foo(let bar), Foo.bar(let bar):\n}" let options = FormatOptions(hoistPatternLet: false) testFormatting(for: input, output, rule: FormatRules.hoistPatternLet, options: options, - exclude: ["multilineSwitchCases"]) + exclude: ["wrapSwitchCases"]) } func testUnhoistCatchLet() {