Vertical Whitespace Between Cases

Include a single empty line between switch cases

  • Identifier: vertical_whitespace_between_cases
  • Enabled by default: No
  • Supports autocorrection: Yes
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

switch x {

case 0..<5:
    print("x is low")

case 5..<10:
    print("x is high")

default:
    print("x is invalid")

}
switch x {
case .valid:
    print("multiple ...")
    print("... lines")

case .invalid:
    print("multiple ...")
    print("... lines")
}
switch x {
case .valid:
    print("x is valid")

case .invalid:
    print("x is invalid")
}
switch x {
case 0..<5:
    print("x is low")

case 5..<10:
    print("x is high")

default:
    print("x is invalid")
}
switch x {
case 0..<5:
    print("x is valid")

default:
    print("x is invalid")
}
switch x {
case 0..<5:
    return "x is valid"

default:
    return "x is invalid"
}
switch x {
case 0..<5: print("x is low")
case 5..<10: print("x is high")
default: print("x is invalid")
}
switch x {    
case 1:    
    print("one")    

default:    
    print("not one")    
}    

Triggering Examples

switch x {
case .valid:
    print("multiple ...")
    print("... lines")
case .invalid:
    print("multiple ...")
    print("... lines")
}
switch x {
case .valid:
    print("x is valid")
case .invalid:
    print("x is invalid")
}
switch x {
case 0..<5:
    print("x is valid")
default:
    print("x is invalid")
}
switch x {
case 0..<5:
    return "x is valid"
default:
    return "x is invalid"
}