Class: RuboCop::Cop::Chef::ChefModernize::OpensslX509Resource

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

Overview

The openssl_x509 resource was renamed to openssl_x509_certificate in Chef Infra Client 14.4. The new resource name should be used.

# bad
openssl_x509 '/etc/httpd/ssl/mycert.pem' do
  common_name 'www.f00bar.com'
  org 'Foo Bar'
  org_unit 'Lab'
  country 'US'
end

# good
openssl_x509_certificate '/etc/httpd/ssl/mycert.pem' do
  common_name 'www.f00bar.com'
  org 'Foo Bar'
  org_unit 'Lab'
  country 'US'
end

Constant Summary collapse

MSG =
'The openssl_x509 resource was renamed to openssl_x509_certificate in Chef Infra Client 14.4. The new resource name should be used.'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



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

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.loc.expression, node.source.gsub(/^openssl_x509/, 'openssl_x509_certificate'))
  end
end

#on_send(node) ⇒ Object



43
44
45
# File 'lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb', line 43

def on_send(node)
  add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :openssl_x509
end