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

Rails/HasManyOrHasOneDependent with paranoia gem #14

Closed
printercu opened this issue Sep 19, 2018 · 7 comments
Closed

Rails/HasManyOrHasOneDependent with paranoia gem #14

printercu opened this issue Sep 19, 2018 · 7 comments

Comments

@printercu
Copy link

Moved from rubocop/rubocop#5285

Hi!

Do you have any suggestions how to use gems providing soft-delete (like paranoia) with HasManyOrHasOneDependent cop: I think it's usual to not provide dependent option to has_many when parent is soft-deletable. Is it supposed just to use rubocop:disable for offences in such cases?

RuboCop version

$ rubocop -V
0.52.0 (using Parser 2.4.0.2, running on ruby 2.4.1 x86_64-darwin16)
@ericboehs
Copy link

I also have this question. I think using a magic comment disable makes sense but I wish there was a better option. How better could RuboCop know to ignore this rule in this scenario?

@koic
Copy link
Member

koic commented May 12, 2021

Currently RuboCop Rails does not have a configuration for option regarding combination with 3rd party gem. If you'd like to suppress the warn quickly , please make the following setting.

# Specify `dependet: nil`.
has_many :articles, dependent: nil

Further details: #467

or

# Your .rubocop.yml
Rails/HasManyOrHasOneDependent:
  Enabled: false

Thank you.

@koic koic closed this as completed May 12, 2021
@gingerlime
Copy link

I bumped into this as well (similar scenario, not specific to the gem), but when I specify :dependent => nil I'm still getting a rubocop offense.

app/models/custom_quiz.rb:29:3: C: Rails/HasManyOrHasOneDependent: Specify a :dependent option.
  has_many :training_sessions, :dependent => nil
  ^^^^^^^^

@koic
Copy link
Member

koic commented May 13, 2021

@gingerlime Is it happening in the latest RuboCop Rails 2.10? Can you provide the result of (bundle exec) rubocop -V?

@gingerlime
Copy link

# rubocop -V
0.93.1 (using Parser 3.0.1.1, rubocop-ast 1.5.0, running on ruby 2.6.5 x86_64-linux)
# cat Gemfile.lock |grep rubocop-rails
    rubocop-rails (2.9.1)

@koic
Copy link
Member

koic commented May 13, 2021

The gems need to be updated and RuboCop Rails 2.10 requires RuboCop 1.7 or higher. Please bundle update rubocop rubocop-rails.
https://rubygems.org/gems/rubocop-rails/versions/2.10.1

@gingerlime
Copy link

Strange, but when I run bundle update rubocop rubocop-rails nothing changes... We're using pronto and pronto-haml seem to require rubocop < 1.0 so I guess that's the reason ... sorry about the false alarm. I will check with the pronto project and see if they can let us upgrade...

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

4 participants