nicklockwood / SwiftFormat

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

Fix edge cases in `forLoop` rule #1494

Closed calda closed 1 year ago

calda commented 1 year ago

This PR fixes several edge cases in the forLoop rule that I missed in #1490.

This PR also adds options to:

  1. not convert anonymous forEach closures to for loops
  2. convert single-line forEach closures to multi-line for loops
codecov[bot] commented 1 year ago

Codecov Report

Merging #1494 (dec6c4d) into develop (1291697) will increase coverage by 0.00%. The diff coverage is 99.46%.

@@            Coverage Diff            @@
##           develop    #1494    +/-   ##
=========================================
  Coverage    95.11%   95.11%            
=========================================
  Files           18       18            
  Lines        20821    20950   +129     
=========================================
+ Hits         19803    19926   +123     
- Misses        1018     1024     +6     
Files Changed Coverage Δ
Sources/ParsingHelpers.swift 96.83% <98.24%> (+0.03%) :arrow_up:
Sources/OptionDescriptor.swift 98.58% <100.00%> (+0.02%) :arrow_up:
Sources/Options.swift 95.71% <100.00%> (+0.03%) :arrow_up:
Sources/Rules.swift 98.41% <100.00%> (+0.01%) :arrow_up:

... and 2 files with indirect coverage changes

calda commented 1 year ago

Rebased on top of the latest develop commit