class RuboCop::Cop::Chef::Modernize::CustomResourceWithAttributes

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.

@example

#### incorrect
attribute :something, String

action :create do
  # some action code because we're in a custom resource
end

#### correct
property :something, String

action :create do
  # some action code because we're in a custom resource
end

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/modernize/resource_with_attributes.rb, line 54
def on_send(node)
  return unless resource_actions?(processed_source.ast)
  attribute?(node) do
    add_offense(node.loc.selector, severity: :refactor) do |corrector|
      corrector.replace(node.loc.selector, 'property')
    end
  end
end