Class: RuboCop::Cop::Chef::Deprecations::ExecutePathProperty

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

Overview

In Chef Infra Client 13 and later you must set path env vars in execute resources using the ‘environment` property not the legacy `path` property.

Examples:


### incorrect
execute 'some_cmd' do
  path '/foo/bar'
end

### correct
execute 'some_cmd' do
  environment {path: '/foo/bar'}
end

Constant Summary collapse

MSG =
'In Chef Infra Client 13 and later you must set path env vars in execute resources using the `environment` property not the legacy `path` property.'

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



41
42
43
44
45
# File 'lib/rubocop/cop/chef/deprecation/execute_path_property.rb', line 41

def on_block(node)
  match_property_in_resource?(:execute, 'path', node) do |offense|
    add_offense(offense, severity: :warning) # @todo: we could probably autocorrect this with some work
  end
end