Class: RuboCop::Cop::Chef::ChefDeprecations::ResourceUsesUpdatedMethod

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

Overview

Don’t call the deprecated updated= method in a resource to set the resource to updated. This method was removed from Chef Infra Client 13 and this will now cause an error. Instead wrap code that updated the state of the node in a converge_by block. Documentation on using the converge_by block can be found at docs.chef.io/custom_resources.html.

Examples:


# bad
action :foo do
  updated = true
end

# good
action :foo do
  converge_by('resource did something) do
    # code that causes the resource to converge
  end

Constant Summary collapse

MSG =
"Don't use updated = true/false to update resource state. This will cause failures in Chef Infra Client 13 and later.".freeze

Instance Method Summary collapse

Instance Method Details

#on_lvasgn(node) ⇒ Object



39
40
41
# File 'lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb', line 39

def on_lvasgn(node)
  add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.node_parts.first == :updated
end