Class: RuboCop::Cop::Chef::ChefModernize::ZipfileResource

Inherits:
RuboCop::Cop
  • Object
show all
Includes:
RuboCop::Chef::CookbookHelpers
Defined in:
lib/rubocop/cop/chef/modernize/zipfile_resource.rb

Overview

Use the archive_file resource built into Chef Infra Client 15+ instead of the zipfile resource from the zipfile cookbook.

Examples:


# bad
zipfile "C:\file.zip" do
  path 'C:\expand_here'
end

Constant Summary collapse

MSG =
'Use the archive_file resource built into Chef Infra Client 15+ instead of the zipfile resource from the zipfile cookbook.'.freeze

Instance Method Summary collapse

Methods included from RuboCop::Chef::CookbookHelpers

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

Instance Method Details

#on_block(node) ⇒ Object



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

def on_block(node)
  match_resource_type?(:zipfile, node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end
end

#on_send(node) ⇒ Object



40
41
42
43
44
# File 'lib/rubocop/cop/chef/modernize/zipfile_resource.rb', line 40

def on_send(node)
  depends_zipfile?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end
end