-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Move Array#to_sentence monkey-patch from ActiveSupport to extend/ #14847
Conversation
Review period will end on 2023-03-02 at 01:42:11 UTC. |
@@ -3,6 +3,7 @@ | |||
|
|||
require "ast_constants" | |||
require "rubocops/extend/formula_cop" | |||
require "utils/array" |
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.
Note I put the util in a separate file, despite being at the top Utils
level, so that this rubocop could import just the method it needs, and not the bulk of the Utils
namespace. As a bonus, rubocop no longer has a direct active_support
require, but still makes use of active_support methods such as present?
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.
@dduugg IMO it's worth either just importing all of Utils
in rubocop
or moving this to another namespace, I think defining modules over multiple files is a confusing behaviour for non-Rubyists (as you don't see the same in most other ecosystems).
@@ -17,7 +17,8 @@ | |||
require "active_support/core_ext/object/try" | |||
require "active_support/core_ext/array/access" | |||
require "active_support/core_ext/string/inflections" | |||
require "active_support/core_ext/array/conversions" | |||
require "active_support/core_ext/kernel/reporting" | |||
require "active_support/core_ext/hash/keys" |
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.
These are transitive requires that we still need, for now.
01b3090
to
ca62249
Compare
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.
Nice work so far!
I reckon we can eventually do similarly for blank?/present?/presence
and they should remain as actual monkey patches rather than new Utils
methods.
I actually have a mild preference about this remaining a monkey patch (outside of ActiveSupport) but I feel much less strongly than for this.
@@ -3,6 +3,7 @@ | |||
|
|||
require "ast_constants" | |||
require "rubocops/extend/formula_cop" | |||
require "utils/array" |
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.
@dduugg IMO it's worth either just importing all of Utils
in rubocop
or moving this to another namespace, I think defining modules over multiple files is a confusing behaviour for non-Rubyists (as you don't see the same in most other ecosystems).
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.
(dupe, sorry)
Review period ended. |
5533188
to
e4e91da
Compare
@MikeMcQuaid PR updated to keep |
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! Good to go once we have the license stuff sorted.
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 again @dduugg!
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?I'm unable to remove the String inflections ActiveSupport dependency after merging #14778 because it's a transitive require of Array conversions. Thus, in this PR, I've introduced a Utils method for the only conversion we appear to use,
to_sentence
.