Swiftlint: Colon rule doesn't take into account associated values in enum

Created on 23 Jan 2019  路  3Comments  路  Source: realm/SwiftLint

New Issue Checklist

Describe the bug

I have the colon rule enabled and I expect it to fail when an associated value declared in an enum case doesn't insert the space between the identifier and the type. As of version 0.30.0, SwiftLint doesn't not fail.

// This does not trigger a violation:
enum Token {
    case invalid
    case valid(token:String)
}

Environment

  • SwiftLint version: 0.30.0
  • Installation method used: binary
  • Paste your configuration file:
opt_in_rules:
  - colon
  • Are you using nested configurations?
    No
  • Which Xcode version are you using (check xcode-select -p)? Xcode 10.1
SourceKit issue bug

Most helpful comment

https://github.com/apple/swift/pull/22090 was merged, so this should be fixed in a future Swift release (but not in 5.0).

All 3 comments

This seems a bug in SourceKit.

enum A {
    case b(c: String)
}

Running sourcekitten syntax --file file.swift

[
  {
    "length" : 4,
    "offset" : 0,
    "type" : "source.lang.swift.syntaxtype.keyword"
  },
  {
    "length" : 1,
    "offset" : 5,
    "type" : "source.lang.swift.syntaxtype.identifier"
  },
  {
    "length" : 4,
    "offset" : 13,
    "type" : "source.lang.swift.syntaxtype.keyword"
  },
  {
    "length" : 1,
    "offset" : 18,
    "type" : "source.lang.swift.syntaxtype.identifier"
  },
  {
    "length" : 1,
    "offset" : 20,
    "type" : "source.lang.swift.syntaxtype.identifier"
  },
  {
    "length" : 6,
    "offset" : 23,
    "type" : "source.lang.swift.syntaxtype.identifier"
  }
]

Filled SR-9740 to track this.

https://github.com/apple/swift/pull/22090 was merged, so this should be fixed in a future Swift release (but not in 5.0).

This was fixed as part of Swift 5.1 馃帀

Was this page helpful?
0 / 5 - 0 ratings