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

error occurred while Style/SingleArgumentDig cop was inspecting #10510

Closed
Ivanov-Anton opened this issue Apr 8, 2022 · 0 comments · Fixed by #10511
Closed

error occurred while Style/SingleArgumentDig cop was inspecting #10510

Ivanov-Anton opened this issue Apr 8, 2022 · 0 comments · Fixed by #10511
Labels

Comments

@Ivanov-Anton
Copy link

Be clear, concise and precise in your description of the problem.
Open an issue with a descriptive title and a summary in grammatically correct,
complete sentences.

Use the template below when reporting bugs. Please, make sure that
you're running the latest stable RuboCop and that the problem you're reporting
hasn't been reported (and potentially fixed) already.

Before filing the ticket you should replace all text above the horizontal
rule with your own words.


Expected behavior

Describe here how you expected RuboCop to behave in this particular situation.

I expect that rubocop correct all offenses without any errors

Actual behavior

rubocop_example@Admins-MacBook-Pro ~ % rubocop example_spec.rb --only Style/SingleArgumentDig -A
Inspecting 1 file
An error occurred while Style/SingleArgumentDig cop was inspecting /Users/anton.i/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
C

Offenses:

example_spec.rb:1:1: C: [Corrected] Style/SingleArgumentDig: Use example_evidence.dig('supporting_messages')[0]['name'] instead of example_evidence.dig('supporting_messages')[0].dig('name').
example_evidence.dig('supporting_messages')[0].dig('name')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
example_spec.rb:1:1: C: [Corrected] Style/SingleArgumentDig: Use example_evidence['supporting_messages'] instead of example_evidence.dig('supporting_messages').
example_evidence.dig('supporting_messages')[0]['name']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 2 offenses detected, 2 offenses corrected

1 error occurred:
An error occurred while Style/SingleArgumentDig cop was inspecting /Users/anton.i/example_spec.rb:1: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.26.1 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 2.7.3 x86_64-darwin17)

Describe here what actually happened.
Please use rubocop --debug when pasting rubocop output as it contains additional information.

For /Users/rubocop_example: Default configuration from /Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/config/default.yml
Inspecting 1 file
Scanning /Users/rubocop_example/example_spec.rb
An error occurred while Style/SingleArgumentDig cop was inspecting /Users/rubocop_example/example_spec.rb:1:0.
Parser::Source::TreeRewriter detected clobbering
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter.rb:427:in `trigger_policy'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter.rb:414:in `enforce_policy'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:233:in `call'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:233:in `swallow'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:97:in `with'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:124:in `place_in_hierarchy'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:106:in `do_combine'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:117:in `place_in_hierarchy'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:131:in `block in combine_children'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:130:in `each'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:130:in `inject'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:130:in `combine_children'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:221:in `merge'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:104:in `do_combine'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter/action.rb:30:in `combine'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/parser-3.1.1.0/lib/parser/source/tree_rewriter.rb:143:in `merge!'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/base.rb:291:in `apply_correction'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/base.rb:375:in `attempt_correction'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/base.rb:356:in `use_corrector'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/base.rb:350:in `correct'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/base.rb:127:in `add_offense'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/style/single_argument_dig.rb:52:in `on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:134:in `each'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:158:in `block in on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:155:in `each'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:155:in `each_with_index'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:155:in `on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:71:in `on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:158:in `block in on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:155:in `each'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:155:in `each_with_index'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:155:in `on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:71:in `on_send'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-ast-1.16.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cop/team.rb:77:in `investigate'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:309:in `inspect_file'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:253:in `block in do_inspection_loop'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:280:in `loop'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:130:in `block in file_offenses'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:155:in `file_offense_cache'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:129:in `file_offenses'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:120:in `process_file'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:100:in `each'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:100:in `reduce'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/runner.rb:47:in `run'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli/command.rb:11:in `run'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli/environment.rb:18:in `run'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli.rb:71:in `run_command'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli.rb:78:in `execute_runners'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/lib/rubocop/cli.rb:47:in `run'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/exe/rubocop:12:in `block in <top (required)>'
/Users/rubocop_example/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/gems/rubocop-1.26.1/exe/rubocop:12:in `<top (required)>'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/bin/rubocop:23:in `load'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/bin/rubocop:23:in `<main>'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in `eval'
/Users/rubocop_example/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in `<main>'

Steps to reproduce the problem

  1. install rubocop with 1.27.0 version
  2. execute in terminal echo 'example_evidence.dig('supporting_messages')[0].dig('name')' >> example.rb
  3. execute in terminal rubocop example.rb --only Style/SingleArgumentDig -A

This is extremely important! Providing us with a reliable way to reproduce
a problem will expedite its solution.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ [bundle exec] rubocop -V
1.27.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
  - rubocop-performance 1.9.1
  - rubocop-rspec 2.0.0
1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 2.7.3 x86_64-darwin17)
@koic koic added the bug label Apr 8, 2022
koic added a commit to koic/rubocop that referenced this issue Apr 8, 2022
Fixes rubocop#10510.

This PR fixes an error for `Style/SingleArgumentDig`
when using multiple `dig` in a method chain.

And this is the same solution as rubocop#10461.
bbatsov pushed a commit that referenced this issue Apr 9, 2022
Fixes #10510.

This PR fixes an error for `Style/SingleArgumentDig`
when using multiple `dig` in a method chain.

And this is the same solution as #10461.
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