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

empty_count rule has false positives for non-Collection comparisons #1601

Closed
danielbyon opened this issue Jun 2, 2017 · 1 comment
Closed

Comments

@danielbyon
Copy link

I'm seeing the empty_count rule triggering an error when doing a count comparison that isn't on a Collection, as shown in the screenshot below:

screen shot 2017-06-02 at 1 46 56 pm

I think this can be solved by making the following change to Source/SwiftLintFramework/Rules/EmptyCountRule.swift line 34:

From:
let pattern = "count\\s*(==|!=|<|<=|>|>=)\\s*0"

To:
let pattern = ".count\\s*(==|!=|<|<=|>|>=)\\s*0"

This will ensure that we're checking for uses of the count member var, instead of checking every identifier named "count".

Running Swiftlint 0.15.0

@jpsim
Copy link
Collaborator

jpsim commented Jun 2, 2017

Duplicate of #827

@jpsim jpsim closed this as completed Jun 2, 2017
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

2 participants