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

minor bugs with empty_count #505

Closed
BluMist opened this issue Feb 7, 2016 · 4 comments
Closed

minor bugs with empty_count #505

BluMist opened this issue Feb 7, 2016 · 4 comments

Comments

@BluMist
Copy link

BluMist commented Feb 7, 2016

example 1: if I just have a variable named count not associated with an array/object, the rule will trigger. maybe restrict the rule to only check for .count?
var count = 0
return count == 0 (trigger error warning)

as an extension, if I do if num + count > 0, the rule will trigger as well

example 2: (probably undetectable) - classes (ex. NSArray) can have .count but not .isEmpty

@jpsim
Copy link
Collaborator

jpsim commented Feb 7, 2016

These issues are known, which is why the rule isn't on by default. See #206 for a discussion around that.

@BluMist
Copy link
Author

BluMist commented Feb 7, 2016

ah, got it, didn't surface in the search.

@BluMist BluMist closed this as completed Feb 7, 2016
@marcelofabri
Copy link
Collaborator

I don't get why the rule shouldn't check for .count. It wouldn't catch a violation if self is a collection object (and count is used without self.), but I think that's a valid tradeoff.

@jpsim
Copy link
Collaborator

jpsim commented Feb 7, 2016

Anecdotally I can say that enabling this rule helped find some inefficient zero comparisons in some Array extensions. More false positives but also more true positives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants