Unneeded Parentheses in Closure Argument
Parentheses are not needed when declaring closure arguments
- Identifier:
unneeded_parentheses_in_closure_argument
- Enabled by default: No
- Supports autocorrection: Yes
- Kind: style
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning
Non Triggering Examples
let foo = { (bar: Int) in }
let foo = { bar, _ in }
let foo = { bar in }
let foo = { bar -> Bool in return true }
DispatchQueue.main.async { () -> Void in
doSomething()
}
Triggering Examples
call(arg: { ↓(bar) in })
call(arg: { ↓(bar, _) in })
let foo = { ↓(bar) -> Bool in return true }
foo.map { ($0, $0) }.forEach { ↓(x, y) in }
foo.bar { [weak self] ↓(x, y) in }
[].first { ↓(temp) in
[].first { ↓(temp) in
[].first { ↓(temp) in
_ = temp
return false
}
return false
}
return false
}
[].first { temp in
[].first { ↓(temp) in
[].first { ↓(temp) in
_ = temp
return false
}
return false
}
return false
}