Class: RuboCop::Cop::Chef::Deprecations::RubyBlockCreateAction
- Extended by:
- AutoCorrector
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb
Overview
Use the :run action in the ruby_block resource instead of the deprecated :create action
Constant Summary collapse
- MSG =
'Use the :run action in the ruby_block resource instead of the deprecated :create action'- RESTRICT_ON_SEND =
[:notifies, :subscribes].freeze
Instance Method Summary collapse
Methods included from RuboCop::Chef::CookbookHelpers
#each_action_symbol, #match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string
Methods inherited from Base
Instance Method Details
#on_block(node) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb', line 63 def on_block(node) match_property_in_resource?(:ruby_block, 'action', node) do |ruby_action| each_action_symbol(ruby_action) do |action, prefix| next unless action.value == :create add_offense(action, severity: :warning) do |corrector| corrector.replace(action, "#{prefix}run") end end end end |
#on_send(node) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb', line 74 def on_send(node) notification?(node) do |action, notified_resource| next unless ruby_block?(notified_resource) add_offense(action, severity: :warning) do |corrector| corrector.replace(action, ':run') end end end |