Class: RuboCop::Cop::Chef::Deprecations::ChefDKGenerators
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/deprecation/chefdk_generators.rb
Overview
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.
Constant Summary collapse
- MSG =
'When writing cookbook generators use the ChefCLI module instead of the ChefDK module which was removed in Chef Workstation 0.8 and later.'
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_const(node) ⇒ Object
44 45 46 47 48 49 50 51 |
# 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 |