SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Rule weak_delegate should not autocorrect

Open ebgraham opened this issue 3 years ago • 3 comments

New Issue Checklist

Describe the bug

The weak_delegate rule is unique in that it actually changes the behavior of the code by autocorrecting weak to delegates. It would be unsafe to apply this rule to a codebase as objects may now released that had previously been retained, leading to undefined behavior and bugs.

This rule is still useful as a warning to developers, but autocorrect should be disabled.

ebgraham avatar Mar 17 '21 19:03 ebgraham

I concur, as this just bit us today. Is there a way to block individual rules from autocorrection?

sjmadsen avatar May 06 '21 20:05 sjmadsen

I agree. We ran into the same problem.

I think the rule triggers on the property being named delegate. In a perfect world where all properties are named correctly, this autocorrection might work. But in case some property is called delegate without actually being a delegate that needs to be weak, this causes errors.

wvteijlingen avatar Oct 05 '21 09:10 wvteijlingen

Any movement on this? Right now we are forced to just disable this rule due to the fact that it is in the autocorrect list which is not ideal.

brianplattenburg-delta avatar May 20 '22 19:05 brianplattenburg-delta