Class: RuboCop::Cop::Chef::ChefModernize::UseBuildEssentialResource

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/chef/modernize/build_essential.rb

Overview

Use the build_essential resource from the build-essential cookbook 5.0+ or Chef Infra Client 14+ instead of using the build-essential::default recipe.

Examples:


# bad
depends 'build-essential'
include_recipe 'build-essential::default'
include_recipe 'build-essential'

# good
build_essential 'install compilation tools'

Constant Summary collapse

MSG =
'Use the build_essential resource instead of the legacy build-essential recipe. This resource ships in the build-essential cookbook v5.0+ and is built into Chef Infra Client 14+'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



46
47
48
49
50
# File 'lib/rubocop/cop/chef/modernize/build_essential.rb', line 46

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.loc.expression, "build_essential 'install compilation tools'")
  end
end

#on_send(node) ⇒ Object



40
41
42
43
44
# File 'lib/rubocop/cop/chef/modernize/build_essential.rb', line 40

def on_send(node)
  build_essential_recipe_usage?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end
end