Class: RuboCop::Cop::Primer::DeprecatedButtonArguments
- Extended by:
- AutoCorrector
- 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
#on_send(node) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubocop/cop/primer/deprecated_button_arguments.rb', line 30 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) do |corrector| corrector.replace(pair.key, DEPRECATIONS[pair.key.value]) end end |