Enable the weak_delegate SwiftLint rule#21068
Merged
crazytonyli merged 2 commits intotrunkfrom Jul 19, 2023
Merged
Conversation
staskus
approved these changes
Jul 14, 2023
Contributor
There was a problem hiding this comment.
👍 Yes, yes, yes.
For those cases where the "delegate" should be strongly referenced, we can use SwiftLint's swiftlint:disable special code comments to ignore the issue.
Agree. Looking into the future, we should call something a delegate where it behaves as expectedly, especially in iOS ecosystem. This rule will ensure that.
I'm approving the change, the CI will do the rest.
As I understand the plan would be to merge it after dealing with all incorrectly non-weak delegates?
Contributor
Author
Yes. I have addressed all the violations. Once all the PRs (all referenced in #21050) are merged, I'll get this PR out of draft state. |
6b8e224 to
e662c7c
Compare
Contributor
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21068-e662c7c | |
| Version | 22.8 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | e662c7c | |
| App Center Build | jetpack-installable-builds #5431 |
Contributor
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21068-e662c7c | |
| Version | 22.8 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | e662c7c | |
| App Center Build | WPiOS - One-Offs #6404 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #21050.
The
weak_delegateSwiftLint rule reports issues on all strong references to types whose name has 'Delegate' in it. Enabling this SwiftLint rule will help us catching retain cycles.Majority of "delegate" types follow observer pattern, which should be declared as weak references. For those cases where the "delegate" should be strongly referenced, we can use SwiftLint's
swiftlint:disablespecial code comments to ignore the issue.Regression Notes
Potential unintended areas of impact
None.
What I did to test those areas of impact (or what existing automated tests I relied on)
None.
What automated tests I added (or what prevented me from doing so)
None.
PR submission checklist:
RELEASE-NOTES.txtif necessary.UI Changes testing checklist: N/A