Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Trigger implicit_getter even if the getter is mutating #1589

Closed
rraphaeldev opened this issue May 31, 2017 · 2 comments
Closed

Trigger implicit_getter even if the getter is mutating #1589

rraphaeldev opened this issue May 31, 2017 · 2 comments
Labels
enhancement Ideas for improvements of existing features and rules.

Comments

@rraphaeldev
Copy link

rraphaeldev commented May 31, 2017

In case of a mutating getter, the get keyword must be specified to add the mutating behavior but this trigger the implicit_getter warning.

struct Counter {
  private var count: Int
  
  init(start: Int = 0) {
    self.count = start
  }
  
  var next: Int? {
    mutating get { // warning: Implicit Getter Violation: Computed read-only properties should avoid using the get keyword. (implicit_getter)
      defer {
        self.count += 1
      }
      
      return self.count
    }
  }
}

Edit: swiftlint version: 0.19.0

@marcelofabri marcelofabri added the enhancement Ideas for improvements of existing features and rules. label May 31, 2017
@marcelofabri
Copy link
Collaborator

Similar to #1309

@marcelofabri
Copy link
Collaborator

Implemented in #1678.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

2 participants