Patch #38093

Use require_relative instead of generating the full path for a file

Added by Go MAEDA about 1 month ago. Updated 16 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Code cleanup/refactoring
Target version:5.1.0

Description

In the code of Redmine, you can find many require methods that builds the absolute path of a file using File.expand_path and __FILE__:

require File.expand_path('../../test_helper', __FILE__)

I think using `require_relative` can make those simpler and more readable, as shown below.

require_relative '../test_helper'

require_relative.patch Magnifier (201 KB) Go MAEDA, 2022-12-23 06:53

Associated revisions

Revision 22016
Added by Go MAEDA about 1 month ago

Use `require_relative` instead of `require File.expand_path(..., FILE)` (#38093).

Patch by Go MAEDA.

Revision 22052
Added by Go MAEDA 16 days ago

Use `require_relative` instead of `File.dirname(FILE) + ...` (#38093).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA about 1 month ago

  • Target version set to 5.1.0

Setting the target version to 5.1.0.

#2 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch.

#3 Updated by Go MAEDA 16 days ago

  • Subject changed from Use `require_relative` instead of `require File.expand_path(..., __FILE__)` to Use require_relative instead of generating the full path for a file

Also available in: Atom PDF