-
Notifications
You must be signed in to change notification settings - Fork 637
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
Support comments when removing spaces between chained functions #1723
Support comments when removing spaces between chained functions #1723
Conversation
Sources/Rules.swift
Outdated
let commentIndex = formatter.index(of: .nonSpaceOrLinebreak, after: endOfLine) | ||
{ | ||
let startOfLine = formatter.startOfLine(at: commentIndex) |
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.
Maybe this name could be improved, since this next token isn't always a comment. This could also be a good place to mention why we're doing this:
let commentIndex = formatter.index(of: .nonSpaceOrLinebreak, after: endOfLine) | |
{ | |
let startOfLine = formatter.startOfLine(at: commentIndex) | |
// Make sure to preserve any code comment between the two lines | |
let nextTokenOrComment = formatter.index(of: .nonSpaceOrLinebreak, after: endOfLine) | |
{ | |
let startOfLine = formatter.startOfLine(at: nextTokenOrComment) |
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.
Added!
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!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1723 +/- ##
===========================================
+ Coverage 95.19% 95.23% +0.03%
===========================================
Files 20 20
Lines 23248 23250 +2
===========================================
+ Hits 22131 22141 +10
+ Misses 1117 1109 -8 ☔ View full report in Codecov by Sentry. |
This looks good, thanks! I'm wondering if this should be put behind some sort of option though, in case there are scenarios where a developer deliberately wanted to leave a blank line above commented methods in the chain but remove them otherwise? |
Updating the
blankLinesBetweenChainedFunctions
rule to take comments into account when removing blank lines between chained functions.So this:
Will turn into:
cc @calda