-
Notifications
You must be signed in to change notification settings - Fork 323
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 rule to remove blank lines between chained functions #272
Add rule to remove blank lines between chained functions #272
Conversation
} | ||
``` | ||
|
||
</details> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule does not remove this empty space if there is a comment in between chained functions. Running the linter will leave this code as-is.
let planets = ["Mercury", "Venus", "Earth", "Mars"] var transformedPlanetNames: [String] { planets .map { $0.uppercased() } // Making names uppercase // Adding excitement with an exclamation mark .map { $0 + "!" } }
Is this exception necessary? I'd prefer we not allow this, and for consistency remove the blank line here as well.
Looking at the PR that introduced this SwiftFormat rule, I don't see any indication that this behavior was implemented intentionally. It would be easy to update the SwiftFormat rule to handle this case and remove this blank line as well.
What do you think @mannylopez?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help updating the rule. Here's the SwiftFormat PR to get rid of this exception: nicklockwood/SwiftFormat#1723
@calda nicklockwood/SwiftFormat#1723 merged overnight. Do you think this PR is ready to merge as well? |
We currently wait to merge until about one week after announcing the proposal review so everyone has a chance to share their feedback (so, we can merge this on Thursday or Friday). We'll also want to update the SwiftFormat version in this repo to include your bug fix. I'm working on instructions for how to do that, which I'll share in a bit. |
ah, that's right! Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks great, and very strong support on Slack.
Summary
This PR proposes adding a rule that removes spaces between chained functions (blankLinesBetweenChainedFunctions )
Reasoning
Improves readability and maintainability, making it easier to see the sequence of functions that are applied to the object.
Examples
Note
After nicklockwood/SwiftFormat#1723 merges, the rule will also apply to cases where there is a comment between chained functions.
Test
Confirmed that running the linter with
--rules blankLinesBetweenChainedFunctions
turned on does remove the extra space