Rule Request: Educated Sorting
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
There area few arrays in SwiftLint's own source that are alphabetically sorted, like masterRuleList and the Linux allTests extensions.
The same thing could apply to enum members, dictionaries, constants, etc.
For example, SourceKitten's SwiftDeclarationKind enum members are all sorted.
It'd be awesome if SwiftLint could automatically infer which sets of declarations were mostly sorted and trigger a warning.
For example, if an array of 10 items only has 2 out-of-order elements, odds are that these are just mis-ordered. This likelihood goes up as the number of total items increases and the number of out-of-order elements decreases.
This could be configurable by minimum thresholds, and probably be made correctable in simple cases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the sorted arrays in Source/SwiftLintFramework/Models/MasterRuleList.swift and the Linux allTests extensions in Tests/SwiftLintFrameworkTests/RulesTests.swift. Compare these examples with SourceKitten's SwiftDeclarationKind.swift, then determine how configurable thresholds and simple correction would fit the proposed rule. Done means the scope and behavior for detecting mostly sorted declarations are defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100