class RuboCop::Cop::Chef::Deprecations::ChefDKGenerators

Chef Workstation 0.8 and later renamed the ‘ChefDK` module used when writing custom cookbook generators from `ChefDK` to `ChefCLI`. For compatibility with the latest Chef Workstation releases you’ll need to reference the new class names.

@example

#### incorrect
ChefDK::CLI
ChefDK::Generator::TemplateHelper
module ChefDK
  # some additional code
end

#### correct
ChefCLI::CLI
ChefCLI::Generator::TemplateHelper
module ChefCLI
  # some additional code
end

Constants

MSG

Public Instance Methods

on_const(node) click to toggle source
# File lib/rubocop/cop/chef/deprecation/chefdk_generators.rb, line 44
def on_const(node)
  # We want to catch calls like ChefCLI::CLI.whatever or places where classes are defined in the ChefDK module
  return unless node.const_name == 'ChefDK' && (node.parent&.module_type? || node.parent&.const_type?)

  add_offense(node, severity: :warning) do |corrector|
    corrector.replace(node, node.source.gsub('ChefDK', 'ChefCLI'))
  end
end