nicklockwood / SwiftFormat

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

Which rule is causing it to rename userId to userID? #1853

Closed Jason-Abbott closed 2 months ago

Jason-Abbott commented 2 months ago

I’ve apparently gone blind from looking too many times at the rules but cannot find the one that is causing it to rename (and thus break) variables.

These are the names of fields from an API so the names are not up to me. I can // swiftformat:disable all but I’d rather just disable whatever rule this is. And honestly, I can’t think of a time when I’d want any tool to change my variable names.

Jason-Abbott commented 2 months ago

I knew it: it only took asking for me to figure out. It’s the “acronyms” rule.

nicklockwood commented 2 months ago

@Jason-Abbott I'm glad you found it. The acronyms rule is disabled by default though, so I'm slightly confused as to how you had this enabled if you didn't want it?

If you are using --enable all or something like that I would advise against it, as the rules that are disabled by default have a higher likelihood of breaking code when used indiscriminately

Jason-Abbott commented 1 month ago

The fault lies with past-self who was just learning Swift a couple years ago, coming from languages where the standard for acronyms is otherwise. I must have enabled the setting to get used to the different standard.

Now I’m accustomed to Swift and forgot there even was such a SwiftFormat setting … so, no problem with SwiftFormat at all! I just kept looking for a setting about “rename” or “variable” and coming up empty.