-
Notifications
You must be signed in to change notification settings - Fork 439
Omit explicit returns where possible #2146
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
Omit explicit returns where possible #2146
Conversation
Personally I'm not in favor of omitting returns. But a normal variable or function need a return IMO |
I'm only a beginner in Swift, but so far omitting returns feels good in:
But, I agree that making this a mandated format might not work well in situations where explicit return keywords make the code much more readable. While a lot of swift-syntax code are small functions, and they look pretty nice without So, that PR is for demonstration purposes. If we chose to enable the rule, we can do so at any point in the future. |
Just a general note about |
I would personally advocate for merging. I might be a bit biased since I'm accustomed to omitting the |
Big same here. |
This commit sets up `.swift-format` rule to omit returns.
40ab696
to
aea4ba6
Compare
I've rebased this PR so we can review this with ordered imports and other improvements merged in. It's growing on me, to be honest. Should I perhaps start a topic in swift forums to pitch this and get more feedback from the community, @ahoppen? |
I’ll gather some feedback on this internally and come back to you in the next week-ish. I’m also very hesitant to merge this as-is. |
I just had another conversation about this and we don’t want this change for now. If there was an official Swift API design guideline to follow regarding when to omit |
Motivation
A separate formatting PR to make space for @Matejkob and @ahoppen and @kimdv to review how our codebase would look with omitting
return
statements where it's possible, a follow-up to #2136. Since this topic might spawn a longer discussion, I've put that rule in a separate PR.Changes
OmitExplicitReturns
swift-format
rule to.swift-format