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/BlockEndNewline cop errors with irregular bracing layout #10890

Closed
malclocke opened this issue Aug 8, 2022 · 1 comment
Closed

Layout/BlockEndNewline cop errors with irregular bracing layout #10890

malclocke opened this issue Aug 8, 2022 · 1 comment
Labels

Comments

@malclocke
Copy link

The Layout/BlockEndNewline cop errors with the following input

# frozen_string_literal: true

-> {
 nil }

Actual behavior

$ rubocop --debug foo.rb 
For /home/malc/oss/rubocop: Default configuration from /home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/config/default.yml
Use parallel by default.
Running parallel inspection
An error occurred while Layout/BlockEndNewline cop was inspecting /home/malc/oss/rubocop/foo.rb:3:0.
undefined method `arguments' for s(:nil):RuboCop::AST::Node
Did you mean?  argument?
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:63:in `last_heredoc_argument'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:49:in `block in register_offense'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/base.rb:346:in `correct'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/base.rb:127:in `add_offense'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:45:in `register_offense'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:39:in `on_block'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:100:in `public_send'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:98:in `each'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:69:in `on_block'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.19.1/lib/rubocop/ast/traversal.rb:20:in `walk'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/team.rb:83:in `investigate'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:311:in `inspect_file'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:255:in `block in do_inspection_loop'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:289:in `block in iterate_until_no_changes'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:282:in `loop'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:282:in `iterate_until_no_changes'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:251:in `do_inspection_loop'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:134:in `block in file_offenses'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:159:in `file_offense_cache'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:133:in `file_offenses'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:69:in `block in warm_cache'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:587:in `call_with_index'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:557:in `process_incoming_jobs'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:537:in `block in worker'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:528:in `fork'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:528:in `worker'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:519:in `block in create_workers'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:518:in `each'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:518:in `each_with_index'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:518:in `create_workers'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:457:in `work_in_processes'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:294:in `map'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/parallel-1.22.1/lib/parallel.rb:238:in `each'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:69:in `warm_cache'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:46:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command.rb:11:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli.rb:72:in `run_command'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli.rb:79:in `execute_runners'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli.rb:48:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/exe/rubocop:19:in `block in <top (required)>'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/exe/rubocop:19:in `<top (required)>'
/home/malc/.rbenv/versions/2.7.3/bin/rubocop:23:in `load'
/home/malc/.rbenv/versions/2.7.3/bin/rubocop:23:in `<main>'
Inspecting 1 file
Scanning /home/malc/oss/rubocop/foo.rb
An error occurred while Layout/BlockEndNewline cop was inspecting /home/malc/oss/rubocop/foo.rb:3:0.
undefined method `arguments' for s(:nil):RuboCop::AST::Node
Did you mean?  argument?
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:63:in `last_heredoc_argument'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:49:in `block in register_offense'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/base.rb:346:in `correct'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/base.rb:127:in `add_offense'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:45:in `register_offense'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/layout/block_end_newline.rb:39:in `on_block'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:100:in `public_send'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:98:in `each'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:69:in `on_block'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.19.1/lib/rubocop/ast/traversal.rb:20:in `walk'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cop/team.rb:83:in `investigate'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:311:in `inspect_file'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:255:in `block in do_inspection_loop'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:289:in `block in iterate_until_no_changes'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:282:in `loop'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:282:in `iterate_until_no_changes'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:251:in `do_inspection_loop'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:134:in `block in file_offenses'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:159:in `file_offense_cache'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:133:in `file_offenses'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:124:in `process_file'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:105:in `block in each_inspected_file'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:104:in `each'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:104:in `reduce'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:104:in `each_inspected_file'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:90:in `inspect_files'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/runner.rb:47:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/command.rb:11:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli.rb:72:in `run_command'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli.rb:79:in `execute_runners'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/lib/rubocop/cli.rb:48:in `run'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/exe/rubocop:19:in `block in <top (required)>'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/home/malc/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.33.0/exe/rubocop:19:in `<top (required)>'
/home/malc/.rbenv/versions/2.7.3/bin/rubocop:23:in `load'
/home/malc/.rbenv/versions/2.7.3/bin/rubocop:23:in `<main>'
C

Offenses:

foo.rb:3:1: C: [Correctable] Style/Lambda: Use the lambda method for multiline lambdas.
-> {
^^

1 file inspected, 1 offense detected, 1 offense autocorrectable

1 error occurred:
An error occurred while Layout/BlockEndNewline cop was inspecting /home/malc/oss/rubocop/foo.rb:3:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.33.0 (using Parser 3.1.2.0, rubocop-ast 1.19.1, running on ruby 2.7.3 x86_64-linux)
Finished in 0.21998426600475796 seconds

Steps to reproduce the problem

$ rubocop -s foo.rb <<EOT
# frozen_string_literal: true

-> {
 nil }
EOT

RuboCop version

$ rubocop -V
1.33.0 (using Parser 3.1.2.0, rubocop-ast 1.19.1, running on ruby 2.7.3 x86_64-linux)
@dvandersluis
Copy link
Member

Thanks for the report @malclocke, this is a dupe of #10877 and already fixed in master.

@dvandersluis dvandersluis closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants