nicklockwood / SwiftFormat

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

Fix issue where `redundantInit` didn't work on some complex types #1659

Closed calda closed 3 months ago

calda commented 3 months ago

This PR fixes an issue where the redundantInit rule didn't work on some complex types with nested scopes, like nested collections, collections of tuples, generic types with a collection argument, etc.

Previously it would leave these examples as-is:

let tupleArray = [(key: String, value: Int)].init()
let nestedArray = [[String]].init()
let atomicDictionary = Atomic<[String: Int]>.init()

Now they're corrected as expected:

let tupleArray = [(key: String, value: Int)]()
let nestedArray = [[String]]()
let atomicDictionary = Atomic<[String: Int]>()
codecov[bot] commented 3 months ago

Codecov Report

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

Project coverage is 95.14%. Comparing base (9d99bdc) to head (6f22825). Report is 5 commits behind head on develop.

:exclamation: Current head 6f22825 differs from pull request most recent head 671979a. Consider uploading reports for the commit 671979a to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1659 +/- ## =========================================== - Coverage 95.17% 95.14% -0.03% =========================================== Files 20 20 Lines 22737 22718 -19 =========================================== - Hits 21639 21616 -23 - Misses 1098 1102 +4 ```

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