Class: RuboCop::Cop::Chef::AttributeMetadata

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/chef/deprecation/attribute_metadata.rb

Overview

Don’t use the deprecated ‘attribute’ metadata value

Examples:


# bad in metadata.rb:

 attribute 'zookeeper_bridge/server',
           display_name: 'zookeeper server',
           description: 'Zookeeper server address.',
           type: 'string',
           required: 'optional',
           default: '"127.0.0.1:2181"'

Constant Summary collapse

MSG =
"Don't use the deprecated 'attribute' metadata value".freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



41
42
43
44
45
# File 'lib/rubocop/cop/chef/deprecation/attribute_metadata.rb', line 41

def autocorrect(node)
  lambda do |corrector|
    corrector.remove(node.loc.expression)
  end
end

#on_send(node) ⇒ Object



37
38
39
# File 'lib/rubocop/cop/chef/deprecation/attribute_metadata.rb', line 37

def on_send(node)
  add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :attribute
end