Class: RuboCop::Cop::Chef::Modernize::ZipfileResource

Inherits:
Base
  • Object
show all
Extended by:
TargetChefVersion
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

# good
archive_file 'expand file.zip' do
  path 'C:\file.zip'
  destination '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.'
RESTRICT_ON_SEND =
[:depends].freeze

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods included from RuboCop::Chef::CookbookHelpers

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

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_block(node) ⇒ Object



56
57
58
59
60
# File 'lib/rubocop/cop/chef/modernize/zipfile_resource.rb', line 56

def on_block(node)
  match_resource_type?(:zipfile, node) do
    add_offense(node, severity: :refactor)
  end
end

#on_send(node) ⇒ Object



50
51
52
53
54
# File 'lib/rubocop/cop/chef/modernize/zipfile_resource.rb', line 50

def on_send(node)
  depends_zipfile?(node) do
    add_offense(node, severity: :refactor)
  end
end