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

Change Rails/ApplicationRecord to ignore migrations #1349

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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