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

Inifite loop detected in Style/SingleLineBlockParams #9958

Closed
tas50 opened this issue Jul 29, 2021 · 0 comments · Fixed by #9966
Closed

Inifite loop detected in Style/SingleLineBlockParams #9958

tas50 opened this issue Jul 29, 2021 · 0 comments · Fixed by #9966
Labels

Comments

@tas50
Copy link
Contributor

tas50 commented Jul 29, 2021

Expected behavior

RuboCop runs and cleans up any offending code if necessary.

Actual behavior

Scanning this code:

# frozen_string_literal: true

cookbook_root = ::File.realpath(::File.dirname(__dir__))
cookbook_repo = ::File.dirname(cookbook_root)
project_root = (0..2).reduce(cookbook_repo) { |acc| ::File.dirname(acc) }
library_root = ::File.join(cookbook_root, 'files', 'default', 'lib')
pattern = ::File.join(library_root, '**', '*.rb')

parent_loader_candidates = [cookbook_repo, project_root].map do |path|
  "#{path}/libraries/loader.rb"
end
parent_loader_candidates.each do |path|
  next unless ::File.exist?(path)
  require path.sub(/\.rb$/, '')
end

Dir.glob(pattern).each do |path|
  require path.sub(/\.rb$/, '')
end

Results in this:

Infinite loop detected in /Users/tsmith/dev/the_world/ama-linux-user-management/test/support/cookbooks/alum-testing/libraries/loader.rb and caused by Style/SingleLineBlockParams
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:299:in `check_for_infinite_loop'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:282:in `block in iterate_until_no_changes'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:281:in `loop'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:281:in `iterate_until_no_changes'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:250:in `do_inspection_loop'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:130:in `block in file_offenses'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:155:in `file_offense_cache'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:129:in `file_offenses'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:120:in `process_file'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:100:in `each'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:100:in `reduce'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:100:in `each_inspected_file'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:86:in `inspect_files'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/runner.rb:47:in `run'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli/command.rb:11:in `run'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli/environment.rb:18:in `run'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli.rb:65:in `run_command'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli.rb:72:in `execute_runners'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/lib/rubocop/cli.rb:41:in `run'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/exe/rubocop:12:in `block in <top (required)>'
/opt/chef-workstation/embedded/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/rubocop-1.18.4/exe/rubocop:12:in `<top (required)>'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/cookstyle-7.15.2/bin/cookstyle:26:in `load'
/opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/cookstyle-7.15.2/bin/cookstyle:26:in `<top (required)>'
/opt/chef-workstation/bin/cookstyle:365:in `load'
/opt/chef-workstation/bin/cookstyle:365:in `<main>'
Finished in 0.529549999977462 seconds

Steps to reproduce the problem

Run rubocop -a against the above code

RuboCop version

1.18.4 (using Parser 3.0.2.0, rubocop-ast 1.8.0, running on ruby 3.0.2 x86_64-darwin18)
@koic koic added the bug label Jul 30, 2021
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Aug 2, 2021
bbatsov pushed a commit that referenced this issue Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants