nicklockwood / SwiftFormat

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

Want to add antonym rules for `redundantNilInit` #1677

Closed rakuyoMo closed 2 months ago

rakuyoMo commented 2 months ago

Our team's norm is that all variables need to be explicitly assigned an initial value, including the special case of Optional. I noticed the redundantNilInit rule and hoped there would be an opposite rule that would automatically add a nil initial value to Optional type values.

nicklockwood commented 2 months ago

Seems reasonable. If you'd be interested in trying to contribute such a rule I'd be happy to accept it, otherwise I'll add it to the backlog

rakuyoMo commented 2 months ago

Seems reasonable. If you'd be interested in trying to contribute such a rule I'd be happy to accept it, otherwise I'll add it to the backlog

I'll try it. Do you recommend adding a new rule, or adding a new parameter to redundantNilInit?

nicklockwood commented 2 months ago

I'll try it. Do you recommend adding a new rule, or adding a new parameter to redundantNilInit?

It should be a new parameter. Probably something like --nilinit insert/remove/properties-only

rakuyoMo commented 2 months ago

Close with https://github.com/nicklockwood/SwiftFormat/pull/1680