Raw Value for Camel Cased Codable Enum

Camel cased cases of Codable String enums should have raw values

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

Non Triggering Examples

enum Numbers: Codable {
  case int(Int)
  case short(Int16)
}
enum Numbers: Int, Codable {
  case one = 1
  case two = 2
}
enum Numbers: Double, Codable {
  case one = 1.1
  case two = 2.2
}
enum Numbers: String, Codable {
  case one = "one"
  case two = "two"
}
enum Status: String, Codable {
    case OK, ACCEPTABLE
}
enum Status: String, Codable {
    case ok
    case maybeAcceptable = "maybe_acceptable"
}
enum Status: String {
    case ok
    case notAcceptable
    case maybeAcceptable = "maybe_acceptable"
}
enum Status: Int, Codable {
    case ok
    case notAcceptable
    case maybeAcceptable = -1
}

Triggering Examples

enum Status: String, Codable {
    case ok
    case notAcceptable
    case maybeAcceptable = "maybe_acceptable"
}
enum Status: String, Decodable {
   case ok
   case notAcceptable
   case maybeAcceptable = "maybe_acceptable"
}
enum Status: String, Encodable {
   case ok
   case notAcceptable
   case maybeAcceptable = "maybe_acceptable"
}
enum Status: String, Codable {
    case ok
    case notAcceptable
    case maybeAcceptable = "maybe_acceptable"
}