class RuboCop::Cop::Chef::Ruby::GemspecRequireRubygems

Rubygems does not need to be required in a Gemspec. It's already loaded out of the box in Ruby now.

Constants

MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/ruby/gemspec_require_rubygems.rb, line 34
def on_send(node)
  require_rubygems?(node) do |r|
    node = node.parent if node.parent && node.parent.conditional? # make sure we identify conditionals on the require
    add_offense(node.loc.expression, message: MSG, severity: :refactor) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end