-
Notifications
You must be signed in to change notification settings - Fork 627
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
Is there a way to enforce Allman bracing in closures AND functions/classes/structs? #406
Comments
@ZoeESummers this is slightly improved in version 0.45.0. Allman indenting is now enforced for closures, however the arguments are not auto-wrapped onto the next line, and the |
Thank you! xXx
Stay safe.
Regards
Zoe
… On 30 Jul 2020, at 23:23, Nick Lockwood ***@***.***> wrote:
@ZoeESummers <https://github.com/ZoeESummers> this is slightly improved in version 0.45.0. Allman indenting is now enforced for closures, however the arguments are not auto-wrapped onto the next line, and the in is not yet treated as a new scope.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#406 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAT7XPNM4BSWQV2SUSMJDJTR6HXHBANCNFSM4HDXJDJA>.
|
I found this new behavior perturbating the allman setting enabled creates lots of issue with Observable it creates weird formatting now we used to fix manually
when a "in" is present, allman should not be enforced to have proper alignment |
@altagir from what you've pasted, it seems that the problem is not that someObservable
.switchMap { $0.syncDone }
.switchMap
{ _ -> Observable<Int> in
...
} |
@nicklockwood
is there some options I specified which creates that ? before latest version, I used to put the "param in" on same line as { thanks |
@altagir I'm pretty sure it's a bug, not something you did. I'll investigate. |
@nicklockwood
|
@altagir did you build the CLI from source, or just run the binary in the develop branch? The binary hasn't been updated. |
@altagir Oh wait, it seems there is still an issue. The code I tested was func foo()
{
return SessionManager
.shared
.validateSession()
.switchMap
{ _ -> Observable<SomeEntity> in
someCode()
}
.switchMap
{
otherCode()
}
} Which formats correctly. But if you remove the outer function it seems to be treated differently. I'd assume that doesn't arise very often in real (non-example) code, but I'll fix it anyway. Thanks for flagging it. |
I did build from source |
Thanks for the work Nick. Do you know if this all works correctly in SwiftUI with its awful syntax? |
Good question. I've done some testing with SwiftUI, but not with SwiftUI + Allman-style. I'll make sure to add some more tests around that. If you have any samples to share that would be helpful. |
@nicklockwood this is my config --allman true |
@altagir that's very strange. I have that exact example in the Snapshots/Issues/406.swift file and it's working correctly (even if I include all options you've specified). Is there any other code in the file? Or perhaps some other configuration you are setting that might be relevant? |
@altagir maybe try running it again with --cache clear ? |
@nicklockwood still same result :/ even without config file (not allman) |
@altagir and with --cache clear? |
@nicklockwood |
definitely :)
|
@altagir unfortunately I can't find any explanation for this. There must be some difference with how you are running it, but I can't imagine what it could be. |
@altagir is this working correctly for you in the released version 0.45.4? |
@nicklockwood I see a weird thing though with other calls... like Async.main |
Hmm, I probably need to special-case this for Allman style. I'll fix that in the next version. |
@altagir fixed in 0.45.6. |
@nicklockwood |
I would very much like to ask for a rule / set of rules that force Allman braces on every pair of {} including closures and 'one liners'.
I thank you for taking a look at the extensive and I would argue complete set of rules and code formatting built into App Code, as discussed in another issue, and to that I would ask that for our little team, we like / prefer that everything is in Allman even 'one liners'.
Add to that we have. a specific layout of closures (using the long format in all cases) e.g.
where you can see 'in' becomes a brace type rule itself.
Do you think there is any hope your application could help?
The text was updated successfully, but these errors were encountered: