Skip to content

Prefer require_relative for internal requires #8482

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

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

tagliala
Copy link
Contributor

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.

Ref:

@tagliala tagliala force-pushed the chore/prefer-require-relative branch from 89c031e to 142812c Compare September 19, 2024 20:43
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.11%. Comparing base (50489c2) to head (a213979).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8482   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         141      141           
  Lines        4069     4069           
=======================================
  Hits         4033     4033           
  Misses         36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tagliala tagliala marked this pull request as ready for review September 19, 2024 21:01
@tagliala
Copy link
Contributor Author

@javierjulio do you want to take a look too?

`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.

Ref:
- activeadmin/arbre#622
- activeadmin/inherited_resources#939
@tagliala tagliala force-pushed the chore/prefer-require-relative branch from 142812c to a213979 Compare September 20, 2024 21:14
@tagliala
Copy link
Contributor Author

tagliala commented Sep 23, 2024

@deivid-rodriguez apparently this can be considered a breaking change (which is fine in a beta version) because of this side effect: varvet/pundit#831 (comment)

I'm a little bit concerned about arbre and inherithed_resources, I was assuming that this was fine in a patch release

Any thoughts?

I'm incline to make this change anyway and release in a patch, but at this point I would add a changelog entry

@deivid-rodriguez
Copy link
Member

I think as long as our release policy permits small enhancements like this in a patch release, then it's fine. I mean, it could make achieving certain things in development a bit harder, but should not be breaking any expected production usage of the gems, so seems fine to me.

@tagliala tagliala merged commit e6ecf5b into activeadmin:master Sep 23, 2024
24 checks passed
@tagliala tagliala deleted the chore/prefer-require-relative branch September 23, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants