`statement_position` fails on one-line `catch`
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
Assuming uncuddled_else, the following passes validation:
do {
x
}
catch {
y
}
But the following fails validation:
do { x }
catch { y }
This is inconsistent and should be fixed. One-line statements are very beneficial and shouldn't be punished.
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint test.swift
Linting Swift files at paths test.swift
Linting 'test.swift' (1/1)
test.swift:1:8: warning: Statement Position Violation: Else and catch should be on the same line, one space after the previous declaration. (statement_position)
Done linting! Found 1 violation, 0 serious in 1 file.
Environment
- SwiftLint version (run
swiftlint versionto be sure)?0.50.1 - Installation method used (Homebrew, CocoaPods, building from source, etc)?
brew - Paste your configuration file:
statement_position:
statement_mode: uncuddled_else
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
Reproduce the report with the statement_position configuration in test.swift, comparing the multiline and one-line do/catch examples under uncuddled_else. Trace the statement_position rule and its tests, then verify that both forms are handled consistently without the reported violation.
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
- 42/100