Sorted Enum Cases

Enum cases should be sorted

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

Non Triggering Examples

enum foo {
    case a
    case b
    case c
}
enum foo {
    case example
    case exBoyfriend
}
enum foo {
    case a
    case B
    case c
}
enum foo {
    case a, b, c
}
enum foo {
    case a
    case b, c
}
enum foo {
    case a(foo: Foo)
    case b(String), c
}
enum foo {
    case a
    case b, C, d
}
@frozen
enum foo {
    case b
    case a
    case c, f, d
}

Triggering Examples

enum foo {
    ↓case b
    ↓case a
    case c
}
enum foo {
    ↓case B
    ↓case a
    case c
}
enum foo {
    case ↓b, ↓a, c
}
enum foo {
    case ↓B, ↓a, c
}
enum foo {
    ↓case b, c
    ↓case a
}
enum foo {
    case a
    case b, ↓d, ↓c
}
enum foo {
    case a(foo: Foo)
    case ↓c, ↓b(String)
}