Skip to content

Commit

Permalink
Use RESTRICT_ON_SEND
Browse files Browse the repository at this point in the history
Follow rubocop/rubocop#8365

This PR uses `RESTRICT_ON_SEND` to restrict callbacks `on_send`
to specific method names only.
  • Loading branch information
koic committed Aug 20, 2021
1 parent 229c803 commit bf2712f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rubocop/cop/sequel/column_default.rb
Expand Up @@ -6,6 +6,7 @@ module Sequel
# ColumnDefault looks for column creation with a default value.
class ColumnDefault < Base
MSG = "Don't create new column with default values"
RESTRICT_ON_SEND = %i[add_column].freeze

def_node_matcher :add_column_default?, <<-MATCHER
(send _ :add_column ... (hash (pair (sym :default) _)))
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/sequel/concurrent_index.rb
Expand Up @@ -6,6 +6,7 @@ module Sequel
# ConcurrentIndex looks for non-concurrent index creation.
class ConcurrentIndex < Base
MSG = 'Prefer creating or dropping new index concurrently'
RESTRICT_ON_SEND = %i[add_index drop_index].freeze

def_node_matcher :indexes?, <<-MATCHER
(send _ {:add_index :drop_index} $...)
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/sequel/json_column.rb
Expand Up @@ -6,6 +6,7 @@ module Sequel
# JSONColumn looks for non-JSONB columns.
class JSONColumn < Base
MSG = 'Use JSONB rather than JSON or hstore'
RESTRICT_ON_SEND = %i[add_column].freeze

def_node_matcher :json_or_hstore?, <<-MATCHER
(send _ :add_column ... (sym {:json :hstore}))
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/sequel/partial_constraint.rb
Expand Up @@ -6,6 +6,7 @@ module Sequel
# PartialConstraint looks for missed usage of partial indexes.
class PartialConstraint < Base
MSG = "Constraint can't be partial, use where argument with index"
RESTRICT_ON_SEND = %i[add_unique_constraint].freeze

def_node_matcher :add_partial_constraint?, <<-MATCHER
(send _ :add_unique_constraint ... (hash (pair (sym :where) _)))
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/sequel/save_changes.rb
Expand Up @@ -9,6 +9,7 @@ class SaveChanges < Base

MSG = 'Use `Sequel::Model#save_changes` instead of '\
'`Sequel::Model#save`.'
RESTRICT_ON_SEND = %i[save].freeze

def_node_matcher :model_save?, <<-MATCHER
(send _ :save)
Expand Down

0 comments on commit bf2712f

Please sign in to comment.