From a2e966c186e0dcdbae0ff17b05e0f752bf7c7f8a Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 29 Apr 2023 01:07:27 -0400 Subject: [PATCH] Xml: Move require outside of #parse_xml Since we use `REXML::Document` in the type signature for `#parse_xml`, we can encounter an `uninitialized constant Homebrew::Livecheck::Strategy::Xml::REXML` error in strategies like `Sparkle` that use `Xml#parse_xml` internally when the Sorbet runtime is used. Moving the related require outside of the `#parse_xml` method and into the `Xml` strategy proper resolves this issue. --- Library/Homebrew/livecheck/strategy/xml.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy/xml.rb b/Library/Homebrew/livecheck/strategy/xml.rb index 06c9b09457..5c0816b96c 100644 --- a/Library/Homebrew/livecheck/strategy/xml.rb +++ b/Library/Homebrew/livecheck/strategy/xml.rb @@ -1,6 +1,8 @@ # typed: true # frozen_string_literal: true +require "rexml/document" + module Homebrew module Livecheck module Strategy @@ -53,8 +55,6 @@ module Homebrew # @return [REXML::Document, nil] sig { params(content: String).returns(T.nilable(REXML::Document)) } def self.parse_xml(content) - require "rexml/document" - parsing_tries = 0 begin REXML::Document.new(content)