Standard and Builtin Code formatting tool for Swift

Originator:nacho4d
Number:rdar://19807214 Date Originated:12-Feb-2015
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
 
Summary:
It would be great if a tool for formatting the code in a standard way like golang gofmt (https://golang.org/cmd/gofmt/) for swift.

Why is this necessary?

- In a development team each person will have its own code style. Further more imported external 3rd party libraries will have its own style too. This lead to a messy style through the entire application. --> A formatting tool is needed

- In code reviews will be a bit faster since developers don't need to discuss styling stuff, new engineers might not now the style of the company or team. --> A formatting tools is needed and it must be standard and builtin

For example, as of now we can write:

func method(param: Type) {
    return
}
func method ( param: Type )
{
    return
}
func method(param:Type){return}

And several more.

For objective-c we have clang-format but is not standard and is it not build. Since is it not builtin not everybody knows about it.

Steps to Reproduce:
See Description.

Expected Results:
Have a tool, let's say: "swiftfmt"

Actual Results:
code formatted standardly in a uniform way in the entire swift universe. (When the formatting tools is activated)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!