nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.62k stars 623 forks source link

Support comments when removing spaces between chained functions #1723

Closed mannylopez closed 3 weeks ago

mannylopez commented 3 weeks ago

Updating the blankLinesBetweenChainedFunctions rule to take comments into account when removing blank lines between chained functions.

So this:


[0, 1, 2]
    .map { $0 * 2 }

    // Multiplies by 3
    .map { $0 * 3 }

Will turn into:

[0, 1, 2]
    .map { $0 * 2 }
    // Multiplies by 3
    .map { $0 * 3 }

cc @calda

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.23%. Comparing base (b0d492f) to head (e8d8656).

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nicklockwood commented 3 weeks ago

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?