SwiftLint
SwiftLint copied to clipboard
Validate that self is only used in escaping closures and conflicts
Use of self should be limited to escaping closures and scopes in which other declarations conflict.
Counterpart of #321
:+1:
Love this. It would make searching for ref-cycles quiet a bit easier... :-)
I could find the "explicit_self" rule but I couldn't find the identifier for this one.
Anyone could help me with finding it ?
Thanks!
Anyone could help me with finding it ?
Doesn't exist yet. If anyone would like to build this rule, please go ahead!
Any update on this?
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
Reopening, as there is still demand for this rule based on #3579 and prior comments on 2020.
Would love to see that implemented.
Any status update on this "implicit_self" rule inclusion? 🤔
Thanks
bump - my team would find this rule to be super useful ❤️
Bumptiybumpbump.
Any status updates on this issue? I think we all want it ❤️
Any updates on this?
Has this been implemented already? I would love to have this rule in SwiftLint!
hello, bump any updates on the concerns/challenges of implementing this?
Bumpbumpbump part 2?
Bump. FYI https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md
I've implemented parts for this rule in #4911. As mentioned there, what's missing ~~are two cases~~ is one case:
- ~~Weakly captured
selfwith explicit unwrapping according to SE-0365~~ - Implicit
selfin classes when the closure isn't@escaping
~~These~~ It can be implemented in a later step (probably as a separate Analyzer rule). I didn't want to make the first implementation overly complex and rather gather your feedback on other cases I might have missed.
Please have a look into the PR and let me know which other test cases you can think of, what I've missed or what doesn't work like the rule assumes!
Closing this as completed. The remaining part "implicit self in classes when the closure isn't @escaping" is requested by #4964.