class RuboCop::Cop::Style::RedundantFileExtensionInRequire


require_relative ‘../foo.so’
require_relative ‘../foo’
require ‘foo.so’
require ‘foo’
# good
require_relative ‘../foo.rb’
require ‘foo.rb’
# bad
@example
but that seems harmless.
if ‘foo.so` file exists when `require ’foo.rb’‘ will be changed to `require ’foo’‘,
There is an edge case where `foo.so` file is loaded instead of a `LoadError`
a `LoadError` will be raised.
and so on to the name until found. If the file named cannot be found,
Note: If the extension is omitted, Ruby tries adding ’.rb’, ‘.so’,
the filename provided to ‘require` and `require_relative`.
This cop checks for the presence of superfluous `.rb` extension in

def on_send(node)

def on_send(node)
  require_call?(node) do |name_node|
    return unless name_node.value.end_with?('.rb')
    add_offense(name_node) do |corrector|
      correction = name_node.value.sub(/\.rb\z/, '')
      corrector.replace(name_node, "'#{correction}'")
    end
  end
end