Comma Spacing

There should be no space before and one after any comma

  • Identifier: comma
  • Enabled by default: Yes
  • Supports autocorrection: Yes
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

func abc(a: String, b: String) { }
abc(a: "string", b: "string"
enum a { case a, b, c }
func abc(
  a: String,  // comment
  bcd: String // comment
) {
}
func abc(
  a: String,
  bcd: String
) {
}
#imageLiteral(resourceName: "foo,bar,baz")
kvcStringBuffer.advanced(by: rootKVCLength)
  .storeBytes(of: 0x2E /* '.' */, as: CChar.self)

Triggering Examples

func abc(a: String ,b: String) { }
func abc(a: String ,b: String ,c: String ,d: String) { }
abc(a: "string",b: "string"
enum a { case a ,b }
let result = plus(
    first: 3 , // #683
    second: 4
)
Foo(
  parameter: a.b.c,
  tag: a.d,
  value: a.identifier.flatMap { Int64($0) } ,
  reason: Self.abcd()
)
return Foo(bar: .baz, title: fuzz,
          message: My.Custom.message ,
          another: parameter, doIt: true,
          alignment: .center)
Logger.logError("Hat is too large",  info: [])