Class: RuboCop::Cop::Chef::Deprecations::ResourceUsesUpdatedMethod

Inherits:
Base
  • 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/.

Examples:


### incorrect
action :foo do
  updated = true
end

### correct
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."

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_lvasgn(node) ⇒ Object



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

def on_lvasgn(node)
  add_offense(node, severity: :warning) if node.node_parts.first == :updated
end