Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Request: Newline between function, array, dictionary, tuple parameters #5564

Closed
2 tasks done
kimdv opened this issue May 9, 2024 · 2 comments
Closed
2 tasks done

Comments

@kimdv
Copy link
Contributor

kimdv commented May 9, 2024

New Issue Checklist

New rule request

After I read this proposal I tought it would be nice to have a rule like "if there is more than x parameters in a function/tuple/array/dictionary there must be a newline between".

This rule can also be implemented without this proposal implemented.

The reason for this is makes it easier to review code. So the rule should be opt-in.
There could also be a configuration to state how many parameters there must be before newline is required.

It could also say that the trailing ) should be on a newline.
We could also have a configuration that require the ( to have a trailing newline

Examples:

// Not OK
func foo(bar: Bar, baz: Baz)
func foo(
  bar: Bar,
  baz: Baz)

// OK
func foo(bar: Bar)
func foo(
  bar: Bar,
  baz: Baz
)

Not sure if it should be the same rule, but when calling a function we could also require newline.

Examples:

// Not OK
someClass.foo(bar: "bar", baz: "baz")
someClass.foo(
  bar: "bar",
  baz: "baz")

// OK
someClass.foo(bar: "bar")
someClass.foo(
  bar: "bar",
  baz: "baz"
)
@kimdv
Copy link
Contributor Author

kimdv commented May 9, 2024

If it makes sense and it's a good idea I'm willing to try to implement it

@kimdv
Copy link
Contributor Author

kimdv commented May 12, 2024

Is already in SwiftLint

@kimdv kimdv closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant