Use named arguments in multiline Swift closuresSW-R1004
When using closures in Swift with multiple parameters, it is often necessary to split the closure into multiple lines to improve readability. However, if the arguments are not named explicitly, it can be difficult to determine which argument a particular line refers to. This can lead to bugs and make the code harder to understand and maintain.
To improve the readability and maintainability of your code, it is recommended to use named arguments in closures that span multiple lines. This makes it clear which argument each line is referring to, and can make the code much easier to follow.
Using named arguments as shown belo makes the code more readable and easier to understand. It also helps prevent potential bugs by making it clear which argument each line refers to.
Bad Practice
someFunctionThatTakesAClosure {
$0.someMethod()
}
Recommended
someFunctionThatTakesAClosure { argument in
argument.someMethod()
}