Allow has_and_belongs_to_many to reduce code

The Rails/HasAndBelongsToMany rule wants model classes for all
many-to-many relationship tables in the database. But our team thinks
that it's useful to declare has_and_belongs_to_many relationships which
don't require an additional model.
This commit is contained in:
Maikel Linke
2023-08-21 10:04:29 +10:00
parent 241239ac68
commit ff18270898
2 changed files with 7 additions and 13 deletions

View File

@@ -53,6 +53,13 @@ Rails/ApplicationRecord:
# Migrations should not contain application code:
- "db/migrate/*.rb"
# Allow many-to-many associations without explicit model.
# - It avoids the additional code of a model class.
# - It simplifies the declaration of the association.
# - Rails may know that there are no callbacks associated.
Rails/HasAndBelongsToMany:
Enabled: false
Rails/SkipsModelValidations:
AllowedMethods:
- "touch"

View File

@@ -419,19 +419,6 @@ Rails/ActiveRecordOverride:
Exclude:
- 'app/models/spree/product.rb'
# Offense count: 8
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/order_cycle.rb'
- 'app/models/spree/role.rb'
- 'app/models/spree/shipping_method.rb'
- 'app/models/spree/user.rb'
- 'app/models/spree/zone.rb'
# Offense count: 47
# Configuration parameters: Include.
# Include: app/models/**/*.rb