Class: RuboCop::Cop::Chef::Deprecations::WindowsFeatureServermanagercmd

Inherits:
Base
  • Object
show all
Includes:
RuboCop::Chef::CookbookHelpers
Defined in:
lib/rubocop/cop/chef/deprecation/windows_feature_servermanagercmd.rb

Overview

The ‘windows_feature` resource no longer supports setting the `install_method` to `:servermanagercmd`. `:windows_feature_dism` or `:windows_feature_powershell` should be used instead.

Examples:


### incorrect
windows_feature 'DHCP' do
  install_method :servermanagercmd
end

### correct
windows_feature 'DHCP' do
  install_method :windows_feature_dism
end

windows_feature 'DHCP' do
  install_method :windows_feature_powershell
end

windows_feature_dism 'DHCP'

windows_feature_powershell 'DHCP'

Constant Summary collapse

MSG =
'The `windows_feature` resource no longer supports setting the `install_method` to `:servermanagercmd`. `:windows_feature_dism` or `:windows_feature_powershell` should be used instead.'

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

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_block(node) ⇒ Object



49
50
51
52
53
# File 'lib/rubocop/cop/chef/deprecation/windows_feature_servermanagercmd.rb', line 49

def on_block(node)
  match_property_in_resource?(:windows_feature, :install_method, node) do |prop_node|
    add_offense(prop_node, severity: :warning) if prop_node.source.include?(':servermanagercmd')
  end
end