nicklockwood / SwiftFormat

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

RedundantGet breaks code if getter can throw #1088

Closed Arthur-Guillaume closed 2 years ago

Arthur-Guillaume commented 2 years ago

Rule RedundantGet break code it the getter of a computed property can throw. example:

enum Endpoint {
  case foo
  var url: URL {
    get throws {
                switch self {
                  case .foo:
                  return try URL(string: "https://my-wonderful-api.com/foo")
                }
  }
}

In this example, get is considered redundant whereas the code won't compile without throws.

nicklockwood commented 2 years ago

@Arthur-Guillaume can you check you're running the latest version of SwiftFormat? AFAIK this was fixed a while ago.

Arthur-Guillaume commented 2 years ago

@nicklockwood thanks for your quick answer.

I was running an old version, update to 0.49 fixed this issue. Sorry about it.