class RuboCop::Cop::Chef::Correctness::NotifiesActionNotSymbol
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.
@example
### incorrect execute 'some command' do notifies 'restart', 'service[httpd]', 'delayed' end execute 'some command' do subscribes 'restart', 'service[httpd]', 'delayed' end ### correct execute 'some command' do notifies :restart, 'service[httpd]', 'delayed' end execute 'some command' do subscribes :restart, 'service[httpd]', 'delayed' end
Constants
- MSG
Public Instance Methods
Source
# 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