Class: RuboCop::Cop::Chef::ChefModernize::ChefGemNokogiri
Overview
The nokogiri gem ships in Chef Infra Client 12+ and does not need to be installed before being used
Constant Summary
collapse
- MSG =
'The nokogiri gem ships in Chef Infra Client 12+ and does not need to be installed before being used.'.freeze
Instance Method Summary
collapse
#match_property_in_resource?, #match_resource_type?, #method_arg_ast_to_string, #resource_block_name_if_string
Instance Method Details
#autocorrect(node) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb', line 50
def autocorrect(node)
lambda do |corrector|
node = node.parent if node.parent&.block_type? corrector.remove(node.loc.expression)
end
end
|
#on_block(node) ⇒ Object
38
39
40
41
42
|
# File 'lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb', line 38
def on_block(node)
match_property_in_resource?(:chef_gem, 'package_name', node) do |pkg_name|
add_offense(node, location: :expression, message: MSG, severity: :refactor) if pkg_name.arguments&.first&.str_content == 'nokogiri'
end
end
|
#on_send(node) ⇒ Object
44
45
46
47
48
|
# File 'lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb', line 44
def on_send(node)
nokogiri_install?(node) do
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end
|