lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb in cookstyle-5.18.4 vs lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb in cookstyle-5.19.9
- old
+ new
@@ -25,10 +25,11 @@
#
# # bad
# chef_gem 'nokogiri'
#
class ChefGemNokogiri < Cop
+ include RangeHelp
include RuboCop::Chef::CookbookHelpers
MSG = 'The nokogiri gem ships in Chef Infra Client 12+ and does not need to be installed before being used.'.freeze
def_node_matcher :nokogiri_install?, <<-PATTERN
@@ -48,10 +49,10 @@
end
def autocorrect(node)
lambda do |corrector|
node = node.parent if node.parent&.block_type? # make sure we get the whole block not just the method in the block
- corrector.remove(node.loc.expression)
+ corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
end
end
end
end
end