lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb in cookstyle-6.15.9 vs lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb in cookstyle-6.16.4
- old
+ new
@@ -26,27 +26,24 @@
#
# # bad
# include_recipe 'chef_handler'
# include_recipe 'chef_handler::default'
#
- class ChefHandlerRecipe < Cop
+ class ChefHandlerRecipe < Base
include RangeHelp
+ extend AutoCorrector
MSG = 'There is no need to include the empty and deprecated chef_handler::default recipe in order to use the chef_handler resource'
def_node_matcher :chef_handler_recipe?, <<-PATTERN
(send nil? :include_recipe (str {"chef_handler" "chef_handler::default"}))
PATTERN
def on_send(node)
chef_handler_recipe?(node) do
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
- end
- end
-
- def autocorrect(node)
- lambda do |corrector|
- corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
+ add_offense(node, message: MSG, severity: :refactor) do |corrector|
+ corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
+ end
end
end
end
end
end