class RuboCop::Cop::Chef::Modernize::PowershellInstallWindowsFeature

Use the windows_feature resource built into Chef Infra Client 14+ instead of the powershell_script resource to run Install-WindowsFeature or Add-WindowsFeature

@example

 #### incorrect
 powershell_script 'Install Feature' do
   code 'Install-WindowsFeature -Name "Net-framework-Core"'
 end

#### correct
windows_feature 'Net-framework-Core' do
  action :install
  install_method :windows_feature_powershell
end

Constants

MSG

Public Instance Methods

on_block(node) click to toggle source
# File lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb, line 45
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?(/^(install|add)-windowsfeature\s/i)
    add_offense(node, severity: :refactor)
  end
end