SwiftLint
SwiftLint copied to clipboard
Vertical Whitespace in between functions
I like to have a single empty line in between logical blocks, and two empty lines in between functions, at the top of a class, and at the bottom of a class (between the last function and the class's closing bracket).
In order not to get the warning about having too much vertical whitespace, I had to customize to the rule to allow up to two lines, but that is of course not specific to inside and outside of functions, so SL won't catch such inconsistencies.
It would be nice to be able to customize this.
Example:
// MARK: Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
let myButton = Button
let myTable = Table
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let myButton = Button
let myTable = Table
}
That's absolutely something I'd be in favor of allowing configuring. Is this something you'd be interested in contributing yourself or are you asking for someone else to build this? I'm happy to point you in the right direction if you're unsure where to start.
I’m very interested in helping out and unsure where to start just as much 😄
Thanks —
- Let’s connect on LinkedIn https://www.linkedin.com/in/imdanielspringer/
On Dec 24, 2018, at 5:09 AM, JP Simard [email protected] wrote:
That's absolutely something I'd be in favor of allowing configuring. Is this something you'd be interested in contributing yourself or are you asking for someone else to build this? I'm happy to point you in the right direction if you're unsure where to start.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/realm/SwiftLint/issues/2526#issuecomment-449683691, or mute the thread https://github.com/notifications/unsubscribe-auth/ASWtSUiH4hka4LCu-Fqrh_9Cctk1rGD2ks5u8FNvgaJpZM4ZgDhp.
Here's roughly the steps you'd take to build this:
- Add a configuration option for how many lines of whitespace should be between functions in VerticalWhitespaceConfiguration.swift. This is the file where configuration options for the
vertical_whitespacerule are defined. - In VerticalWhitespaceRule.swift, add a check for your new configuration option and validate that there's the right amount of spacing for the code style you want to enforce.
- Add tests to VerticalWhitespaceRuleTests.swift following how the other tests in that file are set up.
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
Commenting to avoid this issue from being closed since an issue I'm watching for a feature I'd love to have.
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
.
Lack of this feature is the main reason I haven't been using SwiftLint. Perhaps I'll take a try at adding this.
Any progress on this topic?
any update? this seems like many people would want this
What language would a contribution be in?
bump
bump
help