We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider
class User1 < ApplicationRecord belongs_to :company, -> { where(foo: true) } validates :company_id, presence: true end class User2 < ApplicationRecord belongs_to :company, inverse_of: :employee validates :company_id, presence: true end class User3 < ApplicationRecord belongs_to :company, -> { where(foo: true) }, inverse_of: :employee validates :company_id, presence: true end
Rails/RedundantPresenceValidationOnBelongsTo flags User1 and User2 as offenses, but not User3.
Rails/RedundantPresenceValidationOnBelongsTo
User1
User2
User3
All three examples should be flagged as offenses as they perform redundant presence validations on company_id
company_id
$ [bundle exec] rubocop -V 1.36.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 2.6.9) [x86_64-darwin21] - rubocop-minitest 0.22.1 - rubocop-performance 1.15.0 - rubocop-rails 2.16.1
The text was updated successfully, but these errors were encountered:
Strange, when we use company instead company_id, it works:
class User3 < ApplicationRecord belongs_to :company, -> { where(foo: true) }, inverse_of: :employee validates :company, presence: true end
I can try to fix this one
Sorry, something went wrong.
[Fix rubocop#792] Fixes a false negative for Rails/RedundantPresenceV…
cc0d47d
…alidationOnBelongsTo
ceeebe4
2e22634
Merge pull request #814 from PedroAugustoRamalhoDuarte/fix/fixes_fals…
e7f9546
…e_negative_for_rails_redundant_presence_validation_on_belongs_to [Fix #792] Fixes a false negative for Rails/RedundantPresenceValidationOnBelongsTo
No branches or pull requests
Consider
Rails/RedundantPresenceValidationOnBelongsTo
flagsUser1
andUser2
as offenses, but notUser3
.Expected Behavior
All three examples should be flagged as offenses as they perform redundant presence validations on
company_id
RuboCop version
The text was updated successfully, but these errors were encountered: