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

Move Array#to_sentence monkey-patch from ActiveSupport to extend/ #14847

Merged
merged 10 commits into from
Mar 6, 2023

Conversation

dduugg
Copy link
Member

@dduugg dduugg commented Mar 1, 2023

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run 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.

@BrewTestBot
Copy link
Member

Review period will end on 2023-03-02 at 01:42:11 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Mar 1, 2023
@@ -3,6 +3,7 @@

require "ast_constants"
require "rubocops/extend/formula_cop"
require "utils/array"
Copy link
Member Author

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?

Copy link
Member

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"
Copy link
Member Author

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.

@dduugg dduugg force-pushed the no-to_sentence branch 3 times, most recently from 01b3090 to ca62249 Compare March 1, 2023 05:11
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a 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"
Copy link
Member

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

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(dupe, sorry)

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Mar 2, 2023
@BrewTestBot
Copy link
Member

Review period ended.

@dduugg dduugg force-pushed the no-to_sentence branch 3 times, most recently from 5533188 to e4e91da Compare March 2, 2023 23:26
@dduugg
Copy link
Member Author

dduugg commented Mar 3, 2023

@MikeMcQuaid PR updated to keep to_sentence as a monkey-patch, PTAL

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a 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.

@dduugg dduugg changed the title Remove Array#to_sentence monkey-patch Move Array#to_sentence monkey-patch from ActiveSupport to extend/ Mar 4, 2023
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @dduugg!

@MikeMcQuaid MikeMcQuaid merged commit 9e370b0 into Homebrew:master Mar 6, 2023
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants