Class: RuboCop::Cop::Chef::Modernize::UnnecessaryDependsChef15

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetChefVersion
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/modernize/chef_15_resources.rb

Overview

Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.

Examples:


# bad
depends 'libarchive'
depends 'windows_dns'
depends 'windows_uac'
depends 'windows_dfs'

# good
# the resources ship in Chef Infra Client 15+, so use them without a depends
archive_file 'expand website' do
  path '/tmp/site.zip'
  destination '/var/www/html'
end

windows_uac 'set uac' do
  enable_uac true
end

Constant Summary collapse

MSG =
"Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself."
RESTRICT_ON_SEND =
[:depends].freeze

Instance Method Summary collapse

Methods included from TargetChefVersion

minimum_target_chef_version, required_minimum_chef_version, support_target_chef_version?

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/rubocop/cop/chef/modernize/chef_15_resources.rb', line 57

def on_send(node)
  legacy_depends?(node) do
    add_offense(node, severity: :refactor) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end