-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix circular require warning in belongs_to.rb
#8599
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
Conversation
When running specs with `RUBYOPTS='-w'`, numerous warnings are generated due to a circular require between: - `lib/active_admin/resource/belongs_to.rb` - `lib/active_admin/resource.rb` The warning message is: ``` lib/active_admin/resource/belongs_to.rb:2: warning: lib/active_admin/resource/belongs_to.rb:2: warning: loading in progress, circular require considered harmful - lib/active_admin/resource.rb ``` Based on the code history, there is no specific reason for the inverse require from `belongs_to` to `resource`. This change removes the unnecessary require to eliminate the warnings. Closes #8598
cd78b79
to
c3fd02c
Compare
resource/belongs_to
belongs_to.rb
@@ -1,5 +1,4 @@ | |||
# frozen_string_literal: true | |||
require_relative "../resource" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible that this is a breaking change? Like some use cases where resource/belongs_to
is required individually without other resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. If the warning appears in normal usage of ActiveAdmin v4 and v3 (meaning a real app, not the test/dev app we generate for the project), we should address it in both versions. If we can see it stable in a real app on v3 then I think it's safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit 79c1a98 is where the circular require is introduced but doesn't seem to have any need for it so this removal should be safe. We can backport it as well.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8599 +/- ##
==========================================
- Coverage 99.11% 99.11% -0.01%
==========================================
Files 141 141
Lines 4074 4073 -1
==========================================
- Hits 4038 4037 -1
Misses 36 36 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
When running specs with
RUBYOPTS='-w'
, numerous warnings are generateddue to a circular require between:
lib/active_admin/resource/belongs_to.rb
lib/active_admin/resource.rb
The warning message is:
Based on the code history, there is no specific reason for the inverse
require from
belongs_to
toresource
.This change removes the unnecessary require to eliminate the warnings.
Closes #8598