lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb in cookstyle-6.15.9 vs lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb in cookstyle-6.16.4

- old
+ new

@@ -28,27 +28,24 @@ # def create_yum_repository(resource_name) # ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name) # end # end # - class DefinesChefSpecMatchers < Cop + class DefinesChefSpecMatchers < Base + extend AutoCorrector include RangeHelp MSG = 'ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook' def_node_matcher :chefspec_matcher?, <<-PATTERN (if ( :defined? (const nil? :ChefSpec)) ... ) PATTERN def on_if(node) chefspec_matcher?(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