Class: RuboCop::Cop::Chef::Correctness::ResourceSetsInternalProperties

Inherits:
Base
  • Object
show all
Includes:
RuboCop::Chef::CookbookHelpers
Defined in:
lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb

Overview

Chef Infra Client uses properties in several resources to track state. These should not be set in recipes as they break the internal workings of the Chef Infra Client

Examples:


### incorrect
service 'foo' do
  running true
  action [:start, :enable]
end

### correct
service 'foo' do
  action [:start, :enable]
end

Constant Summary collapse

MSG =
'Do not set properties used internally by Chef Infra Client to track the system state.'

Instance Method Summary collapse

Methods included from RuboCop::Chef::CookbookHelpers

#match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_block(node) ⇒ Object



42
43
44
45
46
# File 'lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb', line 42

def on_block(node)
  match_property_in_resource?(:service, 'running', node) do |prop|
    add_offense(prop, severity: :refactor)
  end
end