opening_brace rule breaks Xcode indentation for multiline function declarations
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
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
If a function declaration has its opening brace on the same line as the func, Xcode is smart enough to indent one "tab" for the body of the function.
However, if the function would span past the 120 character line length limit, if the opening brace is on the same line as the return value or other arguments, Xcode tries to indent by two "tab"s.
This is super frustrating and I've found myself fighting the indentation to resolve the lint violation.
Is it possible to either customize the rule or extend it to handle this case better?
My preferred behavior would be that multiline functions, guard and if statements would have their opening brace on a newline.
Current:
func shortFunctionName(shortParameterName: ShortType) -> ReturnValue {
// Xcode wants to indent to here
}
func someReallyLongFunctionName(
someReallyLongParameterName: SomeType,
anotherReallyLongParameterName: AnotherType)
-> ReturnValue {
// Xcode wants to indent to here
}
Preferred:
func shortFunctionName(shortParameterName: ShortType) -> ReturnValue {
// Xcode wants to indent to here
}
func someReallyLongFunctionName(
someReallyLongParameterName: SomeType,
anotherReallyLongParameterName: AnotherType)
-> ReturnValue
{
// Xcode wants to indent to here
}
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 by locating the opening_brace rule and reviewing how it handles multiline function declarations, including any existing configuration and tests. Compare the current and preferred examples, then define and verify the expected brace placement for multiline functions and related guard or if statements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100