Class: RuboCop::Cop::Chef::Correctness::NotifiesActionNotSymbol
- Extended by:
- AutoCorrector
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb
Overview
When notifying or subscribing actions within a resource the action should always be a symbol. In Chef Infra Client releases before 14.0, this may result in double notification.
Constant Summary collapse
- MSG =
'Resource notification and subscription actions should be symbols not strings.'
Instance Method Summary collapse
Methods included from RuboCop::Chef::CookbookHelpers
#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
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb', line 50 def on_block(node) match_property_in_resource?(nil, %w(notifies subscribes), node) do |notifies_property| return unless notifies_property.node_parts[2].str_type? add_offense(notifies_property, severity: :refactor) do |corrector| corrector.replace(notifies_property.first_argument, ":#{notifies_property.node_parts[2].value}") end end end |