Skip to content

Commit 20042f6

Browse files
committed
Support :: prefixed constants on some cops
1 parent 24b2e87 commit 20042f6

39 files changed

+304
-28
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#868](https://github.com/rubocop/rubocop-rails/pull/868): Support `::` prefixed constants on `Rails/ActionControllerFlashBeforeRender`, `Rails/ActionControllerTestCase`, `Rails/ApplicationController`, `Rails/ApplicationJob`, `Rails/ApplicationMailer`, `Rails/ApplicationRecord`, `Rails/DotSeparatedKeys`, `Rails/DynamicFindBy`, `Rails/FindEach`, `Rails/FreezeTime`, `Rails/HasManyOrHasOneDependent`, `Rails/HelperInstanceVariable`, `Rails/MailerName`, `Rails/MigrationClassName`, `Rails/Output`, `Rails/ReversibleMigrationMethodDefinition`, `Rails/ReversibleMigration`, `Rails/ShortI18n`, `Rails/SkipsModelValidations`, and `Rails/TimeZoneAssignment`. ([@r7kamura][])

lib/rubocop/cop/mixin/active_record_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module ActiveRecordHelper
1010

1111
def_node_matcher :active_record?, <<~PATTERN
1212
{
13-
(const nil? :ApplicationRecord)
14-
(const (const nil? :ActiveRecord) :Base)
13+
(const {nil? cbase} :ApplicationRecord)
14+
(const (const {nil? cbase} :ActiveRecord) :Base)
1515
}
1616
PATTERN
1717

lib/rubocop/cop/mixin/migrations_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module MigrationsHelper
88

99
def_node_matcher :migration_class?, <<~PATTERN
1010
(class
11-
(const nil? _)
11+
(const {nil? cbase} _)
1212
(send
1313
(const (const {nil? cbase} :ActiveRecord) :Migration)
1414
:[]

lib/rubocop/cop/rails/action_controller_flash_before_render.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class ActionControllerFlashBeforeRender < Base
4343

4444
def_node_search :action_controller?, <<~PATTERN
4545
{
46-
(const nil? :ApplicationController)
47-
(const (const nil? :ActionController) :Base)
46+
(const {nil? cbase} :ApplicationController)
47+
(const (const {nil? cbase} :ActionController) :Base)
4848
}
4949
PATTERN
5050

lib/rubocop/cop/rails/action_controller_test_case.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ActionControllerTestCase < Base
3030

3131
def_node_matcher :action_controller_test_case?, <<~PATTERN
3232
(class
33-
(const nil? _)
33+
(const {nil? cbase} _)
3434
(const (const {nil? cbase} :ActionController) :TestCase) _)
3535
PATTERN
3636

lib/rubocop/cop/rails/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ApplicationController < Base
2525

2626
MSG = 'Controllers should subclass `ApplicationController`.'
2727
SUPERCLASS = 'ApplicationController'
28-
BASE_PATTERN = '(const (const nil? :ActionController) :Base)'
28+
BASE_PATTERN = '(const (const {nil? cbase} :ActionController) :Base)'
2929

3030
# rubocop:disable Layout/ClassStructure
3131
include RuboCop::Cop::EnforceSuperclass

lib/rubocop/cop/rails/application_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ApplicationJob < Base
2828

2929
MSG = 'Jobs should subclass `ApplicationJob`.'
3030
SUPERCLASS = 'ApplicationJob'
31-
BASE_PATTERN = '(const (const nil? :ActiveJob) :Base)'
31+
BASE_PATTERN = '(const (const {nil? cbase} :ActiveJob) :Base)'
3232

3333
# rubocop:disable Layout/ClassStructure
3434
include RuboCop::Cop::EnforceSuperclass

lib/rubocop/cop/rails/application_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ApplicationMailer < Base
2828

2929
MSG = 'Mailers should subclass `ApplicationMailer`.'
3030
SUPERCLASS = 'ApplicationMailer'
31-
BASE_PATTERN = '(const (const nil? :ActionMailer) :Base)'
31+
BASE_PATTERN = '(const (const {nil? cbase} :ActionMailer) :Base)'
3232

3333
# rubocop:disable Layout/ClassStructure
3434
include RuboCop::Cop::EnforceSuperclass

lib/rubocop/cop/rails/application_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ApplicationRecord < Base
2929

3030
MSG = 'Models should subclass `ApplicationRecord`.'
3131
SUPERCLASS = 'ApplicationRecord'
32-
BASE_PATTERN = '(const (const nil? :ActiveRecord) :Base)'
32+
BASE_PATTERN = '(const (const {nil? cbase} :ActiveRecord) :Base)'
3333

3434
# rubocop:disable Layout/ClassStructure
3535
include RuboCop::Cop::EnforceSuperclass

lib/rubocop/cop/rails/dot_separated_keys.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DotSeparatedKeys < Base
2424
TRANSLATE_METHODS = %i[translate t].freeze
2525

2626
def_node_matcher :translate_with_scope?, <<~PATTERN
27-
(send {nil? (const nil? :I18n)} {:translate :t} ${sym_type? str_type?}
27+
(send {nil? (const {nil? cbase} :I18n)} {:translate :t} ${sym_type? str_type?}
2828
(hash <$(pair (sym :scope) ${array_type? sym_type?}) ...>)
2929
)
3030
PATTERN

0 commit comments

Comments
 (0)