Add optional rule to prevent empty lines at the start of methods or closures
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
So far we have vertical_whitespace with the max_empty_lines parameter.
There are plenty of places where empty lines are good to increase grouping.
One thing we have observed though and would like to prevent in our projects are empty lines at the beginning, like in
func startDoingStuff() -> Result {
print("Now doing stuff")
// ...
return someResult
}
or
[0...1].map { number in
print("number: \(number)")
// ...
return number* number
}
we don't think there is any reason to allow empty lines at the start of methods so I would like to propose a new rule disallowing this.
I'm about to make a PR too, but since I haven't used sourcery yet I might need a few minutes to get it right (and make all tests pass).
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 with SwiftLint's existing vertical_whitespace rule and its tests, then trace how an optional rule is configured and applied to methods and closures. Done means leading empty lines are rejected when enabled while allowed internal grouping remains valid, with tests covering both methods and closures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100