Class: RuboCop::Cop::Chef::Correctness::CookbookUsesNodeSave

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/chef/correctness/node_save.rb

Overview

Don’t use node.save to save partial node data to the Chef Infra Server mid-run unless it’s a requirement of cookbook design that can’t be avoided. Node.save can result in failed Chef Infra runs appearing in search and increases load on the Chef Infra Server.“

Examples:


### incorrect
node.save

Constant Summary collapse

MSG =
"Don't use node.save to save partial node data to the Chef Infra Server mid-run unless it's absolutely necessary. Node.save can result in failed Chef Infra runs appearing in search and increases load on the Chef Infra Server."
RESTRICT_ON_SEND =
[:save].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



37
38
39
40
41
# File 'lib/rubocop/cop/chef/correctness/node_save.rb', line 37

def on_send(node)
  node_save?(node) do
    add_offense(node, severity: :refactor)
  end
end