class RuboCop::Cop::InSpecStyle::DeprecatedAttributes

Checks if deprecated method attribute is used.

@example EnforcedStyle: InSpecStyle (default)

# Attributes have been deprecated for inputs
# https://github.com/inspec/inspec/issues/3802

# bad
attribute('my_element', value: 10)

# good
input('my_element', value: 10)

Constants

MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/inspecstyle/deprecated_attributes.rb, line 34
def autocorrect(node)
  lambda do |corrector|
    corrector.replace(offense_range(node), preferred_replacement)
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/inspecstyle/deprecated_attributes.rb, line 28
def on_send(node)
  return unless attribute?(node)

  add_offense(node, location: node.loc.selector)
end

Private Instance Methods

offense_range(node) click to toggle source
# File lib/rubocop/cop/inspecstyle/deprecated_attributes.rb, line 42
def offense_range(node)
  node.loc.selector
end
preferred_replacement() click to toggle source
# File lib/rubocop/cop/inspecstyle/deprecated_attributes.rb, line 46
def preferred_replacement
  cop_config.fetch('PreferredReplacement')
end