SwiftLint
SwiftLint copied to clipboard
`unused-parameter` rule should not trigger on binding closure parameter
New Issue Checklist
- [x] I've Updated SwiftLint to the latest version.
- [x] I've searched for existing GitHub issues.
Bug Description
The rule triggers on $historyItem, but the parameter is kinda used. $historyItem results in a binding, but it also makes it possible to access the normal variable with historyItem implicitly. So even though $historyItem is not directly used, it cannot be removed.
List($history) { $historyItem in
Foo(
url: historyItem.url
)
}
In short, make it not trigger on $-prefixed parameters in a closure.
Environment
- SwiftLint version: 0.56.0
- Xcode version: Xcode 15.4, Build version 15F31d
- Installation method used: Installer
- Configuration file:
only_rules:
- unused_parameter
Since $_ is allowed as a parameter, the same rules used for normal parameters apply here as well. In the example, if any of $historyItem or historyItem is used in the closure block, $historyItem can be considered to be used. If there is no reference at all, it can be replaced with $_ (or $_historyItem once that's implemented).
However, silencing the rule completely for $-prefixed parameters might be too cautious.