nicklockwood / SwiftFormat

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

Fix conditionalAssignment bugs with @unknown default cases #1623

Closed calda closed 5 months ago

calda commented 5 months ago

This PR fixes some bugs in how the conditionalAssignment rule handled @unknown default cases, which could result in build failures. For example:

let foo: Foo
switch condition {
case .foo:
  foo = Foo("foo")
case .bar:
  foo = Foo("bar")
@unknown default:
  foo = Foo("default")
}

was being converted to:

let foo = switch condition {
case .foo:
  Foo("foo")
case .bar:
  Foo("bar")
@unknown default:
  foo = Foo("default")
}
codecov[bot] commented 5 months ago

Codecov Report

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

Comparison is base (b1eee35) 95.12% compared to head (d762d00) 95.17%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1623 +/- ## =========================================== + Coverage 95.12% 95.17% +0.04% =========================================== Files 20 20 Lines 22317 22333 +16 =========================================== + Hits 21230 21255 +25 + Misses 1087 1078 -9 ```

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