diff --git a/CHANGELOG.md b/CHANGELOG.md index 775e8ef1e..590831299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,11 @@ `unneeded_synthesized_initializer` rule. [SimplyDanny](https://github.com/SimplyDanny) [#5153](https://github.com/realm/SwiftLint/issues/5153) + +* Make `vertical_whitespace_between_cases` rule work for + cases ending with a string literal. + [ilendemli](https://github.com/ilendemli) + [#5612](https://github.com/realm/SwiftLint/issues/5612) * Ignore access level modifiers restricted to value setting in `extension_access_modifier` rule. diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/VerticalWhitespaceBetweenCasesRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/VerticalWhitespaceBetweenCasesRule.swift index bcc63cd45..55f28a260 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/VerticalWhitespaceBetweenCasesRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/VerticalWhitespaceBetweenCasesRule.swift @@ -3,7 +3,7 @@ import SourceKittenFramework private extension SwiftLintFile { func violatingRanges(for pattern: String) -> [NSRange] { - return match(pattern: pattern, excludingSyntaxKinds: SyntaxKind.commentAndStringKinds) + return match(pattern: pattern, excludingSyntaxKinds: SyntaxKind.commentKinds) } } @@ -57,6 +57,22 @@ struct VerticalWhitespaceBetweenCasesRule: Rule { ] private static let violatingToValidExamples: [Example: Example] = [ + Example(""" + switch x { + case 0..<5: + return "x is valid" + ↓ default: + return "x is invalid" + } + """): Example(""" + switch x { + case 0..<5: + return "x is valid" + + default: + return "x is invalid" + } + """), Example(""" switch x { case 0..<5: