Redundant Void Return
Returning Void in a function declaration is redundant
- Identifier:
redundant_void_return
- Enabled by default: Yes
- Supports autocorrection: Yes
- Kind: idiomatic
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning include_closures true
Non Triggering Examples
func foo() {}
func foo() -> Int {}
func foo() -> Int -> Void {}
func foo() -> VoidResponse
let foo: (Int) -> Void
func foo() -> Int -> () {}
let foo: (Int) -> ()
func foo() -> ()?
func foo() -> ()!
func foo() -> Void?
func foo() -> Void!
struct A {
subscript(key: String) {
print(key)
}
}
//
// include_closures: false
//
doSomething { arg -> Void in
print(arg)
}
Triggering Examples
func foo()↓ -> Void {}
protocol Foo {
func foo()↓ -> Void
}
func foo()↓ -> () {}
func foo()↓ -> ( ) {}
protocol Foo {
func foo()↓ -> ()
}
doSomething { arg↓ -> () in
print(arg)
}
doSomething { arg↓ -> Void in
print(arg)
}