nicklockwood / SwiftFormat

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

Add `—nilinit` for `redundantNilInit` rule #1679

Closed rakuyoMo closed 2 months ago

rakuyoMo commented 2 months ago

The branch is wrong and I noticed that I should commit to the develop branch. I will close this PR and open another one.

Added —nilinit option to redundantNilInit rule, its value includes insert and remove. Among them, remove is consistent with the previous logic, and insert is a new logic. It will add nil as the default value after the optional value type according to the opposite rules of remove.

I did not implement the properties-only option mentioned in the issue, firstly because I did not need it, and secondly because I was not familiar enough with this project.

I added documentation and test cases and all of them passed.

This is my first PR for this project. If I did something wrong or if there is anything else that needs to be modified, please let me know.

rakuyoMo commented 2 months ago

The branch is wrong and I noticed that I should commit to the develop branch. I will close this PR and open another one.

nicklockwood commented 2 months ago

The branch is wrong and I noticed that I should commit to the develop branch. I will close this PR and open another one.

Thank you! (though for future reference I can fix that at my end)