Class: RuboCop::Cop::Chef::Deprecations::LegacyNotifySyntax
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb
Overview
Use the new-style notification syntax which allows you to notify resources defined later in a recipe or resource.
Constant Summary collapse
- MSG =
'Use the new-style notification syntax which allows you to notify resources defined later in a recipe or resource.'
- RESTRICT_ON_SEND =
[:notifies, :subscribes].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb', line 70 def on_send(node) legacy_notify?(node) do |notify_type, action, type, name, timing| add_offense(node, severity: :warning) do |corrector| service_value = case name.type when :str "'#{type.source}[#{name.value}]'" when :dstr "\"#{type.source}[#{name.value}]\"" else "\"#{type.source}[\#{#{name.source}}]\"" end new_val = +"#{notify_type} #{action.source}, #{service_value}" new_val << ", #{timing.first.source}" unless timing.empty? corrector.replace(node, new_val) end end end |