Swift

Swift

Made by DeepSource

Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation SW-R1030

Anti-pattern
Minor

Types that are used solely for hosting static members should be implemented as a caseless enum in Swift.

By using a caseless enum, you explicitly indicate that the type should not be instantiated. This helps prevent accidental creation of instances, which can lead to unnecessary memory allocation and potential misuse of the type.

Bad Practice

struct Math {
  public static let pi = 3.14
}

Recommended

enum Math {
  public static let pi = 3.14
}