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

undefined method error when running Rails/DeprecatedActiveModelErrorsMethods cop #724

Closed
arashm opened this issue Jun 20, 2022 · 2 comments

Comments

@arashm
Copy link

arashm commented Jun 20, 2022

The Rails/DeprecatedActiveModelErrorsMethods returns an exception when running:

An error occurred while Rails/DeprecatedActiveModelErrorsMethods cop was inspecting homer/app/models/client_creator.rb:105:34.
undefined method `method?' for s(:lvar, :iovation_check/.:RuboCop::AST::Node
Did you mean?  method
               methods
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.15.0/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb:122:in `autocorrect'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.15.0/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb:112:in `block (2 levels) in on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/base.rb:342:in `correct'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/base.rb:127:in `add_offense'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.15.0/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb:109:in `block in on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.15.0/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb:58:in `any_manipulation?'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.15.0/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb:108:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:100:in `public_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:98:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:69:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:158:in `block in on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `each_with_index'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:158:in `block in on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `each_with_index'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:158:in `block in on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `each_with_index'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:155:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_send'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:154:in `on_if'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_if'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:153:in `on_def'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_def'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:153:in `on_class'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_class'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `block in on_dstr'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:136:in `on_dstr'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.18.0/lib/rubocop/ast/traversal.rb:20:in `walk'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/commissioner.rb:86:in `investigate'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/team.rb:155:in `investigate_partial'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cop/team.rb:83:in `investigate'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:307:in `inspect_file'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:251:in `block in do_inspection_loop'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:285:in `block in iterate_until_no_changes'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:278:in `loop'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:278:in `iterate_until_no_changes'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:247:in `do_inspection_loop'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:130:in `block in file_offenses'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:155:in `file_offense_cache'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:129:in `file_offenses'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:120:in `process_file'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:100:in `each'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:100:in `reduce'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:100:in `each_inspected_file'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:86:in `inspect_files'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/runner.rb:47:in `run'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli/command.rb:11:in `run'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli/environment.rb:18:in `run'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli.rb:71:in `run_command'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli.rb:78:in `execute_runners'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/lib/rubocop/cli.rb:47:in `run'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/exe/rubocop:12:in `block in <top (required)>'
.rbenv/versions/3.0.3/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rubocop-1.30.1/exe/rubocop:12:in `<top (required)>'
.rbenv/versions/3.0.3/bin/rubocop:25:in `load'

The code looks like this

client.messages << iovation_check.errors.keys.first.to_s if iovation_check.errors.present?

Expected behavior

The code is valid and shouldn't raise an exception.

Actual behavior

see the error above.

Steps to reproduce the problem

running rubocop -d PATH_TO_FILE shows the error.

RuboCop version

1.30.1 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 3.0.3 arm64-darwin21)
  - rubocop-rails 2.15.0
  - rubocop-rspec 2.11.1
@nobuyo
Copy link
Contributor

nobuyo commented Jun 20, 2022

It seems to same as #717.

@arashm
Copy link
Author

arashm commented Jun 20, 2022

Oh, thanks. Seems like an unreleased fix. I close this.

@arashm arashm closed this as completed Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants