Swiftlint: Identifiable conformation triggers identifier_name rule

Created on 26 Sep 2019  路  2Comments  路  Source: realm/SwiftLint

As of Swift 5.1, a new Identifiable protocol has been added.

To conform to this protocol, a variable with name id has to be declared on the conforming type.

This declaration triggers the Identifier Name Violation rule (Variable name should be between 3 and 40 characters long).

Triggering Example

$ echo "struct Example: Identifiable { var id: Int { 1 } }" | swiftlint --use-stdin

As much as I agree with the rule, since I don't believe there's any other way around it, I suggest to add an exception for this conformation.

Most helpful comment

You can use the configuration file to exclude it:

identifier_name:
  excluded: # excluded via string array
    - id
    - URL

All 2 comments

You can use the configuration file to exclude it:

identifier_name:
  excluded: # excluded via string array
    - id
    - URL

Whoa! I didn't know that, many thanks @marcelofabri 馃槂

Was this page helpful?
0 / 5 - 0 ratings