rubocop-rails
rubocop-rails copied to clipboard
Rails/HasManyOrHasOneDependent should check if the rule already matches for a relation without limiting scope
Rails/HasManyOrHasOneDependent should check if the rule already matches for a relation without limiting scope
has_many :children, -> { dependent: :destroy, inverse_of: :parent, class_name: 'Parent'
has_many :boy_children, -> { where(sex: 'boy') }, inverse_of: :parent, class_name: 'parent' # Needs rubocop:disable Rails/HasManyOrHasOneDependent
The second, scope-limited, relation should not need the dependent: destroy.
Expected behavior
The second, scope-limited, relation should not give a rule violation
Actual behavior
Rubocop shows rule violations
Steps to reproduce the problem
See above code example.
RuboCop version
Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-rails, rubocop-performance, and others) output by rubocop -V,
include them as well. Here's an example:
1.21.0 (using Parser 3.0.2.0, rubocop-ast 1.11.0, running on ruby 2.7.3 x86_64-darwin20)
- rubocop-performance 1.11.5
- rubocop-rails 2.12.2
- rubocop-rake 0.6.0
- rubocop-rspec 2.4.0
dup of https://github.com/rubocop/rubocop-rails/issues/541?
oh i guess not nvm
@koic This one is preventing me from upgrading, unless there is a workaround I am not thinking of? I think you've been working on this cop recently. Thoughts?