Empty Enum Arguments
ID |
swift.empty_enum_arguments |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Swift |
Tags |
code-smell, redundancy |
Description
Reports an enum-case pattern of the form .foo() or Color.red() with
an empty parenthesized argument list. Patterns match by name; the empty
parens add nothing.
switch x {
case .start(): // FLAW
...
case .retry(let n): // OK — binds an associated value
...
case .stop: // OK — no parens
...
}
Rationale
The empty-tuple pattern is legal but confusing — readers expect the parens to bind associated values. Dropping them makes the pattern look like every other case without associated data.