Navigation Menu

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

Layout/SpaceBeforeBlockBraces cop raises RuntimeError #7590

Closed
j-miyake opened this issue Dec 23, 2019 · 0 comments · Fixed by #7591
Closed

Layout/SpaceBeforeBlockBraces cop raises RuntimeError #7590

j-miyake opened this issue Dec 23, 2019 · 0 comments · Fixed by #7591
Labels

Comments

@j-miyake
Copy link
Contributor

j-miyake commented Dec 23, 2019

Layout/SpaceBeforeBlockBraces cop raises undefined local variable or method when processing a file like below.

foo.rb

context do
  let(:foo){{a: 1, b: 2}}
end

Expected behavior

Rubocop should not raise the error.

Actual behavior

Rubocop raises the error.

Steps to reproduce the problem

Under the following configuration,

Style/BlockDelimiters
  Enable: true

Layout/SpaceBeforeBlockBraces
  EnforcedStyle: no_space

Run rubocop

$ rubocop -d foo.rb
Inspecting 1 file
Scanning /Users/johnny/test/foo.rb
An error occurred while Layout/SpaceBeforeBlockBraces cop was inspecting /Users/johnny/test/foo.rb:2:2.
undefined local variable or method `node' for #<RuboCop::Cop::Layout::SpaceBeforeBlockBraces:0x00007fabed2fb458>
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/layout/space_before_block_braces.rb:123:in `conflict_with_block_delimiters?'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/layout/space_before_block_braces.rb:50:in `on_block'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:57:in `block (2 levels) in trigger_responding_cops'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:136:in `with_cop_error_handling'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:56:in `block in trigger_responding_cops'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:55:in `each'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:55:in `trigger_responding_cops'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:32:in `block (2 levels) in <class:Commissioner>'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:164:in `on_block'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:13:in `walk'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:44:in `investigate'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/team.rb:124:in `investigate'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/team.rb:112:in `offenses'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cop/team.rb:44:in `inspect_file'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:296:in `inspect_file'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:244:in `block in do_inspection_loop'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:276:in `block in iterate_until_no_changes'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:269:in `loop'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:269:in `iterate_until_no_changes'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:240:in `do_inspection_loop'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:119:in `block in file_offenses'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:143:in `file_offense_cache'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:117:in `file_offenses'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:108:in `process_file'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:86:in `each'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:86:in `reduce'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:86:in `each_inspected_file'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:73:in `inspect_files'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:39:in `run'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli/command.rb:10:in `run'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli/environment.rb:17:in `run'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli.rb:65:in `run_command'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/lib/rubocop/cli.rb:41:in `run'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/exe/rubocop:13:in `block in <top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/2.3.0/gems/rubocop-0.78.0/exe/rubocop:12:in `<top (required)>'
/usr/local/bin/rubocop:22:in `load'
/usr/local/bin/rubocop:22:in `<main>'

RuboCop version

$ rubocop -V
0.78.0 (using Parser 2.6.5.0, running on ruby 2.3.7 universal.x86_64-darwin18)
@koic koic added the bug label Dec 24, 2019
koic added a commit to koic/rubocop that referenced this issue Dec 24, 2019
Fixes rubocop#7590.

This PR fixes an error for `Layout/SpaceBeforeBlockBraces` when using with
`EnforcedStyle: line_count_based` of `Style/BlockDelimiters` cop.
bbatsov pushed a commit that referenced this issue Dec 25, 2019
Fixes #7590.

This PR fixes an error for `Layout/SpaceBeforeBlockBraces` when using with
`EnforcedStyle: line_count_based` of `Style/BlockDelimiters` cop.
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