Class: RuboCop::Cop::Chef::Deprecations::WindowsTaskChangeAction

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Includes:
RuboCop::Chef::CookbookHelpers
Defined in:
lib/rubocop/cop/chef/deprecation/windows_task_change_action.rb

Overview

The :change action in the windows_task resource was removed when windows_task was added to Chef Infra Client 13+ The default action of :create should can now be used to create an update tasks.

Examples:


### incorrect
windows_task 'chef ad-join leave start time' do
  task_name 'chef ad-join leave'
  start_day '06/09/2016'
  start_time '01:00'
  action [:change, :create]
end

### correct
windows_task 'chef ad-join leave start time' do
  task_name 'chef ad-join leave'
  start_day '06/09/2016'
  start_time '01:00'
  action :create
end

Constant Summary collapse

MSG =
'The :change action in the windows_task resource was removed when windows_task was added to Chef Infra Client 13+. The default action of :create should can now be used to create an update tasks.'

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

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



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubocop/cop/chef/deprecation/windows_task_change_action.rb', line 52

def on_block(node)
  match_property_in_resource?(:windows_task, 'action', node) do |action_node|
    action_values = action_node.arguments.first

    if action_values.sym_type? # there's only a single action given
      check_action(action_values)
    else # it was an array of actions
      action_values.node_parts.each { |action| check_action(action) }
    end
  end
end