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
idrougge opened this issue Jul 10, 2019 · 0 comments · Fixed by #2810

Comments

@idrougge
Copy link

commented Jul 10, 2019

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
Projects
None yet
2 participants
You can’t perform that action at this time.