Repository navigation
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
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 versionto be sure): 0.63.2 - Xcode version (run
xcodebuild -versionto 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: errorAre you using nested configurations? No — single .swiftlint.yml at the repository root.
Activity
jffmrk commentedon Apr 19, 2026
We just enabled
explicit_selfon our repo, and a lot of false positives showed up under string interpolation.PR with a fix:
#6610