Skip to content

Rule Request: guard self (vs weakSelf, strongSelf) #2495

Closed
@freak4pc

Description

New Issue Checklist

New rule request

  1. 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.

  1. 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]
  1. Should the rule be configurable, if so what parameters should be configurable?
    I don't think so.

  2. Should the rule be opt-in or enabled by default? Why?
    Opt-in

Metadata

Assignees

No one assigned

    Labels

    rule-requestRequests for a new rules.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions