Repository navigation
Conversation
Generated by 🚫 Danger |
01f0fc8 to
cedcca5
Compare
explicit_self false positives around string interpolation
f5e32b7 to
6dfa8fc
Compare
SourceKit can report instance-member refs for text inside string literals, at the open paren of \(...), or with offsets that do not match a simple '.' check. Combine SwiftSyntax static segment ranges with source-text verification for explicit self.<member> spans, and skip bogus offsets at string interpolation open parens. Add non-triggering, triggering, and correction examples for implicit member access inside string interpolation.
6dfa8fc to
12dd5f5
Compare
|
Hey @jffmrk, thanks for bringing this up and sorry for the late response. While reviewing your code, I thought about simplifying the whole rule a lot by making use of your idea to let SwiftSyntax help to find correct positions more reliably. This is what led to #6662. It uses SwiftSyntax to find symbols in the first place and only asks SourceKit about their origin. Doing so, a lot of code could be removed making the rule quite a bit easier to comprehend. I hope you don't mind if we move forward with #6662. I have retained you as a (co-)author in the commit and the changelog entry. |
|
Cool. Thanks! I'll try it out on our code tomorrow. This was Cursor helping me out. |
Let me know about the results. I'll cut a new release shortly after. |
Summary
SourceKit can report misleading instance-member refs for
explicit_selfwhen code uses string literals and\(...)interpolation (e.g. literal text that matches a property name, or bogus offsets at the interpolation open paren).This PR filters those cases using SwiftSyntax static string segments, skips offsets at
\(, and verifies explicitself.` spans in source text.Fixes #6611
Testing
swift test --filter ExplicitSelfRuleGeneratedTestsMade with Cursor