Class: RuboCop::Cop::Chef::Modernize::DeclareActionClass

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Defined in:
lib/rubocop/cop/chef/modernize/declare_action_class.rb

Overview

In Chef Infra Client 12.9 and later ‘action_class` can be used instead of `declare_action_class`.

Examples:


### incorrect
declare_action_class do
  foo
end

### correct
action_class do
  foo
end

Constant Summary collapse

MSG =
'In Chef Infra Client 12.9 and later `action_class` can be used instead of `declare_action_class`.'
RESTRICT_ON_SEND =
[:declare_action_class].freeze

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



45
46
47
48
49
# File 'lib/rubocop/cop/chef/modernize/declare_action_class.rb', line 45

def on_send(node)
  add_offense(node, severity: :refactor) do |corrector|
    corrector.replace(node, node.source.gsub('declare_action_class', 'action_class'))
  end
end