From b820af7b6b5882f1d6fa055419b38690117dc41c Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Thu, 19 Sep 2024 14:24:28 +0200 Subject: [PATCH] Prefer `require_relative` for internal requires `require_relative` is preferred over `require` for files within the same project because it uses paths relative to the current file, making code more portable and less dependent on the load path. This change updates internal requires to use `require_relative` for consistency, performance, and improved portability. Refs: - rubocop/rubocop#8748 --- lib/route_translator.rb | 8 ++++---- lib/route_translator/extensions.rb | 6 +++--- lib/route_translator/translator.rb | 6 +++--- lib/route_translator/translator/path.rb | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/route_translator.rb b/lib/route_translator.rb index d2c68de8..8fd97189 100644 --- a/lib/route_translator.rb +++ b/lib/route_translator.rb @@ -2,10 +2,10 @@ require 'active_support' -require 'route_translator/extensions' -require 'route_translator/translator' -require 'route_translator/host' -require 'route_translator/version' +require_relative 'route_translator/extensions' +require_relative 'route_translator/translator' +require_relative 'route_translator/host' +require_relative 'route_translator/version' module RouteTranslator extend RouteTranslator::Host diff --git a/lib/route_translator/extensions.rb b/lib/route_translator/extensions.rb index e3b3302e..e1f1bffc 100644 --- a/lib/route_translator/extensions.rb +++ b/lib/route_translator/extensions.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'route_translator/extensions/mapper' -require 'route_translator/extensions/route_set' -require 'route_translator/extensions/action_controller' +require_relative 'extensions/mapper' +require_relative 'extensions/route_set' +require_relative 'extensions/action_controller' diff --git a/lib/route_translator/translator.rb b/lib/route_translator/translator.rb index fa6cb916..753f051a 100644 --- a/lib/route_translator/translator.rb +++ b/lib/route_translator/translator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'route_translator/translator/route_helpers' -require 'route_translator/translator/path' -require 'route_translator/route' +require_relative 'translator/route_helpers' +require_relative 'translator/path' +require_relative 'route' module RouteTranslator module Translator diff --git a/lib/route_translator/translator/path.rb b/lib/route_translator/translator/path.rb index 7c3778d6..e7082082 100644 --- a/lib/route_translator/translator/path.rb +++ b/lib/route_translator/translator/path.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'route_translator/translator/path/segment' +require_relative 'path/segment' module RouteTranslator module Translator