Duplicate Enum Cases

Enum shouldn’t contain multiple cases with the same name

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

Non Triggering Examples

enum PictureImport {
    case addImage(image: UIImage)
    case addData(data: Data)
}
enum A {
    case add(image: UIImage)
}
enum B {
    case add(image: UIImage)
}
enum Tag: String {
#if CONFIG_A
    case value = "CONFIG_A"
#elseif CONFIG_B
    case value = "CONFIG_B"
#else
    case value = "CONFIG_DEFAULT"
#endif
}
enum Target {
#if os(iOS)
  case file
#else
  case file(URL)
#endif
}

Triggering Examples

enum PictureImport {
    case add(image: UIImage)
    case addURL(url: URL)
    case add(data: Data)
}