Swiftformat: Braces not formatted with switches containing tuples, extensions, or "required init" function.

Created on 9 Mar 2020  路  2Comments  路  Source: nicklockwood/SwiftFormat

So sorry to bother you again about this, but switch statements with tuples are still not happy (in either direction to allman or back):

switch (firstOctet, secondOctet, thirdOctet, fourthOctet) {
    case (0, 0, 0, 0):
        return .failure(.unableToParseIP)

    case (10, 92, _, _):
        switch thirdOctet
        {

Got ^ after running with allman true.

  switch (firstOctet, secondOctet, thirdOctet, fourthOctet)
  {
  case (0, 0, 0, 0):
    return .failure(.unableToParseIP)

  case (10, 92, _, _):
    switch thirdOctet {

And ^ when I move the brace manually and run without --allman

Similarly for extensions when converting to/from allman style:

extension ViewModel {
    struct ShareOption: Equatable
    {
        let iconName: String
        let label: String
        let action: ShareViewModel.Action
        let accessibilityIdentifier: String
    }
}

Also required init:

    required init?(coder _: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

which does not get formatted in either direction (move the brace down and run without --allman and it does not move back).

Currently using 0.44.4 as installed from Homebrew.

bug

Most helpful comment

@PompeiaPaetenari fixed in 0.44.5

All 2 comments

@PompeiaPaetenari thanks for reporting this, I'll get it fixed for the next release.

@PompeiaPaetenari fixed in 0.44.5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shripada picture shripada  路  3Comments

MaxDesiatov picture MaxDesiatov  路  3Comments

shawnkoh picture shawnkoh  路  3Comments

PompeiaPaetenari picture PompeiaPaetenari  路  4Comments

meherkasam picture meherkasam  路  3Comments