Empty Parameters

ID

swift.empty_parameters

Severity

info

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

Swift

Tags

code-smell, style

Description

Reports a function type written as (Void) → T. The idiomatic Swift spelling for "function taking no arguments" is () → T.

typealias Bad = (Void) -> Int     // FLAW
func f(_ cb: (Void) -> Int) {}    // FLAW

typealias Good = () -> Int        // OK
func g(_ cb: (Int) -> Int) {}     // OK

Rationale

The Void type is just an alias for the empty tuple (). Using it in a parameter position confuses readers and triggers compiler warnings on recent Swift versions.

Remediation

Replace (Void) → T with () → T.

typealias Callback = () -> Int