class RuboCop::Cop::Bundler::InsecureProtocolSource

The symbol argument `:gemcutter`, `:rubygems`, and `:rubyforge` are deprecated. So please change your source to URL string that 'rubygems.org' if possible, or 'rubygems.org' if not.

This autocorrect will replace these symbols with 'rubygems.org'. Because it is secure, HTTPS request is strongly recommended. And in most use cases HTTPS will be fine.

However, it don't replace all `sources` of `http://` with `https://`. For example, when specifying an internal gem server using HTTP on the intranet, a use case where HTTPS can not be specified was considered. Consider using HTTP only if you can not use HTTPS.

@example

# bad
source :gemcutter
source :rubygems
source :rubyforge

# good
source 'https://rubygems.org' # strongly recommended
source 'http://rubygems.org'

Constants

MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/bundler/insecure_protocol_source.rb, line 53
def autocorrect(node)
  lambda do |corrector|
    corrector.replace(
      node.first_argument.loc.expression, "'https://rubygems.org'"
    )
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/bundler/insecure_protocol_source.rb, line 41
def on_send(node)
  insecure_protocol_source?(node) do |source|
    message = format(MSG, source: source)

    add_offense(
      node,
      location: range(node.first_argument.loc.expression),
      message: message
    )
  end
end

Private Instance Methods

range(node) click to toggle source
# File lib/rubocop/cop/bundler/insecure_protocol_source.rb, line 63
def range(node)
  range_between(node.begin_pos, node.end_pos)
end