`redundant_self` false positive with Logger
bugacceptable-false-positive
### New Issue Checklist
- [x] I've Updated SwiftLint to the latest version.
- [x] I've searched for [existing GitHub issues](https://github.com/realm/SwiftLint/issues).
### Bug Description
Sample Code
```swift
import os
class Name {
private let test = ""
func testLog() {
Logger(subsystem: "sub", category: "cat").warning("test: \(self.test, privacy: .private(mask: .hash))")
}
}
```
SwiftLint output:
```bash
$ swiftlint
Linting Swift files in current working directory
Linting 'a.swift' (1/1)
~/Desktop/a.swift:7:68: warning: Redundant Self Violation: Explicit use of 'self' is not required (redundant_self)
Done linting! Found 1 violation, 0 serious in 1 file.
```
When removing the `self.` from the `self.test`:
```bash
$ swift a.swift
a.swift:7:68: error: reference to property 'test' in closure requires explicit use of 'self' to make capture semantics explicit
5 |
6 | func testLog() {
7 | Logger(subsystem: "sub", category: "cat").warning("test: \(test, privacy: .private(mask: .hash))")
| |- error: reference to property 'test' in closure requires explicit use of 'self' to make capture semantics explicit
| `- note: reference 'self.' explicitly
8 | }
9 | }
```
### Environment
* SwiftLint version (run `swiftlint version` to be sure): 0.63.2
* Xcode version (run `xcodebuild -version` to be sure): Xcode 26.3 Build version 17C529
* Installation method used (Homebrew, CocoaPods, building from source, etc): Homebrew
* Configuration file:
```yml
opt_in_rules:
- redundant_self
redundant_self:
only_in_closures: false
```
1 条评论