Class: RuboCop::Cop::Chef::Deprecations::MacosUserdefaultsGlobalProperty

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Includes:
RangeHelp, RuboCop::Chef::CookbookHelpers
Defined in:
lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb

Overview

The ‘global` property in the macos_userdefaults resource was deprecated in Chef Infra Client 16.3. This property was never properly implemented and caused failures under many conditions. Omitting the `domain` property will now set global defaults.

Examples:


### incorrect
macos_userdefaults 'set a value' do
  global true
  key 'key'
  value 'value'
end

### correct
macos_userdefaults 'set a value' do
  key 'key'
  value 'value'
end

Constant Summary collapse

MSG =
'The `global` property in the macos_userdefaults resource was deprecated in Chef Infra Client 16.3. Omitting the `domain` property will now set global defaults.'

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

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
54
55
# File 'lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb', line 49

def on_block(node)
  match_property_in_resource?(:macos_userdefaults, 'global', node) do |global|
    add_offense(global.loc.expression, severity: :warning) do |corrector|
      corrector.remove(range_with_surrounding_space(range: global.loc.expression, side: :left))
    end
  end
end