Void Return

Prefer -> Void over -> ()

  • Identifier: void_return
  • Enabled by default: Yes
  • Supports autocorrection: Yes
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration: warning

Non Triggering Examples

let abc: () -> Void = {}

let abc: () -> (VoidVoid) = {}

func foo(completion: () -> Void)

let foo: (ConfigurationTests) -> () throws -> Void

let foo: (ConfigurationTests) ->   () throws -> Void

let foo: (ConfigurationTests) ->() throws -> Void

let foo: (ConfigurationTests) -> () -> Void

let foo: () -> () async -> Void

let foo: () -> () async throws -> Void

let foo: () -> () async -> Void

func foo() -> () async throws -> Void {}

func foo() async throws -> () async -> Void { return {} }

Triggering Examples

let abc: () -> () = {}

let abc: () -> (Void) = {}

let abc: () -> (   Void ) = {}

func foo(completion: () -> ())

func foo(completion: () -> (   ))

func foo(completion: () -> (Void))

let foo: (ConfigurationTests) -> () throws -> ()

func foo() async -> ()

func foo() async throws -> ()