Class: RuboCop::Cop::Chef::Correctness::InvalidNotificationResource

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/chef/correctness/invalid_notification_resource.rb

Overview

The resource to notify when calling ‘notifies` or `subscribes` must be a string.

Examples:


### incorrect

template '/etc/www/configures-apache.conf' do
  notifies :restart, service['apache'], :immediately
end

template '/etc/www/configures-apache.conf' do
  notifies :restart, service[apache], :immediately
end

### correct

template '/etc/www/configures-apache.conf' do
  notifies :restart, 'service[apache]', :immediately
end

Constant Summary collapse

MSG =
'The resource to notify when calling `notifies` or `subscribes` must be a string.'
RESTRICT_ON_SEND =
[:notifies, :subscribes].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



50
51
52
53
54
# File 'lib/rubocop/cop/chef/correctness/invalid_notification_resource.rb', line 50

def on_send(node)
  invalid_notification?(node) do |resource|
    add_offense(resource, severity: :refactor)
  end
end