Rule Request: guard self
(vs weakSelf, strongSelf) #2495
Closed
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
New rule request
- Why should this rule be added?
Since Swift 4.2 we can now do guard let self = self
instead of guard let strongSelf
, guad let weakSelf
, guard let 'self'
and all other sort of oddities. I'd like to enforce that.
- Provide several examples of what would and wouldn't trigger violations.
Trigger:
if let `self` = self
guard let `self` = self
guard let strongSelf = self
guard let [anything not "self"] = self
Doesn't trigger:
if let self = self
guard let self = self
guard let self = [anytime this is self]
-
Should the rule be configurable, if so what parameters should be configurable?
I don't think so. -
Should the rule be opt-in or enabled by default? Why?
Opt-in