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

Infinite loop caused by Layout/SpaceBeforeSemicolon and Layout/SpaceInsideBlockBraces cops #12374

Closed
ydakuka opened this issue Nov 8, 2023 · 0 comments · Fixed by #12376
Closed
Labels

Comments

@ydakuka
Copy link

ydakuka commented Nov 8, 2023

Actual behavior

I have the following code:

class User < ApplicationRecord
  scope :my_scope_name, -> { ; my_method_name }
end

Terminal:

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop -A app/models/user.rb
Inspecting 1 file
C

Offenses:

app/models/user.rb:4:29: C: [Corrected] Layout/SpaceBeforeSemicolon: Space found before semicolon.
  scope :my_scope_name, -> { ; my_method_name }
                            ^
app/models/user.rb:4:29: C: [Corrected] Layout/SpaceInsideBlockBraces: Space missing inside {.
  scope :my_scope_name, -> {; my_method_name }
                            ^

0 files inspected, 2 offenses detected, 2 offenses corrected
Infinite loop detected in /app/app/models/user.rb and caused by Layout/SpaceBeforeSemicolon -> Layout/SpaceInsideBlockBraces
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:332:in `check_for_infinite_loop'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:315:in `block in iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:314:in `loop'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:164:in `block in file_offenses'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:189:in `file_offense_cache'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:163:in `file_offenses'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:154:in `process_file'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:134:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:134:in `reduce'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:134:in `each_inspected_file'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:120:in `inspect_files'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/runner.rb:73:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli/command.rb:11:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli/environment.rb:18:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:118:in `run_command'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:125:in `execute_runners'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:51:in `block in run'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:77:in `profile_if_needed'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/lib/rubocop/cli.rb:43:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/exe/rubocop:19:in `block in <top (required)>'
/usr/local/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-1.57.2/exe/rubocop:19:in `<top (required)>'
/usr/local/bin/rubocop:23:in `load'
/usr/local/bin/rubocop:23:in `<main>'

Rubocop

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop -V
1.57.2 (using Parser 3.2.2.4, rubocop-ast 1.29.0, running on ruby 2.7.8) [x86_64-linux]
  - rubocop-capybara 2.19.0
  - rubocop-factory_bot 2.24.0
  - rubocop-performance 1.19.1
  - rubocop-rails 2.22.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.25.0
  - rubocop-thread_safety 0.5.1
@ydakuka ydakuka changed the title Infinite loop on Layout/SpaceBeforeSemicolon and Layout/SpaceInsideBlockBraces cops Infinite loop caused by Layout/SpaceBeforeSemicolon and Layout/SpaceInsideBlockBraces cops Nov 8, 2023
@koic koic added the bug label Nov 9, 2023
koic added a commit to koic/rubocop that referenced this issue Nov 9, 2023
…olon`

Fixes rubocop#12374.

This PR fixes a false positive for `Layout/SpaceBeforeSemicolon`
when a space between an opening lambda brace and a semicolon.

NOTE: When `Token#left_curly_brace?` supports `:tLAMBEG`,
the condition `token.type == :tLAMBEG` can be removed.
koic added a commit that referenced this issue Nov 10, 2023
…pace_before_semicolon

[Fix #12374] Fix a false positive for `Layout/SpaceBeforeSemicolon`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants