nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.88k stars 638 forks source link

redundantSelf only on property references (not method calls)? #1339

Open JetForMe opened 1 year ago

JetForMe commented 1 year ago

Is there any way to specify something like --redundantSelf properties-only?

nicklockwood commented 1 year ago

@JetForMe there isn't currently. Such a thing wouldn't be too hard to add, with the caveat the SwiftFormat only knows the context of the current file, so it couldn't know if you were using a method declared in another file as a property, e.g.

// file A
class Foo {
  func bar()
}

...

// file B
extension Foo {
  func baz() {
    let quux = self.bar // function used as property
  }
}
JetForMe commented 1 year ago

I think that's a reasonable limitation.