class RuboCop::Cop::Chef::Modernize::PowershellScriptExpandArchive

Use the archive_file resource built into Chef Infra Client 15+ instead of using the powershell_script resource to run Expand-Archive

@example

#### incorrect
powershell_script 'Expand website' do
  code 'Expand-Archive "C:\\file.zip" -DestinationPath "C:\\inetpub\\wwwroot\\" -Force'
end

Constants

MSG

Public Instance Methods

on_block(node) click to toggle source
# File lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb, line 39
def on_block(node)
  match_property_in_resource?(:powershell_script, 'code', node) do |code_property|
    property_data = method_arg_ast_to_string(code_property)
    return unless property_data && property_data.match?(/^expand-archive/i)
    add_offense(node, severity: :refactor)
  end
end