nicklockwood / SwiftFormat

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

Fix redundantInit bug in ternary operators #1683

Closed calda closed 2 months ago

calda commented 2 months ago

This PR fixes a bug in the redundantInit rule for .init calls in ternary operators. It was unexpectedly converting code like:

let bar: Bar = (foo.isBar && bar.isBaaz) ? .init() : nil

to

let bar: Bar = (foo.isBar && bar.isBaaz) ? () : nil
codecov[bot] commented 2 months ago

Codecov Report

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

Project coverage is 95.20%. Comparing base (4e3bd75) to head (72ab6c6).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1683 +/- ## =========================================== + Coverage 92.78% 95.20% +2.41% =========================================== Files 20 20 Lines 21162 22945 +1783 =========================================== + Hits 19636 21845 +2209 + Misses 1526 1100 -426 ```

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