-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Rule Request: Vertical Whitespace Opening/Closing Braces With Configuration #2322
Comments
Did someone realise this functionality by custom rules? |
Any update on this issue? |
I can get it to trigger with the following custom_rules:
What I'd like to do is autocorrect it by adding in another newline where the one newline exists. Any suggestions @marcelofabri ? |
I was looking at possibilities to customize this rule to implement "vertical white space between nested types only". So that enum A { // this line would give an error because there should be one blank line after this
enum B {
}
}
struct S { // however, this is fine
let a: Int
} I ended up making this custom rule which works out pretty well. custom_rules:
vertical_space_between_nested_types:
name: "Vertical space between nested types"
regex: '(class|struct|enum|extension)[^\n]*\{\n[^\n]*(class|struct|enum|extension)'
message: "Nested types should be separated by a blank line"
severity: error
Hopefully this can help someone else like me in need of such functionality. Thanks to everyone involved making SwiftLint project. 👍 |
I would love to have this as well. Anyone looking into making this happen? |
Any updates maybe? |
This is a fantastic idea! I'd also love if it could support a minimum or exact number of blank lines before/after a brace. For example, a code style might require a single blank line after the start of a class/struct/enum/protocol, or it could be optional. I'm not familiar with the internals of SwiftLint — is it feasible for config values to support both numbers and ranges, such as |
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! |
I'm still interested in having this enhancement. |
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! |
This is an annoyingly aggressive bot. Why should people have to keep kicking a bug every 2 months to keep it active? |
I agree @quinntaylor, after seeing the bot in practice for the last few months, I've decided to remove the bot, rationale here: #3529 Consider this one re-opened. |
Should this have a |
This ticket is related to issue #1518 and to PR #2291.
Once #2291 is merged, it'd be good to extend the functionality of the
vertical_whitespace_opening_braces
andvertical_whitespace_closing_braces
so that they can be configured for braces of different types.Why should this rule be added?
These rules are great for function braces, but for class/struct braces it might be good to allow 1 empty line to make the code easier to read.
Provide several examples of what would and wouldn't trigger violations.
Should the rule be configurable, if so what parameters should be configurable?
This is an example of possible configurations for these rules:
The configurations above are just a suggestion, I have only been using this library for a week so there are probably better ways to add such configurations to these rules.
Should the rule be opt-in or enabled by default? Why?
I would enable this rule by default and set
1
as the default forclass
,struct
,protocol
,extension
, and0
forfunc
.The text was updated successfully, but these errors were encountered: