class RuboCop::Cop::Chef::Deprecations::ChefHandlerUsesSupports

Use the type `property` instead of the deprecated `supports` property in the `chef_handler` resource. The `supports` property was removed in `chef_handler` cookbook version 3.0 (June 2017) and Chef Infra Client 14.0.

@example

#### incorrect
chef_handler 'whatever' do
  supports start: true, report: true, exception: true
end0

#### correct
chef_handler 'whatever' do
  type start: true, report: true, exception: true
end

Constants

MSG

Public Instance Methods

on_block(node) click to toggle source
# File lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb, line 42
def on_block(node)
  match_property_in_resource?(:chef_handler, 'supports', node) do |prop_node|
    add_offense(prop_node, message: MSG, severity: :warning) do |corrector|
      # make sure to delete leading and trailing {}s that would create invalid ruby syntax
      extracted_val = prop_node.arguments.first.source.gsub(/{|}/, '')
      corrector.replace(prop_node, "type #{extracted_val}")
    end
  end
end