Required Enum Case

Enums conforming to a specified protocol must implement a specific case(s).

  • Identifier: required_enum_case
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    {Protocol Name}
    KeyValue
    {Case Name 1} {warning|error}
    {Case Name 2} {warning|error}

Non Triggering Examples

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success, error, notConnected
}

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success, error, notConnected(error: Error)
}

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success
    case error
    case notConnected
}

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success
    case error
    case notConnected(error: Error)
}

Triggering Examples

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success, error
}

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success, error
}

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success
    case error
}

//
// NetworkResponsable:
//   error: warning
//   notConnected: warning
//   success: warning
//

enum MyNetworkResponse: String, NetworkResponsable {
    case success
    case error
}