Class: RuboCop::Cop::Chef::Ruby::GemspecRequireRubygems

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

Overview

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object


34
35
36
37
38
39
40
41
# 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