-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redundant_self_in_closure false positive #5010
Comments
This is a known shortcoming of this rule that must generally be accepted, unfortunately. The reason is that normal SwiftLint rules only operate on the Swift AST without knowing anything about types. The line |
Thank you for your fast answer. |
Well, it's unimportant where the symbol is defined. You can just have let x = 1
self.x = 2 to make the rule fail. The point is that there can be a symbol named class X {
var x = 1
func f(x: Int = 2) {
var x = 3
g {
var x = 4
self.x = x
}
}
func g(_ work: () -> Void) { work() }
} This is valid Swift code with 3 reasons why |
I came up with a way to track all identifiers declared up to a certain statement in the code. With that knowledge, the That is supposed to fix your specific issue and a lot more similar cases. |
New Issue Checklist
Describe the bug
in the typical case where a guard let is used :
affecting a new value to the object property "self.lastTimerCallTime" trigger a false positive and remove the self creating an error since local lastTimerCallTime is immutable
Environment
The text was updated successfully, but these errors were encountered: