Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Request: Empty Array Literal #2807

Closed
2 tasks done
idrougge opened this issue Jul 10, 2019 · 0 comments · Fixed by #2810
Closed
2 tasks done

Rule Request: Empty Array Literal #2807

idrougge opened this issue Jul 10, 2019 · 0 comments · Fixed by #2810
Labels
rule-request Requests for a new rules.

Comments

@idrougge
Copy link

New Issue Checklist

New rule request

Prefer checking isEmpty over comparing string to an empty array literal.

This reflects the behaviour already implemented by empty_string.

What would trigger

if myArray == [] {  }

guard list != [] else { return }

if [] == anArray {  }

theArray==[] ? return : f(theArray)

What would not trigger

let myArray = []

if myArray.isEmpty {  }

guard list.isEmpty else { return }

if myArray == [1, 2, 3] {  }

3. Should the rule be configurable, if so what parameters should be configurable?

No.

4. Should the rule be opt-in or enabled by default? Why?

Same as for empty_string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants