Class: RuboCop::Cop::Chef::ChefCorrectness::ResourceSetsInternalProperties

Inherits:
RuboCop::Cop
  • 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:


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

# good
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.'.freeze

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

Instance Method Details

#on_block(node) ⇒ Object



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

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