redundant_void_return - ApplebaumIan/BitbucketAPI GitHub Wiki

Redundant Void Return

Returning Void in a function declaration is redundant.

  • Identifier: redundant_void_return
  • Enabled by default: Enabled
  • Supports autocorrection: Yes
  • Kind: idiomatic
  • Analyzer rule: No
  • Minimum Swift compiler version: 3.0.0
  • Default configuration: warning

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)
    }
}

Triggering Examples

func foo()↓ -> Void {}

protocol Foo {
  func foo()↓ -> Void
}
func foo()↓ -> () {}

func foo()↓ -> ( ) {}
protocol Foo {
  func foo()↓ -> ()
}