Class: RuboCop::Cop::Chef::Deprecations::UseAutomaticResourceName

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/deprecation/use_automatic_resource_name.rb

Overview

The use_automatic_resource_name method was removed in Chef Infra Client 16. The resource name/provides should be set explicitly instead.

Examples:


### incorrect
module MyCookbook
  class MyCookbookService < Chef::Resource
    use_automatic_resource_name
    provides :mycookbook_service

    # some additional code
  end
end

Constant Summary collapse

MSG =
'The use_automatic_resource_name method was removed in Chef Infra Client 16. The resource name/provides should be set explicitly instead.'
RESTRICT_ON_SEND =
[:use_automatic_resource_name].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



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

def on_send(node)
  add_offense(node.loc.selector, severity: :warning) do |corrector|
    corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
  end
end