class RuboCop::Cop::Chef::Deprecations::WindowsPackageInstallerTypeString

In Chef Infra Client 13 and later the ‘windows_package` resource’s ‘installer_type` property must be a symbol.

@example

#### incorrect
windows_package 'AppveyorDeploymentAgent' do
  source 'https://www.example.com/appveyor.msi'
  installer_type 'msi'
  options "/quiet /qn /norestart /log install.log"
end

#### correct
windows_package 'AppveyorDeploymentAgent' do
  source 'https://www.example.com/appveyor.msi'
  installer_type :msi
  options "/quiet /qn /norestart /log install.log"
end

Constants

MSG

Public Instance Methods

on_block(node) click to toggle source
# File lib/rubocop/cop/chef/deprecation/windows_package_installer_type_string.rb, line 46
def on_block(node)
  match_property_in_resource?(:windows_package, 'installer_type', node) do |offense|
    return unless offense.arguments.count == 1 # we can only analyze simple string args
    return unless offense.arguments.first.str_type? # anything else is fine

    add_offense(offense, severity: :warning) do |corrector|
      corrector.replace(offense.arguments.first.source_range, ":#{offense.arguments.first.value}")
    end
  end
end