Class: RuboCop::Cop::Chef::Deprecations::NodeDeepFetch

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/deprecation/node_deep_fetch.rb

Overview

The node.deep_fetch method has been removed from Chef-Sugar, and must be replaced by the node.read API.

Examples:


### incorrect
node.deep_fetch("foo")

### correct
node.read("foo")

### incorrect
node.deep_fetch!("foo")

### correct
node.read!("foo")

Constant Summary collapse

RESTRICT_ON_SEND =
[:deep_fetch, :deep_fetch!].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/rubocop/cop/chef/deprecation/node_deep_fetch.rb', line 46

def on_send(node)
  node_deep_fetch?(node) do
    add_offense(node.loc.selector, message: "Do not use node.#{node.method_name}. Replace with node.#{fix_name(node.method_name)} to keep identical behavior.", severity: :warning) do |corrector|
      corrector.replace(node.loc.selector, fix_name(node.method_name))
    end
  end
end