nicklockwood / SwiftFormat

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

wraparguments enforcement using a threshold #1697

Open pafdad opened 1 month ago

pafdad commented 1 month ago

Hello and thank you for SwiftFormat

Using wraparguments, I'd like to be able to enforce a threshold as to the number of arguments that will cause this rule to be enforced.

For instance, in my code-base, if a function takes 1 argument, it's OK for it to be on the same line as the function name itself:

foo("bar") // <--- this should be OK

but if a function has 2 or more arguments, I'd like this rule to be enfoced:

foo("bar", "baz") // <--- this should throw an error

// this should be the correct way of calling the function
foo(
  "bar",
  "baz"
)

What I'm trying to do is to enforce this style throughout the code. Right now even if i have the following rules:

--wraparguments before-first
--wrapparameters before-first
--wrapcollections before-first

A programmer can still write code like this:

foo("bar", "baz")

Any help would be appreciated. Thank you