Class: RuboCop::Cop::Primer::DeprecatedButtonArguments
- Defined in:
- lib/rubocop/cop/primer/deprecated_button_arguments.rb
Overview
This cop ensures that ‘ButtonComponent` doesn’t use deprecated arguments.
bad ButtonComponent.new(variant: :small)
good ButtonComponent.new(size: :small)
Constant Summary collapse
- INVALID_MESSAGE =
<<~STR `variant` is deprecated. Use `size` instead. STR
- DEPRECATIONS =
{ variant: :size }.freeze
Instance Method Summary collapse
Methods inherited from BaseCop
Instance Method Details
#autocorrect(node) ⇒ Object
43 44 45 46 47 |
# File 'lib/rubocop/cop/primer/deprecated_button_arguments.rb', line 43 def autocorrect(node) lambda do |corrector| corrector.replace(node, DEPRECATIONS[node.value]) end end |
#on_send(node) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/primer/deprecated_button_arguments.rb', line 29 def on_send(node) return unless (node) kwargs = node.arguments.last return if kwargs.nil? pair = kwargs.pairs.find { |x| x.key.value == :variant } return if pair.nil? add_offense(pair.key, message: INVALID_MESSAGE) end |