Skip to content

Conversation

@eugeneius
Copy link
Contributor

The test added here demonstrates the problem:

$ bundle exec rspec spec/rubocop/cop/performance/collection_literal_in_loop_spec.rb:149
Run options: include {:locations=>{"./spec/rubocop/cop/performance/collection_literal_in_loop_spec.rb"=>[149]}}

Randomized with seed 21526

RuboCop::Cop::Performance::CollectionLiteralInLoop
  when inside one of `Enumerable` loop-like methods
    registers an offense when the method is called with no receiver (FAILED - 1)

Failures:

  1) RuboCop::Cop::Performance::CollectionLiteralInLoop when inside one of `Enumerable` loop-like methods registers an offense when the method is called with no receiver
     Failure/Error: receiver != node && !receiver.descendants.include?(node)

     NoMethodError:
       undefined method `descendants' for nil:NilClass
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:118:in `block in node_within_enumerable_loop?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:85:in `enumerable_loop?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:117:in `node_within_enumerable_loop?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:109:in `loop?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:103:in `block in parent_is_loop?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:103:in `each'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:103:in `any?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:103:in `parent_is_loop?'
     # ./lib/rubocop/cop/performance/collection_literal_in_loop.rb:82:in `on_send'
     # ./spec/rubocop/cop/performance/collection_literal_in_loop_spec.rb:150:in `block (3 levels) in <top (required)>'

Finished in 0.03141 seconds (files took 0.8423 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/rubocop/cop/performance/collection_literal_in_loop_spec.rb:149 # RuboCop::Cop::Performance::CollectionLiteralInLoop when inside one of `Enumerable` loop-like methods registers an offense when the method is called with no receiver

Randomized with seed 21526

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic merged commit 5da259b into rubocop:master Sep 5, 2020
@koic
Copy link
Member

koic commented Sep 5, 2020

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants