Class: RuboCop::Cop::Chewy::FieldType
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Chewy::FieldType
- Defined in:
- lib/rubocop/cop/chewy/field_type.rb
Overview
This cop force to specify a type for Chewy field
# bad
field :name
# good
field :name, type: 'text'
Constant Summary collapse
- MSG =
'Specify a `type` for Chewy field.'
- RESTRICT_ON_SEND =
%i[field].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
23 24 25 26 27 |
# File 'lib/rubocop/cop/chewy/field_type.rb', line 23 def on_send(node) return if (node) add_offense(node) end |
#options_has_field?(node) ⇒ Object
19 20 21 |
# File 'lib/rubocop/cop/chewy/field_type.rb', line 19 def_node_matcher :options_has_field?, <<~PATTERN (send nil? :field (sym _)+ (hash <(pair (sym :type) {str sym}) ...>)) PATTERN |