New Issue Checklist
Bug Description
The explicit_self analyzer rule reports a violation (“Instance variables and functions should be explicitly accessed with self.”) even when the member is already accessed with self. inside string interpolation \(...) (and the same pattern with raw-string interpolation \#(...)).
Expected: No violation; self is explicit.
Actual: explicit_self reports a violation (false positive).
explicit_self only runs with swiftlint analyze (compiler invocations required), not swiftlint lint.
Minimal example:
class StringInterpolation {
let foo = "foo"
var description: String {
return "StringInterpolation{foo: \(self.foo)}"
}
var rawStringLiteral: String {
return #"StringInterpolation{foo: \#(self.foo)} using "raw" string literals."#
}
}
Full repro (Swift package, xcodebuild log + analyze): https://github.com/jffmrk/swiftlint-explicit-self-string-interpolation
Example command output:
$ swiftlint analyze --compiler-log-path xcodebuild.log
Analyzing 'StringInterpolation.swift' (1/1)
/Users/jmark/src/github/swiftlint-explicit-self-string-interpolation/Sources/ExplicitSelfStringInterpolationBug/StringInterpolation.swift:5:43: error: Explicit Self Violation: Instance variables and functions should be explicitly accessed with 'self.' (explicit_self)
/Users/jmark/src/github/swiftlint-explicit-self-string-interpolation/Sources/ExplicitSelfStringInterpolationBug/StringInterpolation.swift:9:45: error: Explicit Self Violation: Instance variables and functions should be explicitly accessed with 'self.' (explicit_self)
(Line/column may vary slightly by Swift/Xcode version.)
Environment
- SwiftLint version (run
swiftlint version to be sure): 0.63.2
- Xcode version (run
xcodebuild -version to be sure): Xcode 26.4 (Build version 17E192)
- Installation method used (Homebrew, CocoaPods, building from source, etc): Homebrew (
/opt/homebrew/bin/swiftlint)
- Configuration file:
analyzer_rules:
- explicit_self
explicit_self:
severity: error
Are you using nested configurations? No — single .swiftlint.yml at the repository root.
New Issue Checklist
Bug Description
The
explicit_selfanalyzer rule reports a violation (“Instance variables and functions should be explicitly accessed withself.”) even when the member is already accessed withself.inside string interpolation\(...)(and the same pattern with raw-string interpolation\#(...)).Expected: No violation;
selfis explicit.Actual:
explicit_selfreports a violation (false positive).explicit_selfonly runs withswiftlint analyze(compiler invocations required), notswiftlint lint.Minimal example:
Full repro (Swift package,
xcodebuildlog + analyze): https://github.com/jffmrk/swiftlint-explicit-self-string-interpolationExample command output:
(Line/column may vary slightly by Swift/Xcode version.)
Environment
swiftlint versionto be sure): 0.63.2xcodebuild -versionto be sure): Xcode 26.4 (Build version 17E192)/opt/homebrew/bin/swiftlint)Are you using nested configurations? No — single
.swiftlint.ymlat the repository root.