config/default.yml in rubocop-rails-2.6.0 vs config/default.yml in rubocop-rails-2.7.0
- old
+ new
@@ -35,10 +35,18 @@
Use `update!` instead of `update_attributes!`.
Enabled: true
VersionAdded: '0.53'
SafeAutoCorrect: false
+Rails/ActiveRecordCallbacksOrder:
+ Description: 'Order callback declarations in the order in which they will be executed.'
+ StyleGuide: 'https://rails.rubystyle.guide/#callbacks-order'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+ Include:
+ - app/models/**/*.rb
+
Rails/ActiveRecordOverride:
Description: >-
Check for overriding Active Record methods instead of using
callbacks.
Enabled: true
@@ -151,10 +159,16 @@
EnforcedStyle: flexible
SupportedStyles:
- strict
- flexible
+Rails/DefaultScope:
+ Description: 'Avoid use of `default_scope`.'
+ StyleGuide: 'https://rails.rubystyle.guide#avoid-default-scope'
+ Enabled: false
+ VersionAdded: '2.7'
+
Rails/Delegate:
Description: 'Prefer delegate method for delegations.'
Enabled: true
VersionAdded: '0.21'
VersionChanged: '0.50'
@@ -232,10 +246,18 @@
Enabled: true
VersionAdded: '0.30'
Include:
- app/models/**/*.rb
+Rails/FindById:
+ Description: >-
+ Favor the use of `find` over `where.take!`, `find_by!`, and `find_by_id!` when you
+ need to retrieve a single record by primary key when you expect it to be found.
+ StyleGuide: 'https://rails.rubystyle.guide/#find'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+
Rails/FindEach:
Description: 'Prefer all.find_each over all.find.'
StyleGuide: 'https://rails.rubystyle.guide#find-each'
Enabled: true
VersionAdded: '0.30'
@@ -298,10 +320,16 @@
Rails/IndexWith:
Description: 'Prefer `index_with` over `each_with_object` or `map`.'
Enabled: true
VersionAdded: '2.5'
+Rails/Inquiry:
+ Description: "Prefer Ruby's comparison operators over Active Support's `Array#inquiry` and `String#inquiry`."
+ StyleGuide: 'https://rails.rubystyle.guide/#inquiry'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+
Rails/InverseOf:
Description: 'Checks for associations where the inverse cannot be determined automatically.'
Enabled: true
VersionAdded: '0.52'
Include:
@@ -323,10 +351,35 @@
- https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
- https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
Enabled: true
VersionAdded: '0.62'
+Rails/MailerName:
+ Description: 'Mailer should end with `Mailer` suffix.'
+ StyleGuide: 'https://rails.rubystyle.guide/#mailer-name'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+ Include:
+ - app/mailers/**/*.rb
+
+Rails/MatchRoute:
+ Description: >-
+ Don't use `match` to define any routes unless there is a need to map multiple request types
+ among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
+ StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+ Include:
+ - config/routes.rb
+ - config/routes/**/*.rb
+
+Rails/NegateInclude:
+ Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
+ StyleGuide: 'https://rails.rubystyle.guide#exclude'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+
Rails/NotNullColumn:
Description: 'Do not add a NOT NULL column without a default value.'
Enabled: true
VersionAdded: '0.43'
Include:
@@ -348,14 +401,34 @@
Enabled: true
VersionAdded: '0.41'
Rails/Pick:
Description: 'Prefer `pick` over `pluck(...).first`.'
+ StyleGuide: 'https://rails.rubystyle.guide#pick'
Enabled: true
Safe: false
VersionAdded: '2.6'
+Rails/Pluck:
+ Description: 'Prefer `pluck` over `map { ... }`.'
+ StyleGuide: 'https://rails.rubystyle.guide#pluck'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+
+Rails/PluckId:
+ Description: 'Use `ids` instead of `pluck(:id)` or `pluck(primary_key)`.'
+ StyleGuide: 'https://rails.rubystyle.guide/#ids'
+ Enabled: 'pending'
+ Safe: false
+ VersionAdded: '2.7'
+
+Rails/PluckInWhere:
+ Description: 'Use `select` instead of `pluck` in `where` query methods.'
+ Enabled: 'pending'
+ Safe: false
+ VersionAdded: '2.7'
+
Rails/PluralizationGrammar:
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
Enabled: true
VersionAdded: '0.35'
@@ -439,10 +512,24 @@
Enabled: true
VersionAdded: '0.48'
VersionChanged: '0.59'
AutoCorrect: false
+Rails/RenderInline:
+ Description: 'Prefer using a template over inline rendering.'
+ StyleGuide: 'https://rails.rubystyle.guide/#inline-rendering'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+
+Rails/RenderPlainText:
+ Description: 'Prefer `render plain:` over `render text:`.'
+ StyleGuide: 'https://rails.rubystyle.guide/#plain-text-rendering'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+ # Convert only when `content_type` is explicitly set to `text/plain`.
+ ContentTypeCompatibility: true
+
Rails/RequestReferer:
Description: 'Use consistent syntax for request.referer.'
Enabled: true
VersionAdded: '0.41'
EnforcedStyle: referer
@@ -496,31 +583,48 @@
Enabled: true
VersionAdded: '0.19'
Include:
- app/models/**/*.rb
+Rails/ShortI18n:
+ Description: 'Use the short form of the I18n methods: `t` instead of `translate` and `l` instead of `localize`.'
+ StyleGuide: 'https://rails.rubystyle.guide/#short-i18n'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
+ EnforcedStyle: conservative
+ SupportedStyles:
+ - conservative
+ - aggressive
+
Rails/SkipsModelValidations:
Description: >-
Use methods that skips model validations with caution.
See reference for more information.
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
Enabled: true
VersionAdded: '0.47'
- VersionChanged: '0.60'
- Blacklist:
+ VersionChanged: '2.7'
+ ForbiddenMethods:
- decrement!
- decrement_counter
- increment!
- increment_counter
+ - insert
+ - insert!
+ - insert_all
+ - insert_all!
- toggle!
- touch
+ - touch_all
- update_all
- update_attribute
- update_column
- update_columns
- update_counters
- Whitelist: []
+ - upsert
+ - upsert_all
+ AllowedMethods: []
Rails/TimeZone:
Description: 'Checks the correct usage of time zone aware methods.'
StyleGuide: 'https://rails.rubystyle.guide#time'
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
@@ -567,9 +671,14 @@
Enabled: true
VersionAdded: '0.9'
VersionChanged: '0.41'
Include:
- app/models/**/*.rb
+
+Rails/WhereExists:
+ Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
+ Enabled: 'pending'
+ VersionAdded: '2.7'
# Accept `redirect_to(...) and return` and similar cases.
Style/AndOr:
EnforcedStyle: conditionals