realm / realm/SwiftLint

Vertical Whitespace in between functions

Open
#2,526 14 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

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
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named in the issue. Start by locating SwiftLint's vertical-whitespace rule and its configuration, then determine how separate limits for logical blocks and function or class boundaries should be represented; done means the example can be configured and inconsistent spacing is reported correctly.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.