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/EmptyLinesAroundAttributeAccessor fails if the attr_accessor is the last line of the file #9184

Closed
tas50 opened this issue Dec 7, 2020 · 0 comments · Fixed by #9185
Labels

Comments

@tas50
Copy link
Contributor

tas50 commented Dec 7, 2020

Expected behavior

EOF should be considered an empty line around the attr_accessor and the cop should continue on without error.

Actual behavior

An error occurred while Layout/EmptyLinesAroundAttributeAccessor cop was inspecting /Users/tsmith/dev/the_world/php5-fpm/resources/pool.rb:66:0.
undefined method `blank?' for nil:NilClass
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb:87:in `next_line_empty?'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb:72:in `on_send'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:100:in `public_send'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:98:in `each'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:69:in `on_send'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.3.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.3.0/lib/rubocop/ast/traversal.rb:136:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.3.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.3.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/team.rb:157:in `investigate_partial'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/team.rb:83:in `investigate'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:315:in `inspect_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:286:in `loop'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:255:in `do_inspection_loop'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:132:in `block in file_offenses'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:157:in `file_offense_cache'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:131:in `file_offenses'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:122:in `process_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:100:in `each'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:100:in `reduce'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:47:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command.rb:11:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/environment.rb:18:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli.rb:65:in `run_command'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli.rb:41:in `run'
/Users/tsmith/dev/oss/rubocop/exe/rubocop:13:in `block in <top (required)>'
/usr/local/Cellar/ruby/2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/tsmith/dev/oss/rubocop/exe/rubocop:12:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/bin/rubocop:23:in `load'
/usr/local/lib/ruby/gems/2.7.0/bin/rubocop:23:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/opt/ruby/bin/bundle:23:in `load'
/usr/local/opt/ruby/bin/bundle:23:in `<main>'

Steps to reproduce the problem

End a file with the attr_accessor like this

# whatever
attr_accessor :exists

RuboCop version

1.5.2 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.7.2 x86_64-darwin19)
  - rubocop-performance 1.9.1
  - rubocop-rspec 2.0.1
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