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

Style/BisectedAttrAccessor cop fails when attr_reader is not used in a normal way #8257

Closed
cohei opened this issue Jul 7, 2020 · 1 comment · Fixed by #8260
Closed

Style/BisectedAttrAccessor cop fails when attr_reader is not used in a normal way #8257

cohei opened this issue Jul 7, 2020 · 1 comment · Fixed by #8260
Labels
Milestone

Comments

@cohei
Copy link

cohei commented Jul 7, 2020

Style/BisectedAttrAccessor cop fails when attr_reader receives a variable with splat.


Expected behavior

Success without error.

Actual behavior

Error occurs.

Steps to reproduce the problem

Make this file

# reproduce.rb
class C
  ATTRIBUTES = %i[a b]
  attr_reader(*ATTRIBUTES)
end

then

$ rubocop -d --only Style/BisectedAttrAccessor reproduce.rb 
output
For /: Default configuration from /usr/local/bundle/gems/rubocop-0.87.0/config/default.yml
Inspecting 1 file
Scanning /reproduce.rb
An error occurred while Style/BisectedAttrAccessor cop was inspecting /reproduce.rb:1:0.
undefined method `value' for s(:splat,
  s(:const, nil, :ATTRIBUTES)):RuboCop::AST::Node
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/style/bisected_attr_accessor.rb:50:in `map'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/style/bisected_attr_accessor.rb:50:in `block in accessor_names'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/style/bisected_attr_accessor.rb:49:in `each'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/style/bisected_attr_accessor.rb:49:in `accessor_names'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/style/bisected_attr_accessor.rb:27:in `on_class'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:91:in `block (2 levels) in trigger_responding_cops'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:113:in `with_cop_error_handling'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:90:in `block in trigger_responding_cops'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:89:in `each'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:89:in `trigger_responding_cops'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:61:in `block (2 levels) in <class:Commissioner>'
/usr/local/bundle/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:14:in `walk'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/commissioner.rb:74:in `investigate'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/team.rb:151:in `investigate_partial'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cop/team.rb:83:in `investigate'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:296:in `inspect_file'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:246:in `block in do_inspection_loop'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:278:in `block in iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:271:in `loop'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:271:in `iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:242:in `do_inspection_loop'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:122:in `block in file_offenses'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:147:in `file_offense_cache'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:120:in `file_offenses'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:111:in `process_file'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:90:in `block in each_inspected_file'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:89:in `each'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:89:in `reduce'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:89:in `each_inspected_file'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:78:in `inspect_files'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/runner.rb:39:in `run'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli/command.rb:10:in `run'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli/environment.rb:17:in `run'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli.rb:65:in `run_command'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli.rb:72:in `execute_runners'
/usr/local/bundle/gems/rubocop-0.87.0/lib/rubocop/cli.rb:41:in `run'
/usr/local/bundle/gems/rubocop-0.87.0/exe/rubocop:13:in `block in <top (required)>'
/usr/local/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/usr/local/bundle/gems/rubocop-0.87.0/exe/rubocop:12:in `<top (required)>'
/usr/local/bundle/bin/rubocop:23:in `load'
/usr/local/bundle/bin/rubocop:23:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Style/BisectedAttrAccessor cop was inspecting /reproduce.rb:1:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
0.87.0 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.7.1 x86_64-linux)
Finished in 0.17187920000287704 seconds

RuboCop version

$ rubocop -V
0.87.0 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.7.1 x86_64-linux)
@koic koic added the bug label Jul 7, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 7, 2020

@fatkodima Can you look into this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants