Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rules around newlines #548

Closed
Noobish1 opened this issue Feb 18, 2016 · 5 comments · Fixed by #747
Closed

Add rules around newlines #548

Noobish1 opened this issue Feb 18, 2016 · 5 comments · Fixed by #747

Comments

@Noobish1
Copy link

So I hate redundant newlines in our codebase. We've hired some junior developers recently and they have a habit of adding redundant newlines everywhere and we'd love to see warnings/errors when they do this.

a few places they do it:

  • In between functions (we normally have empty line between them)
  • in function bodies (we normally have one empty line between chunks of related code)
  • at the bottom of classes/structs (we normally have no empty lines at the bottom of classes/structs)

Would it be possible to add rules for the above cases?

@brentleyjones
Copy link

In our style guide we have a section that basically reads as:

Grouping

  • Spacing:
    • Leave a single blank line at the start of a type declaration or extension.
    • Leave a single blank line before and after // MARK: or other grouping related comments.
    • Otherwise don't leave whitespace at the beginning or end of a scope.
  • Make liberal use of single blank lines to divide code into logical chunks. Some pre-defined logical chunks are:
    • Functions
    • Commented items

This is similar to @Noobish1's rules. I would love to be able to enforce these via SwiftLint.

@jpsim
Copy link
Collaborator

jpsim commented Feb 24, 2016

This all sounds great to me. I don't think anyone has claimed this ticket as something they were building yet, so anyone should feel free to get started on this!

@brentleyjones
Copy link

Btw, #305 is a duplicate of this now.

@masters3d
Copy link
Contributor

masters3d commented Aug 9, 2016

Do we need a new rule or could TrailingWhitespaceRule be modified to also complain about pure newlines?

@masters3d
Copy link
Contributor

Never mind, this would be confusing with the TrailingNewlineRule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants