Class: RuboCop::Cop::Chef::Modernize::SysctlParamResource

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Includes:
RuboCop::Chef::CookbookHelpers
Defined in:
lib/rubocop/cop/chef/modernize/sysctl_param_resource.rb

Overview

The sysctl_param resource was renamed to sysctl when it was added to Chef Infra Client 14.0. The new resource name should be used.

Examples:


### incorrect
sysctl_param 'fs.aio-max-nr' do
  value '1048576'
end

### correct
sysctl 'fs.aio-max-nr' do
  value '1048576'
end

Constant Summary collapse

MSG =
'The sysctl_param resource was renamed to sysctl when it was added to Chef Infra Client 14.0. The new resource name should be used.'
RESTRICT_ON_SEND =
[:sysctl_param].freeze

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods included from RuboCop::Chef::CookbookHelpers

#match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



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

def on_send(node)
  add_offense(node, severity: :refactor) do |corrector|
    corrector.replace(node, node.source.gsub(/^sysctl_param/, 'sysctl'))
  end
end