-
-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
lazy in a chain should negate the ChainArrayAllocation cop.
Expected behavior
some_array.lazy.map(&:some_obj_method).reject(&:nil?).firstShould not trigger a perf cop since this is actually a very performant (at least not too aweful) way of getting the first non-nil result. lazy should negate the chain cop as it no longer is a performance issue.
Actual behavior
Cop triggers as follows:
[Performance/ChainArrayAllocation] [I] Use unchained `map` and `reject!`(followed by `return array` if required) instead of chaining `map...reject`.
Steps to reproduce the problem
Run perf cops on above code snippet.
RuboCop version
$ grep cop Gemfile.lock
rubocop (1.6.1)
rubocop-ast (>= 1.2.0, < 2.0)
rubocop-ast (1.4.1)
rubocop-performance (1.9.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.9.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-rake (0.5.1)
rubocop
rubocop-rspec (2.1.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
rubocop (>= 0.52)
rubocop (= 1.6.1)
rubocop-performance (= 1.9.1)
rubocop-rails (= 2.9.1)
rubocop-rake (= 0.5.1)
rubocop-rspec (= 2.1.0)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working