Swift

Swift

Made by DeepSource

Enum should always have unique cases SW-W1007

Bug risk
Critical

Enum should always have unique cases as having multiple cases with the same name can lead to unintended behavior. When cases in enum are not unique, it can cause confusion and make the code difficult to maintain. This is especially true when the cases are mapped to different values. If the same case name is used for different values, it can lead to unexpected results and bugs in the code.

Bad Practice

enum Animal {
    case cat(String)
    case dog(String)
    case cat(Int)
}

Recommended

enum Animal {
    case catName(String)
    case dogName(String)
    case catAge(Int)
}