Class: RuboCop::Cop::Chef::ChefModernize::CustomResourceWithAttributes
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefModernize::CustomResourceWithAttributes
- Defined in:
- lib/rubocop/cop/chef/modernize/resource_with_attributes.rb
Overview
In HWRPs and LWRPs you defined attributes, but custom resources changed the name to be properties to avoid confusion with chef recipe attributes. When writing a custom resource they should be called properties even though the two are aliased.
Constant Summary collapse
- MSG =
'Custom Resources should contain properties not attributes'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
59 60 61 62 63 |
# File 'lib/rubocop/cop/chef/modernize/resource_with_attributes.rb', line 59 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.selector, 'property') end end |
#on_send(node) ⇒ Object
53 54 55 56 57 |
# File 'lib/rubocop/cop/chef/modernize/resource_with_attributes.rb', line 53 def on_send(node) attribute?(node) do add_offense(node, location: :selector, message: MSG, severity: :refactor) if resource_actions?(processed_source.ast) end end |