Skip to content

Commit

Permalink
Merge pull request #1349 from fatkodima/application_record_ignore-mig…
Browse files Browse the repository at this point in the history
…rations

Change `Rails/ApplicationRecord` to ignore migrations
  • Loading branch information
koic authored Sep 4, 2024
2 parents 9138f7b + ff07593 commit 93f9a89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1342](https://github.com/rubocop/rubocop-rails/issues/1342): Change `Rails/ApplicationRecord` to ignore migrations. ([@fatkodima][])
4 changes: 3 additions & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ Rails/ApplicationRecord:
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.49'
VersionChanged: '2.5'
VersionChanged: '<<next>>'
Exclude:
- db/**/*.rb

Rails/ArelStar:
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/rails/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module Cop
module Rails
# Checks that models subclass `ApplicationRecord` with Rails 5.0.
#
# It is a common practice to define models inside migrations in order to retain forward
# compatibility by avoiding loading any application code. And so migration files are excluded
# by default for this cop.
#
# @safety
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationRecord`
# sneak into an Active Record model that is not purposed to inherit logic common among other
Expand Down

0 comments on commit 93f9a89

Please sign in to comment.