Fix empty_enum_arguments false positive when called expression is an identifier (#4600)
This commit is contained in:
parent
d8d5e5bb43
commit
97ba82d740
|
@ -14,7 +14,10 @@
|
|||
|
||||
#### Bug Fixes
|
||||
|
||||
* None.
|
||||
* Fix false positives in `empty_enum_arguments` when the called expression
|
||||
is an identifier or an init call.
|
||||
[Steffen Matthischke](https://github.com/heeaad)
|
||||
[#4597](https://github.com/realm/SwiftLint/issues/4597)
|
||||
|
||||
## 0.50.1: Artisanal Clothes Pegs Fixup Edition
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ struct EmptyEnumArgumentsRule: SwiftSyntaxCorrectableRule, ConfigurationProvider
|
|||
wrapInSwitch("case \"bar\".uppercased()"),
|
||||
wrapInSwitch(variable: "(foo, bar)", "case (_, _) where !something"),
|
||||
wrapInSwitch("case (let f as () -> String)?"),
|
||||
wrapInSwitch("case .bar(Baz())"),
|
||||
wrapInSwitch("case .bar(.init())"),
|
||||
wrapInSwitch("default"),
|
||||
Example("if case .bar = foo {\n}"),
|
||||
Example("guard case .bar = foo else {\n}"),
|
||||
|
@ -65,6 +67,8 @@ struct EmptyEnumArgumentsRule: SwiftSyntaxCorrectableRule, ConfigurationProvider
|
|||
wrapInSwitch("case .bar↓()"),
|
||||
wrapInSwitch("case .bar↓(_), .bar2↓(_)"),
|
||||
wrapInSwitch("case .bar↓() where method() > 2"),
|
||||
wrapInSwitch("case .bar(.baz↓())"),
|
||||
wrapInSwitch("case .bar(.baz↓(_))"),
|
||||
wrapInFunc("case .bar↓(_)"),
|
||||
Example("if case .bar↓(_) = foo {\n}"),
|
||||
Example("guard case .bar↓(_) = foo else {\n}"),
|
||||
|
@ -89,6 +93,8 @@ struct EmptyEnumArgumentsRule: SwiftSyntaxCorrectableRule, ConfigurationProvider
|
|||
wrapInSwitch("case .bar↓()"): wrapInSwitch("case .bar"),
|
||||
wrapInSwitch("case .bar↓(_), .bar2↓(_)"): wrapInSwitch("case .bar, .bar2"),
|
||||
wrapInSwitch("case .bar↓() where method() > 2"): wrapInSwitch("case .bar where method() > 2"),
|
||||
wrapInSwitch("case .bar(.baz↓())"): wrapInSwitch("case .bar(.baz)"),
|
||||
wrapInSwitch("case .bar(.baz↓(_))"): wrapInSwitch("case .bar(.baz)"),
|
||||
wrapInFunc("case .bar↓(_)"): wrapInFunc("case .bar"),
|
||||
Example("if case .bar↓(_) = foo {"): Example("if case .bar = foo {"),
|
||||
Example("guard case .bar↓(_) = foo else {"): Example("guard case .bar = foo else {"),
|
||||
|
@ -193,7 +199,9 @@ private extension PatternSyntax {
|
|||
|
||||
private extension FunctionCallExprSyntax {
|
||||
var argumentsHasViolation: Bool {
|
||||
argumentList.allSatisfy(\.expression.isDiscardAssignmentOrFunction)
|
||||
!calledExpression.is(IdentifierExprSyntax.self) &&
|
||||
calledExpression.as(MemberAccessExprSyntax.self)?.lastToken?.tokenKind != .initKeyword &&
|
||||
argumentList.allSatisfy(\.expression.isDiscardAssignmentOrFunction)
|
||||
}
|
||||
|
||||
var innermostFunctionCall: FunctionCallExprSyntax {
|
||||
|
|
Loading…
Reference in New Issue