`vertical_whitespace_between_cases` considers comments
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Bug Description
Since 0.63, vertical_whitespace_between_cases considers inline comments in whether a newline is needed. For example, previously, this produced no warning with the setting enabled, as the cases were handled in a single line.
switch myEnum {
case .a: print("a")
// Now we handle b.
case .b: print("b")
}
However, now it requires a newline before the comment, despite the fact that the structure of the actual code doesn't trigger the warning.
switch myEnum {
case .a: print("a")
// Now we handle b.
case .b: print("b")
}
It seems to me that only the structure of the switch itself should be considered when determining the newline requirement, as was the case before. If this was an intentional change, perhaps an additional parameter can be added for better control?
Environment
- SwiftLint version: 0.63.0
- Xcode version: 26.2
- Installation method used: CocoaPods
- Configuration file: directly enabled the rule, no configuration yet.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the implementation and tests for the vertical_whitespace_between_cases rule, reproducing the two switch examples from the issue. Add a regression test showing that an inline comment does not require an extra newline when the switch cases themselves remain on one line; done means the original example produces no warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100