Class: RuboCop::Cop::Chef::Modernize::DependsOnOpensslCookbook

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

Overview

Don't depend on the openssl cookbook which was made obsolete by Chef Infra Client 14.4. All openssl_* resources are now included directly in Chef Infra Client.

Examples:


# bad
depends 'openssl'

# good
# the openssl_* resources ship in Chef Infra Client 14.4+, so use them without a depends
openssl_x509_certificate '/etc/httpd/ssl/mycert.pem' do
  common_name 'www.example.com'
  org 'Example Inc'
  org_unit 'IT'
  country 'US'
end

Constant Summary collapse

MSG =
"Don't depend on the `openssl` cookbook which was made obsolete by Chef Infra Client 14.4. All `openssl_*` resources are now included directly in Chef Infra Client."
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



52
53
54
55
56
57
58
# File 'lib/rubocop/cop/chef/modernize/depends_openssl_cookbook.rb', line 52

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