Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NonDeterministicRequireOrder should also apply to require_relative #10614

Closed
gongfarmer opened this issue May 10, 2022 · 0 comments · Fixed by #10615
Closed

NonDeterministicRequireOrder should also apply to require_relative #10614

gongfarmer opened this issue May 10, 2022 · 0 comments · Fixed by #10615
Labels

Comments

@gongfarmer
Copy link

This regards the cop Lint/NonDeterministicRequireOrder

Currently it does not flag code which uses require_relative instead of require, like this:

# require all ruby source files in ./update/
Dir.glob("#{__dir__}/update/*.rb") do |path|
  require_relative path
end

Current result:

$ rubocop lib/gpt/update.rb 
Inspecting 1 file
.

1 file inspected, no offenses detected

Desired result:

$ rubocop lib/gpt/update.rb 
Inspecting 1 file
W

Offenses:

lib/gpt/update.rb:6:1: W: [Correctable] Lint/NonDeterministicRequireOrder: Sort files before requiring them.
Dir.glob("#{__dir__}/update/*.rb") do |path|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable
@koic koic added the bug label May 10, 2022
koic added a commit to koic/rubocop that referenced this issue May 10, 2022
… `require_relative`

Fixes rubocop#10614.

This PR makes `Lint/NonDeterministicRequireOrder` aware of `require_relative`.
koic added a commit that referenced this issue May 10, 2022
…re_order_aware_of_require_relative

[Fix #10614] Make `Lint/NonDeterministicRequireOrder` aware of `require_relative`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants