realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.67k stars 2.22k forks source link

Rule weak_delegate should not autocorrect #3577

Closed ebgraham closed 2 years ago

ebgraham commented 3 years ago

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.

sjmadsen commented 3 years ago

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

wvteijlingen commented 3 years ago

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.

brianplattenburg-delta commented 2 years ago

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.