Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an infinite loop error for
Layout/SpaceInsideBlockBraces
This PR fixes an infinite loop error for `Layout/SpaceInsideBlockBraces` when`EnforcedStyle: no_space` with `SpaceBeforeBlockParameters: false` are set in multiline block. ```yaml # .rubocop.yml AllCops: DisabledByDefault: true Layout/SpaceInsideBlockBraces: Enabled: true EnforcedStyle: no_space SpaceBeforeBlockParameters: false ``` ```ruby # example.rb items.map {|item| item.do_something } ``` ```console % rubocop -a --only Layout/SpaceInsideBlockBraces Inspecting 1 file C Offenses: example.rb:2:20: C: [Corrected] Layout/SpaceInsideBlockBraces: Space inside } detected. item.do_something ... 0 files inspected, 1 offense detected, 1 offense corrected Infinite loop detected in /private/tmp/foo/example.rb. /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:268:in `check_for_infinite_loop' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:251:in `block in iterate_until_no_changes' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:250:in `loop' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:250:in `iterate_until_no_changes' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:221:in `do_inspection_loop' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:124:in `block in file_offenses' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:142:in `file_offense_cache' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:122:in `file_offenses' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.72.0/lib/rubocop/runner.rb:110:in `process_file' (snip) ``` Furthermore, it is changed by auto-correction to the following unnatural code. ```diff diff --git a/example.rb b/example.rb index f1427be..fb547ee 100644 --- a/example.rb +++ b/example.rb @@ -1,3 +1,2 @@ items.map {|item| - item.do_something -} + item.do_something} ``` This PR prevents the error by noticing right brace of multiline block.
- Loading branch information