realm/SwiftLint

`unowned_variable_capture` fires for `unowned(unsafe)` captures

Open

#6,817 创建于 2026年7月10日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Swift (2,295 fork)batch import
enhancementgood first issue

仓库指标

Star
 (19,570 star)
PR 合并指标
 (平均合并 16天 3小时) (30 天内合并 37 个 PR)

描述

the unowned_variable_capture rule currently fires not only for unowned captures, but also for unowned(unsafe) captures.

IMO this is excessive, as the unsafe addition already makes clear the programmer's intent to trade safety for performance here, and guarantee that the captured value's lifetime will exceed that of the closure.

suggestion: unowned_variable_capture should fire only for unowned captures, but not for unowned(unsafe) ones.

looking at the rule's documentation, it seems like this should be the behaviour anyway, as the "triggering examples" section lists only unowned captures but no unowned(unsafe) ones.

贡献者指南