Class: RuboCop::Cop::Chef::ChefDeprecations::ResourceInheritsFromCompatResource
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefDeprecations::ResourceInheritsFromCompatResource
- Defined in:
- lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb
Overview
Resources written in the class based HWRP style should inherit from the ‘Chef::Resource’ class and not the ‘ChefCompat::Resource’ class from the deprecated compat_resource cookbook.
Constant Summary collapse
- MSG =
"HWRP style resource should inherit from the 'Chef::Resource' class and not the 'ChefCompat::Resource' class from the deprecated compat_resource cookbook.".freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
52 53 54 55 56 |
# File 'lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb', line 52 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.expression, node.loc.expression.source.gsub('ChefCompat', 'Chef')) end end |
#on_class(node) ⇒ Object
46 47 48 49 50 |
# File 'lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb', line 46 def on_class(node) inherits_from_compat_resource?(node) do add_offense(node, location: :expression, message: MSG, severity: :refactor) end end |