Class: RuboCop::Cop::Chef::Ruby::RequireNetHttps

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/ruby/require_net_https.rb

Overview

net/https is deprecated and just includes net/http and openssl. We should include those directly instead.

Examples:


# bad
require 'net/https'

# good
require 'net/http'
require 'openssl'

Constant Summary collapse

MSG =
"net/https is deprecated and just includes net/http and openssl. We should include those directly instead."

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object


43
44
45
46
47
48
49
# File 'lib/rubocop/cop/chef/ruby/require_net_https.rb', line 43

def on_send(node)
  require_net_https?(node) do
    add_offense(node.loc.expression, message: MSG, severity: :refactor) do |corrector|
      corrector.replace(node, %Q{require "net/http"\nrequire "openssl"})
    end
  end
end