Closed orchetect closed 2 years ago
Have you set the --swiftversion
? It must be set to 5.1 or higher for this rule to be enabled.
Ah you are correct. Swift version is set to auto.
Which raises another question: when invoked within Xcode using the source editor plugin, does it have any way to ascertain Swift version that is used in the current file? I'm not sure if that kind of metadata is available for source editor plugins.
I would assume the canonical way to solve this is to have .swiftformat files set up in every project and define the Swift version within it. Then have the Xcode plugin set to Infer Options Automatically.
Which raises another question: when invoked within Xcode using the source editor plugin, does it have any way to ascertain Swift version that is used in the current file? I'm not sure if that kind of metadata is available for source editor plugins.
It doesn't have any way to do this, and Xcode doesn't expose it. I might be able to infer it based on certain heuristics, but I don't attempt to do that currently.
I would assume the canonical way to solve this is to have .swiftformat files set up in every project and define the Swift version within it. Then have the Xcode plugin set to Infer Options Automatically.
That's generally how it works, however the plugin can't read the .swiftformat file due to sandboxing restrictions, so it has to be configured separately (there is a neat workaround for this though using XPC that will hopefully land in the next major release).
Thank you for the clarifications. ❤️
SwiftFormat 0.49.14 Xcode 14 beta 5
With SwiftFormat reset to default settings (which has
redundantReturn
enabled), the following code is left intact as-is.The expectation would be that the
get { }
block would be simplified to: