Class: RuboCop::Cop::Chef::ChefModernize::PowershellInstallWindowsFeature
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefModernize::PowershellInstallWindowsFeature
- Includes:
- RuboCop::Chef::CookbookHelpers
- Defined in:
- lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb
Overview
Use the windows_feature resource built into Chef Infra Client 15+ instead of the powershell_script resource to run Install-WindowsFeature or Add-WindowsFeature
# good
windows_feature 'Net-framework-Core' do
action :install
install_method :windows_feature_powershell
end
Constant Summary collapse
- MSG =
'Use the windows_feature resource built into Chef Infra Client 13+ instead of using Install-WindowsFeature or Add-WindowsFeature in a powershell_script resource'.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
42 43 44 45 46 47 48 49 |
# File 'lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb', line 42 def on_block(node) match_property_in_resource?(:powershell_script, 'code', node) do |code_property| property_data = method_arg_ast_to_string(code_property) if property_data && property_data.match?(/^(install|add)-windowsfeature\s/i) add_offense(node, location: :expression, message: MSG, severity: :refactor) end end end |