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

Replace Nokogiri with REXML #11610

Merged
merged 2 commits into from
Jun 30, 2021

Conversation

samford
Copy link
Member

@samford samford commented Jun 28, 2021

  • 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?

This is a follow-up to #11599, where I said I would replace use of nokogiri for XML parsing with rexml in parts of brew outside of the Sparkle livecheck strategy. These changes are generally a straightforward shift from nokogiri methods to rexml methods.

One notable difference is that rexml requires you to access attribute values using square bracket syntax instead of a method (like #attr in nokogiri).rexml has an #attribute method but it returns the full attribute (e.g., a="b"). We can't use a safe navigation operator in this context, so it was necessary to create an intermediate variable to be able to guard against nil values.

If we had more code doing this, I would say that we could probably just extend rexml to add an attr method that's just a wrapper for the square bracket syntax. This would allow us to use the safe navigation operator but I'm not sure if it's worth deviating from rexml's established API.


I'm not familiar with the BundleVersion and UnversionedCaskChecker classes but I've tried to exercise this using livecheck's ExtractPlist and Sparkle strategies, which use one or both of these classes. The output from checking casks that use these strategies was the same with and without these changes.

The other area where UnversionedCaskChecker is used is in the brew bump-unversioned-casks dev-cmd. I let this run for a few casks and it seemed to work as expected. I don't anticipate this introducing any issues but it wouldn't hurt for some homebrew/cask folks to test this out, as I'm not as knowledgeable about that side of Homebrew.

@BrewTestBot
Copy link
Member

Review period will end on 2021-06-29 at 00:10:57 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Jun 28, 2021
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.

Great work here! May be worth considering a brew style check (in a follow-up PR) that ensures there's no require "nokogiri" usage in Homebrew/brew.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Jun 29, 2021
@BrewTestBot
Copy link
Member

Review period ended.

@samford
Copy link
Member Author

samford commented Jun 29, 2021

May be worth considering a brew style check (in a follow-up PR) that ensures there's no require "nokogiri" usage in Homebrew/brew.

If we don't have any intention to keep nokogiri around for HTML parsing (this isn't necessary at the moment), should we simply remove it from the Gemfile? It was only added seven months ago and for these particular areas that we're replacing with rexml.

If we were to drop it from the Gemfile, would we still need/want a brew style check (e.g., to discourage it from being re-added) or no?

@MikeMcQuaid
Copy link
Member

If we don't have any intention to keep nokogiri around for HTML parsing (this isn't necessary at the moment), should we simply remove it from the Gemfile? It was only added seven months ago and for these particular areas that we're replacing with rexml.

If we were to drop it from the Gemfile, would we still need/want a brew style check (e.g., to discourage it from being re-added) or no?

Yes, I think it can/should be dropped from the Gemfile. If it's not being pulled in as a recursive dependency: we can probably do nothing. My only concern is that it just gets re-added at some point in future and a brew style check that says what to do instead may help a bit more? Definitely not blocking and very much optional, though.

@samford
Copy link
Member Author

samford commented Jun 30, 2021

Yes, I think it can/should be dropped from the Gemfile. If it's not being pulled in as a recursive dependency: we can probably do nothing.

nokogiri will still be installed as a dependency of mechanize but dropping it from the Gemfile (as a direct dependency) at least gets us back to where we were before it was added. I'll create a follow-up PR for the Gemfile/Gemfile.lock changes after I merge this.

My only concern is that it just gets re-added at some point in future and a brew style check that says what to do instead may help a bit more?

Certainly understandable to me. Last question: would we want the style check to also disallow gem "nokogiri" (in addition to require "nokogiri") or is the Gemfile out of scope?

Definitely not blocking and very much optional, though.

I'll try to tinker with this when I get a chance but, at the moment, there's some important livecheck work that I would like to focus on wrapping up into a PR first.

@samford samford merged commit b3d95b8 into Homebrew:master Jun 30, 2021
@samford samford deleted the replace-nokogiri-with-rexml-part-two branch June 30, 2021 00:52
@samford samford mentioned this pull request Jun 30, 2021
7 tasks
@MikeMcQuaid
Copy link
Member

Certainly understandable to me. Last question: would we want the style check to also disallow gem "nokogiri" (in addition to require "nokogiri") or is the Gemfile out of scope?

Up to you!

I'll try to tinker with this when I get a chance but, at the moment, there's some important livecheck work that I would like to focus on wrapping up into a PR first.

👍🏻 thanks for all your work here and on livecheck!

@github-actions github-actions bot added the outdated PR was locked due to age label Jul 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
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.

3 participants