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

Performance/Detect Cop and Enumerator::Lazy #1973

Closed
zapo opened this issue Jun 15, 2015 · 1 comment
Closed

Performance/Detect Cop and Enumerator::Lazy #1973

zapo opened this issue Jun 15, 2015 · 1 comment

Comments

@zapo
Copy link

zapo commented Jun 15, 2015

Hi there. First, many thanks for the great work :)
Performance/Detect doesn't look to handle Enumerator::Lazy instances.

2.2.2 :001 > [1, 2, 3, 4, 5].lazy.select { i % 2 == 0 }.first(2) => [2, 4]

Not sure if this is known and/or planning in supporting it ?

One workaround is to take(n).to_a

@rrosenblum
Copy link
Contributor

My guess is that lazy was not considered when writing the cop. This sounds like a reasonable request to not register an offense when lazy is used. This is probably impacting Performance/Count as well. This should be pretty easy to implement.

bbatsov added a commit that referenced this issue Jun 29, 2015
[Fix #1973] Add support for lazy enumerables in `Performance/Detect`
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