🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

livecheck: prevent unnecessary boolean args#22823

Merged
MikeMcQuaid merged 1 commit into
mainfrom
livecheck/prevent-unnecessary-boolean-args
Jun 20, 2026
Merged

livecheck: prevent unnecessary boolean args#22823
MikeMcQuaid merged 1 commit into
mainfrom
livecheck/prevent-unnecessary-boolean-args

Conversation

@samford

@samford samford commented Jun 20, 2026

Copy link
Copy Markdown
Member

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

I recently added a boolean compressed option to the Livecheck.url method but it should only be used with a false value, as livecheck uses compression for page_content fetches by default. Similarly, homebrew_curl is another boolean option but it should only be true or omitted, as brewed curl isn't used by default.

This adds additional guards to Livecheck.url to prevent unnecessary values from being set as url options. This also modifies the related property types in Livecheck::Options to only allow the correct types. Under normal circumstances, users should only see the errors from Livecheck.url (not Sorbet type errors) as they prevent the method from setting Options values that would trigger a type error.

The stricter Options property types are a safeguard to ensure that we don't use incorrect values when setting these options in livecheck itself. For example, we have some code in livecheck that infers whether a check should use brewed curl and this sets the homebrew_curl option value. That logic should only be exercised if use_homebrew_curl? returns true but the stricter type would catch a false value if we were less careful.

I recently added a boolean `compressed` option to the `Livecheck.url`
method but it should only be used with a `false` value, as livecheck
uses compression for `page_content` fetches by default. Similarly,
`homebrew_curl` is another boolean option but it should only be `true`
or omitted, as brewed curl isn't used by default.

This adds additional guards to `Livecheck.url` to prevent unnecessary
values from being set as `url` options. This also modifies the related
property types in `Livecheck::Options` to only allow the correct
types. Under normal circumstances, users should only see the errors
from `Livecheck.url` (not Sorbet type errors) as they prevent the
method from setting `Options` values that would trigger a type error.

The stricter `Options` property types are a safeguard to ensure that
we don't use incorrect values when setting these options in livecheck
itself. For example, we have some code in livecheck that infers
whether a check should use brewed curl and this sets the
`homebrew_curl` option value. That logic should only be exercised if
`use_homebrew_curl?` returns `true` but the stricter type would catch
a `false` value if we were less careful.
Copilot AI review requested due to automatic review settings June 20, 2026 01:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tightens Livecheck.url’s option handling so callers can’t provide redundant/invalid boolean values for options that are effectively “default-on” (compressed) or “opt-in” (homebrew_curl). It also makes Livecheck::Options types reflect those stricter semantics and adds coverage to ensure the new guards raise user-facing ArgumentErrors.

Changes:

  • Add runtime guards in Livecheck#url to reject compressed: true and homebrew_curl: false.
  • Narrow Livecheck::Options Sorbet prop types to only allow compressed: false (or nil) and homebrew_curl: true (or nil).
  • Add RSpec examples covering the new ArgumentError cases.

Reviewed changes

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

File Description
Library/Homebrew/test/livecheck_spec.rb Adds regression tests ensuring invalid boolean values raise ArgumentError.
Library/Homebrew/livecheck/options.rb Tightens option prop types to enforce “set-only” semantics for compressed/homebrew_curl.
Library/Homebrew/livecheck.rb Adds argument guards in Livecheck#url to prevent setting unsupported boolean values.

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

Comment thread Library/Homebrew/livecheck/options.rb
Comment thread Library/Homebrew/livecheck/options.rb

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice idea!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jun 20, 2026
Merged via the queue into main with commit 29d65ce Jun 20, 2026
43 checks passed
@MikeMcQuaid MikeMcQuaid deleted the livecheck/prevent-unnecessary-boolean-args branch June 20, 2026 09:29
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.

3 participants