Skip to content

Conversation

@samford
Copy link
Member

@samford samford commented Jan 29, 2026

  • 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 lgtm (style, typechecking and tests) with your changes locally?

This expands test coverage for livecheck's Xml strategy, bringing it to 100% coverage for lines and branches.

To achieve this, it was necessary to strengthen the return type of parse_xml and remove a related guard in versions_from_content that can never be true. parse_xml should only ever return an REXML::Document or raise an error, so it can't return nil.

Like #21476, this is part of some overarching work to ensure that all strategy find_versions methods have a content parameter (except ExtractPlist) and to increase test coverage for all the strategies to 100%. Changing the parse_xml return type felt a little out of scope, so I split this into a separate PR.

Copilot AI review requested due to automatic review settings January 29, 2026 20:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands test coverage for the livecheck Xml strategy to 100%, while also strengthening type safety by making the return type of parse_xml non-nullable.

Changes:

  • Strengthened the return type signature of Xml.parse_xml from T.nilable(REXML::Document) to REXML::Document
  • Removed unreachable guard in versions_from_content that checked for blank XML
  • Added comprehensive test coverage for error handling edge cases in XML parsing
  • Refactored test structure to use a more maintainable match_data hash organization

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/livecheck/strategy/xml.rb Updated return type signature for parse_xml to be non-nullable and removed unreachable blank check
Library/Homebrew/test/livecheck/strategy/xml_spec.rb Added new error handling tests, refactored test data structure, and expanded coverage to 100%

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samford samford force-pushed the livecheck/xml-expand-test-coverage branch 2 times, most recently from 1b81af7 to 6ae96e9 Compare January 30, 2026 00:52
This expands test coverage for livecheck's `Xml` strategy, bringing it
to 100% coverage for lines and branches.

To achieve this, it was necessary to strengthen the return type of
`parse_xml` and remove a related guard in `versions_from_content` that
can never be true. `parse_xml` should only ever return an
`REXML::Document` or raise an error, so it can't return `nil`. The
`Sparkle.items_from_content` method contains the same guard, so this
removes it from there as well.
@samford samford force-pushed the livecheck/xml-expand-test-coverage branch from 6ae96e9 to b48abf4 Compare January 30, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants