lib/rubocop/cop/chef/modernize/macos_user_defaults.rb in cookstyle-6.15.9 vs lib/rubocop/cop/chef/modernize/macos_user_defaults.rb in cookstyle-6.16.4

- old
+ new

@@ -34,22 +34,20 @@ # domain 'AppleKeyboardUIMode' # global true # value '2' # end # - class MacOsXUserdefaults < Cop + class MacOsXUserdefaults < Base extend TargetChefVersion + extend AutoCorrector minimum_target_chef_version '14.0' MSG = 'The mac_os_x_userdefaults resource was renamed to macos_userdefaults when it was added to Chef Infra Client 14.0. The new resource name should be used.' def on_send(node) - add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :mac_os_x_userdefaults - end - - def autocorrect(node) - lambda do |corrector| + return unless node.method_name == :mac_os_x_userdefaults + add_offense(node, message: MSG, severity: :refactor) do |corrector| corrector.replace(node.loc.expression, node.source.gsub(/^mac_os_x_userdefaults/, 'macos_userdefaults')) end end end end