Class: RuboCop::Cop::Chef::ChefModernize::CronManageResource

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/chef/modernize/cron_manage_resource.rb

Overview

The cron_manage resource was renamed to cron_access in the 6.1 release of the cron cookbook, and later shipped in Chef Infra Client 14.4. The new resource name should be used.

# bad
cron_manage 'mike'

# good
cron_access 'mike'

Constant Summary collapse

MSG =
'The cron_manage resource was renamed to cron_access in the 6.1 release of the cron cookbook and later shipped in Chef Infra Client 14.4. The new resource name should be used.'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



38
39
40
41
42
# File 'lib/rubocop/cop/chef/modernize/cron_manage_resource.rb', line 38

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.loc.expression, node.source.gsub(/^cron_manage/, 'cron_access'))
  end
end

#on_send(node) ⇒ Object



34
35
36
# File 'lib/rubocop/cop/chef/modernize/cron_manage_resource.rb', line 34

def on_send(node)
  add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :cron_manage
end