class RuboCop::Cop::Packaging::RelativeRequireToLib


require_relative ‘foo/bar’
require_relative ‘spec_helper’
# good
require ‘foo/bar’
# good
require ‘foo.rb’
# good
require_relative ‘../../lib/foo/bar’
# bad
require_relative ‘lib/foo.rb’
# bad
@example
instead.
mapping to the “lib” directory and suggests to use ‘require`
This cop is used to identify the `require_relative` calls,
:nodoc:
:nodoc:
:nodoc:

def on_new_investigation

Processing of the AST happens here.

https://github.com/rubocop-hq/rubocop/blob/343f62e4555be0470326f47af219689e21c61a37/lib/rubocop/cop/base.rb
More about the `#on_new_investigation` method can be found here:
Extended from the Base class.
def on_new_investigation
  @file_path = processed_source.file_path
  @file_directory = File.dirname(@file_path)
end

def on_send(node)

https://github.com/rubocop-hq/rubocop-ast/blob/08d0f49a47af1e9a30a6d8f67533ba793c843d67/lib/rubocop/ast/traversal.rb#L112
More about the `#on_send` method can be found here:
Extended from AST::Traversal.
def on_send(node)
  return unless require_relative(node)
  add_offense(node)
end

def target_falls_in_lib?(str)

It is used to find paths which starts with "lib".
This method is called from inside `#def_node_matcher`.
def target_falls_in_lib?(str)
  root_dir = RuboCop::ConfigLoader.project_root
  File.expand_path(str, @file_directory).start_with?(root_dir + '/lib')
end