trailing_comma - ApplebaumIan/BitbucketAPI GitHub Wiki
Trailing Comma
Trailing commas in arrays and dictionaries should be avoided/enforced.
- Identifier: trailing_comma
- Enabled by default: Enabled
- Supports autocorrection: Yes
- Kind: style
- Analyzer rule: No
- Minimum Swift compiler version: 3.0.0
- Default configuration: warning, mandatory_comma: false
Non Triggering Examples
let foo = [1, 2, 3]
let foo = []
let foo = [:]
let foo = [1: 2, 2: 3]
let foo = [Void]()
let example = [ 1,
2
// 3,
]
foo([1: "\(error)"])
Triggering Examples
let foo = [1, 2, 3β,]
let foo = [1, 2, 3β, ]
let foo = [1, 2, 3 β,]
let foo = [1: 2, 2: 3β, ]
struct Bar {
let foo = [1: 2, 2: 3β, ]
}
let foo = [1, 2, 3β,] + [4, 5, 6β,]
let example = [ 1,
2β,
// 3,
]
let foo = ["ΧΧΧ", "Ξ±Ξ²Ξ³", "πΊπΈ"β,]
class C {
#if true
func f() {
let foo = [1, 2, 3β,]
}
#endif
}
foo([1: "\(error)"β,])