Skip to content

Rule Request: [container_types] Need new rule to require idiomatic container rules #1808

@atlassian-gaustin

Description

@atlassian-gaustin

New Issue Checklist

Rule Request

The "idiomatically-correct" types of containers are ContainerType<ElementType[, ElementType...]>. While the Swift documentation states that the syntactic sugar versions are preferred, there are points in the code where the sugar versions do not work because the idiomatically-correct type is required (Array<Int>.Index is valid, [Int].Index is an error).

The existing rule for syntactic_sugar rule disallows these or simply doesn't check (on/off). There needs to be a new rule (that deprecates syntactic_sugar) that allows checking for idiomatically-correct, syntactic sugar, or off.

  • container_types **on** - type definitions of Array<Int> or Dictionary<String, Any> would pass, [Int] and [String: Any] would fail.
  • container_types **sugar** - type definitions of [Int] or [String: Any] would pass, Array<Int> and Dictionary<String, Any> would fail.
  • container_types **off** - type definitions of [Int], '[String: Any], Array, or Dictionary<String, Any>` would pass.

Default would be container_types sugar to match existing syntactic_sugar default of on. This would also require syntactic_sugar to be deprecated or mapped into this new rule as a synonym to 'sugar' or 'off'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule-requestRequests for a new rules.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions