I'm setting a value to one of two localized strings with a ternary operator like so:
let statesTitle = compactEnabled ? Localized.Titles.additionalStates : Localized.Titles.stateLicenses
And receiving the SwiftLint colon violation warning:
Colon violation: colons should be next to the identifier when specifying a type and next to the key in dictionary literals.
Of course, neither of those situations apply to my above code.
I couldn't reproduce it with this snippet
$ echo "let statesTitle = compactEnabled ? Localized.Titles.additionalStates : Localized.Titles.stateLicenses" | swiftlint lint --use-stdin --no-cache --enable-all-rules
Done linting! Found 0 violations, 0 serious in 1 file.
@nevillco hi, I'm just following up on this, how can we reproduce this?
Closing due lack of activity.
@marcelofabri I'm experiencing this same issue on the current latest version.
$ swiftlint version
0.21.0
The following code triggers the colon rule:
struct FooBar {
static let foo = true
static let bar = false
func baz(lhs: Int, rhs: Int) -> Bool {
typealias Type = FooBar
return lhs > rhs ? Type.foo : Type.bar
}
}
Error:

@vfn Thanks for the sample example. I could reproduce it with 0.21.0 as well.
Here's a reduced version of the snippet that still triggers the warning:
func baz(lhs: Int, rhs: Int) -> Bool {
typealias Type = FooBar
return lhs > rhs ? foo : Type.bar
}
I just took a look at the bug and found something weird.
SourceKitten parses Type.foo : Type.bar respectively in a following manner
syntaxtype.identifier <- 鉂搒hould be typeidentifiersyntaxtype.typeidentifierfoo <- 鉂搒hould be Type.fooType.barBut even if SourceKitten is able to correctly parse the two tokens as typeidentifiers, the switch case in ColonRule+Type.swift considers (.typeidentifier, .typeidentifier) as not valid kinds.
Any ideas??
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
Most helpful comment
@vfn Thanks for the sample example. I could reproduce it with 0.21.0 as well.
Here's a reduced version of the snippet that still triggers the warning: