Class: RuboCop::Cop::Chef::Deprecations::ExecuteRelativeCreatesWithoutCwd
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Chef::Deprecations::ExecuteRelativeCreatesWithoutCwd
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb
Overview
In Chef Infra Client 13 and later you must either specific an absolute path when using the ‘execute` resource’s ‘creates` property or also use the `cwd` property.
Constant Summary collapse
- MSG =
"In Chef Infra Client 13 and later you must either specific an absolute path when using the `execute` resource's `creates` property or also use the `cwd` 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
Instance Method Details
#on_block(node) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb', line 46 def on_block(node) match_property_in_resource?(:execute, 'creates', node) do |offense| return unless offense.arguments.count == 1 # we can only analyze simple string args return unless offense.arguments.first.str_type? # we can only analyze simple string args # skip any creates that are abs paths https://rubular.com/r/3TbDsgcAa1EaIF return if offense.arguments.first.value.match?(%r{^(/|[a-zA-Z]:)}) # return if we have a cwd property match_property_in_resource?(:execute, 'cwd', node) do return end add_offense(offense, severity: :warning) end end |