Skip to content

Commit

Permalink
Prefer require_relative for internal requires
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
tagliala committed Sep 19, 2024
1 parent 8dfd313 commit b820af7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/route_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/route_translator/extensions.rb
Original file line number Diff line number Diff line change
@@ -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'
6 changes: 3 additions & 3 deletions lib/route_translator/translator.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/route_translator/translator/path.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'route_translator/translator/path/segment'
require_relative 'path/segment'

module RouteTranslator
module Translator
Expand Down

0 comments on commit b820af7

Please sign in to comment.