Empty Array Initialize
Open
Nobody has claimed this yet.
discussion
rule-request
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New rule request
array initialize using [] instead ()
Bad
var emptyArray = [Int]()
Good
var emptyArray: [Int] = []
- using [] is more common and preferred due to its readability and simplicity. It is a more straightforward way to indicate that you are initializing an empty array of a specific type.
- using () to initialize an empty array might lead to confusion, as it resembles tuple syntax, which may suggest that you are creating a tuple.
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 locating the existing SwiftLint rule implementations and tests for syntax-style checks. Use the issue's bad and good examples to define the expected behavior for empty arrays, then add coverage showing that [] is preferred over Int. Done means the rule consistently identifies the requested form and the related tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100