Skip to content

Commit 93f9a89

Browse files
authored
Merge pull request #1349 from fatkodima/application_record_ignore-migrations
Change `Rails/ApplicationRecord` to ignore migrations
2 parents 9138f7b + ff07593 commit 93f9a89

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1342](https://github.com/rubocop/rubocop-rails/issues/1342): Change `Rails/ApplicationRecord` to ignore migrations. ([@fatkodima][])

config/default.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ Rails/ApplicationRecord:
212212
Enabled: true
213213
SafeAutoCorrect: false
214214
VersionAdded: '0.49'
215-
VersionChanged: '2.5'
215+
VersionChanged: '<<next>>'
216+
Exclude:
217+
- db/**/*.rb
216218

217219
Rails/ArelStar:
218220
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'

lib/rubocop/cop/rails/application_record.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module Cop
55
module Rails
66
# Checks that models subclass `ApplicationRecord` with Rails 5.0.
77
#
8+
# It is a common practice to define models inside migrations in order to retain forward
9+
# compatibility by avoiding loading any application code. And so migration files are excluded
10+
# by default for this cop.
11+
#
812
# @safety
913
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationRecord`
1014
# sneak into an Active Record model that is not purposed to inherit logic common among other

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy