Class: RuboCop::Cop::Chef::Correctness::InvalidNotificationTiming

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

Overview

Valid notification timings are ‘:immediately`, `:immediate` (alias for :immediately), `:delayed`, and `:before`.

Examples:


### incorrect

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

### correct

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

Constant Summary collapse

MSG =
'Valid notification timings are :immediately, :immediate (alias for :immediately), :delayed, and :before.'
RESTRICT_ON_SEND =
[:notifies, :subscribes].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



46
47
48
49
50
# File 'lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb', line 46

def on_send(node)
  notification_with_timing?(node) do |timing|
    add_offense(timing, severity: :refactor) unless %i(immediate immediately delayed before).include?(timing.value)
  end
end