Class: RuboCop::Cop::Chef::Modernize::UseBuildEssentialResource

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
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:


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

### correct
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+'
RESTRICT_ON_SEND =
[:include_recipe].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/modernize/build_essential.rb', line 44

def on_send(node)
  build_essential_recipe_usage?(node) do
    add_offense(node, severity: :refactor) do |corrector|
      corrector.replace(node, "build_essential 'install compilation tools'")
    end
  end
end