Class: RuboCop::Cop::Chef::Deprecations::ChefWindowsPlatformHelper

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/deprecation/chef_windows_platform_helper.rb

Overview

Use ‘platform?(’windows’)‘ instead of the legacy `Chef::Platform.windows?` helper

Examples:


### incorrect
Chef::Platform.windows?

### correct
platform?('windows')
platform_family?('windows')

Constant Summary collapse

MSG =
"Use `platform?('windows')` instead of the legacy `Chef::Platform.windows?` helper."
RESTRICT_ON_SEND =
[:windows?].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/rubocop/cop/chef/deprecation/chef_windows_platform_helper.rb', line 44

def on_send(node)
  chef_platform_windows?(node) do
    add_offense(node, severity: :warning) do |corrector|
      corrector.replace(node, "platform?('windows')")
    end
  end
end