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/HasManyOrHasOneDependent cop" since v2.12.0 #535

Closed
ybiquitous opened this issue Sep 9, 2021 · 7 comments · Fixed by #536
Closed

"An error occurred while Rails/HasManyOrHasOneDependent cop" since v2.12.0 #535

ybiquitous opened this issue Sep 9, 2021 · 7 comments · Fixed by #536
Labels
bug Something isn't working

Comments

@ybiquitous
Copy link
Contributor

ybiquitous commented Sep 9, 2021

Hi there, are you enjoying RubyKaigi 2021 Takeout? 😄

When I try v2.12.0 released today, I encounter the following error with the Rails/HasManyOrHasOneDependent cop:

An error occurred while Rails/HasManyOrHasOneDependent cop was inspecting ...

Expected behavior

I expect no errors like the previous version v2.11.3.

Actual behavior

Run bundle exec rubocop --debug app/models/user.rb:

For /private/tmp/rubocop-rails-repro: configuration from /private/tmp/rubocop-rails-repro/.rubocop.yml
configuration from /private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-rails-2.12.0/config/default.yml
configuration from /private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-rails-2.12.0/config/default.yml
Default configuration from /private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/config/default.yml
Use parallel by default.
Running parallel inspection
undefined method `first' for nil:NilClass
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-rails-2.12.0/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:117:in `valid_options?'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-rails-2.12.0/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:80:in `on_send'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:134:in `each'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.11.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.11.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/team.rb:83:in `investigate'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:310:in `inspect_file'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:254:in `block in do_inspection_loop'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:288:in `block in iterate_until_no_changes'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:281:in `loop'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:281:in `iterate_until_no_changes'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:250:in `do_inspection_loop'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:130:in `block in file_offenses'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:155:in `file_offense_cache'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:129:in `file_offenses'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:67:in `block in warm_cache'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:509:in `call_with_index'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:477:in `process_incoming_jobs'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:459:in `block in worker'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:450:in `fork'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:450:in `worker'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:441:in `block in create_workers'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:440:in `each'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:440:in `each_with_index'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:440:in `create_workers'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:380:in `work_in_processes'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:283:in `map'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/parallel-1.20.1/lib/parallel.rb:232:in `each'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:67:in `warm_cache'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:46:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command.rb:11:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/environment.rb:18:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli.rb:71:in `run_command'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli.rb:78:in `execute_runners'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli.rb:47:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/exe/rubocop:12:in `block in <top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/exe/rubocop:12:in `<top (required)>'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `load'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `<top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:63:in `load'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:63:in `kernel_load'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:28:in `run'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:480:in `exec'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:30:in `dispatch'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:24:in `start'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.3.0.dev/exe/bundle:49:in `block in <top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.3.0.dev/exe/bundle:37:in `<top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/bin/bundle:23:in `load'
/Users/masafumi.koba/.rbenv/versions/3.0.2/bin/bundle:23:in `<main>'
Inspecting 1 file
Scanning /private/tmp/rubocop-rails-repro/app/models/user.rb
undefined method `first' for nil:NilClass
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-rails-2.12.0/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:117:in `valid_options?'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-rails-2.12.0/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:80:in `on_send'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:134:in `each'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.11.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.11.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cop/team.rb:83:in `investigate'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:310:in `inspect_file'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:254:in `block in do_inspection_loop'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:288:in `block in iterate_until_no_changes'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:281:in `loop'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:281:in `iterate_until_no_changes'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:250:in `do_inspection_loop'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:130:in `block in file_offenses'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:155:in `file_offense_cache'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:129:in `file_offenses'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:120:in `process_file'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:100:in `each'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:100:in `reduce'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:86:in `inspect_files'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/runner.rb:47:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/command.rb:11:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli/environment.rb:18:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli.rb:71:in `run_command'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli.rb:78:in `execute_runners'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/lib/rubocop/cli.rb:47:in `run'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/exe/rubocop:12:in `block in <top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/gems/rubocop-1.20.0/exe/rubocop:12:in `<top (required)>'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `load'
/private/tmp/rubocop-rails-repro/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `<top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:63:in `load'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:63:in `kernel_load'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:28:in `run'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:480:in `exec'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:30:in `dispatch'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:24:in `start'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.3.0.dev/exe/bundle:49:in `block in <top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/Users/masafumi.koba/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.3.0.dev/exe/bundle:37:in `<top (required)>'
/Users/masafumi.koba/.rbenv/versions/3.0.2/bin/bundle:23:in `load'
/Users/masafumi.koba/.rbenv/versions/3.0.2/bin/bundle:23:in `<main>'
.

1 file inspected, no offenses detected
Finished in 0.5217470000497997 seconds

Steps to reproduce the problem

Prepare Gemfile:

source "https://rubygems.org"

gem "rubocop", "= 1.20.0"
gem "rubocop-rails", "= 2.12.0"

Prepare app/models/user.rb:

class User < ApplicationRecord
  has_many :articles, -> { where(active: true) }, class_name: "Article"
end

Run: bundle install

Run: bundle exec rubocop --debug app/models/user.rb

You should see the error above.

RuboCop version

$ bundle exec rubocop -V
1.20.0 (using Parser 3.0.2.0, rubocop-ast 1.11.0, running on ruby 3.0.2 x86_64-darwin20)
  - rubocop-rails 2.12.0
@koic koic added the bug Something isn't working label Sep 9, 2021
koic added a commit to koic/rubocop-rails that referenced this issue Sep 9, 2021
Fixes rubocop#535.

This PR fixes an error for `Rails/HasManyOrHasOneDependent`
when using lambda argument and not specifying any options.
@koic
Copy link
Member

koic commented Sep 9, 2021

Thanks for your early feedback. I've opened #536.

Hi there, are you enjoying RubyKaigi 2021 Takeout? 😄

Yep! Enjoy RubyKaigi Takeout 2021! Thank you!

@ybiquitous
Copy link
Contributor Author

Awesome! Also, thank you so much for the nice talk! 😊 👏🏼

@koic
Copy link
Member

koic commented Sep 9, 2021

Wow, Thank you!

@koic koic closed this as completed in #536 Sep 9, 2021
koic added a commit that referenced this issue Sep 9, 2021
…_one_dependent

[Fix #535] Fix an error for `Rails/HasManyOrHasOneDependent`
@imajes
Copy link

imajes commented Sep 9, 2021

Can we get this rolled out asap? it's going to make anyone who updated to 2.12 and have automated systems block builds etc. :(

@ybiquitous
Copy link
Contributor Author

@koic Thanks for the quick release of 2.12.1! I can confirm the error has been successfully fixed! 👍🏼

@koic
Copy link
Member

koic commented Sep 10, 2021

@imajes RuboCop Rails 2.12.1 has been released! @ybiquitous Thank you for confirmation!

@imajes
Copy link

imajes commented Sep 10, 2021

Thanks @koic !

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.

3 participants