@@ -44,7 +44,9 @@ public struct EmptyEnumArgumentsRule: SubstitutionCorrectableASTRule, Configurat
4444 wrapInSwitch ( " case (let f as () -> String)? " ) ,
4545 wrapInSwitch ( " default " ) ,
4646 Example ( " if case .bar = foo { \n } " ) ,
47- Example ( " guard case .bar = foo else { \n } " )
47+ Example ( " guard case .bar = foo else { \n } " ) ,
48+ Example ( " if foo == .bar() {} " ) ,
49+ Example ( " guard foo == .bar() else { return } " )
4850 ] ,
4951 triggeringExamples: [
5052 wrapInSwitch ( " case .bar↓(_) " ) ,
@@ -53,7 +55,9 @@ public struct EmptyEnumArgumentsRule: SubstitutionCorrectableASTRule, Configurat
5355 wrapInSwitch ( " case .bar↓() where method() > 2 " ) ,
5456 wrapInFunc ( " case .bar↓(_) " ) ,
5557 Example ( " if case .bar↓(_) = foo { \n } " ) ,
56- Example ( " guard case .bar↓(_) = foo else { \n } " )
58+ Example ( " guard case .bar↓(_) = foo else { \n } " ) ,
59+ Example ( " if case .bar↓() = foo { \n } " ) ,
60+ Example ( " guard case .bar↓() = foo else { \n } " )
5761 ] ,
5862 corrections: [
5963 wrapInSwitch ( " case .bar↓(_) " ) : wrapInSwitch ( " case .bar " ) ,
@@ -85,6 +89,7 @@ public struct EmptyEnumArgumentsRule: SubstitutionCorrectableASTRule, Configurat
8589 return [ ]
8690 }
8791
92+ let needsCase = kind == . if || kind == . guard
8893 let contents = file. stringView
8994
9095 let callsRanges = dictionary. substructure. compactMap { dict -> NSRange ? in
@@ -127,6 +132,10 @@ public struct EmptyEnumArgumentsRule: SubstitutionCorrectableASTRule, Configurat
127132 }
128133 }
129134
135+ if needsCase, file. match ( pattern: " \\ bcase \\ b " , with: [ . keyword] , range: caseRange) . isEmpty {
136+ return nil
137+ }
138+
130139 if callsRanges. contains ( where: parenthesesRange. intersects) {
131140 return nil
132141 }
0 commit comments