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

An error occurred while Rails/ActionOrder cop was inspecting files #841

Closed
dmarcoux opened this issue Oct 26, 2022 · 0 comments · Fixed by #859
Closed

An error occurred while Rails/ActionOrder cop was inspecting files #841

dmarcoux opened this issue Oct 26, 2022 · 0 comments · Fixed by #859
Labels
bug Something isn't working

Comments

@dmarcoux
Copy link

I might have found a bug in version 2.17.1 in the Rails/ActionOrder. See the stacktrace below.

Expected behavior

I expect RuboCop to not produce an error.

Actual behavior

Stacktrace:

An error occurred while Rails/ActionOrder cop was inspecting /obs/src/api/app/controllers/webui/project_controller.rb:1:0.
Parser::Source::TreeRewriter detected clobbering
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter.rb:427:in `trigger_policy'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter.rb:414:in `enforce_policy'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:225:in `call'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:225:in `call_enforcer_for_merge'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:216:in `merge'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:104:in `do_combine'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:117:in `place_in_hierarchy'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:131:in `block in combine_children'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:130:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:130:in `inject'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:130:in `combine_children'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:221:in `merge'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:104:in `do_combine'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter/action.rb:30:in `combine'
/usr/lib64/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter.rb:143:in `merge!'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/base.rb:295:in `apply_correction'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/base.rb:379:in `attempt_correction'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/base.rb:360:in `use_corrector'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/base.rb:354:in `correct'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/base.rb:127:in `add_offense'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:73:in `register_offense'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:48:in `block in on_class'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:50:in `block in action_declarations'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:106:in `block in visit_descendants'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:105:in `visit_descendants'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:107:in `block in visit_descendants'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:105:in `visit_descendants'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/node/mixin/descendence.rb:97:in `each_node'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:45:in `action_declarations'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:44:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:44:in `each_cons'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-rails-2.17.1/lib/rubocop/cop/rails/action_order.rb:44:in `on_class'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:100:in `public_send'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:98:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:69:in `on_class'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cop/team.rb:77:in `investigate'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:315:in `inspect_file'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:286:in `loop'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:255:in `do_inspection_loop'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:138:in `block in file_offenses'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:163:in `file_offense_cache'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:137:in `file_offenses'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:128:in `process_file'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:109:in `block in each_inspected_file'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:108:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:108:in `reduce'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:108:in `each_inspected_file'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:94:in `inspect_files'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/runner.rb:47:in `run'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli/command.rb:11:in `run'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli/environment.rb:18:in `run'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli.rb:72:in `run_command'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli.rb:79:in `execute_runners'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/lib/rubocop/cli.rb:48:in `run'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/exe/rubocop:19:in `block in <top (required)>'
/usr/lib64/ruby/3.1.0/benchmark.rb:311:in `realtime'
/usr/lib64/ruby/gems/3.1.0/gems/rubocop-1.37.1/exe/rubocop:19:in `<top (required)>'
/usr/bin/rubocop:25:in `load'
/usr/bin/rubocop:25:in `<main>'

Steps to reproduce the problem

This is the file which is causing the issue: https://github.com/openSUSE/open-build-service/blob/e479c616af873f4ae9f3ef538e5a38d2133913f9/src/api/app/controllers/webui/project_controller.rb

RuboCop version

$ bundle exec rubocop -V
1.37.1 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.2) [x86_64-linux-gnu]
  - rubocop-performance 1.15.0
  - rubocop-rails 2.17.1
  - rubocop-rspec 2.13.2.2
@koic koic added the bug Something isn't working label Oct 28, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Nov 8, 2022
Fixes rubocop#841.

This PR fixes an error for `Rails/ActionOrder`
when using unconventional order of multiple actions.

With this change, autocorrection blank line positions are not as expected,
so they are left to autocorrection of `Layout/EmptyLineBetweenDefs` and
`Layout/EmptyLinesAroundClassBody` cops.

This PR aims to fix the error, that it may be a cleaner autocorrection later.
koic added a commit to koic/rubocop-rails that referenced this issue Nov 8, 2022
Fixes rubocop#841.

This PR fixes an error for `Rails/ActionOrder`
when using unconventional order of multiple actions.

With this change, autocorrection blank line positions are not as expected,
so they are left to autocorrection of `Layout/EmptyLineBetweenDefs` and
`Layout/EmptyLinesAroundClassBody` cops.

This PR aims to fix the error, that it may be a cleaner autocorrection later.
koic added a commit to koic/rubocop-rails that referenced this issue Nov 8, 2022
Fixes rubocop#841.

This PR fixes an error for `Rails/ActionOrder`
when using unconventional order of multiple actions.

With this change, autocorrection blank line positions are not as expected,
so they are left to autocorrection of `Layout/EmptyLineBetweenDefs` and
`Layout/EmptyLinesAroundClassBody` cops.

This PR aims to fix the error, that it may be a better autocorrection later.
koic added a commit to koic/rubocop-rails that referenced this issue Nov 10, 2022
Fixes rubocop#841.

This PR fixes an error for `Rails/ActionOrder`
when using unconventional order of multiple actions.

With this change, autocorrection blank line positions are not as expected,
so they are left to autocorrection of `Layout/EmptyLineBetweenDefs` and
`Layout/EmptyLinesAroundClassBody` cops.

This PR aims to fix the error, that it may be a better autocorrection later.
@koic koic closed this as completed in #859 Nov 11, 2022
koic added a commit that referenced this issue Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants