100 Commits
Author SHA1 Message Date
Douglas EichelbergerandMike McQuaid a923f27661 Update rubocop to 1.89.0
Also updates rubocop-sorbet (0.13.2 -> 0.14.0) and json (2.21.1 ->
2.21.2), which rubocop depends on.

Two suppressions can go away thanks to bug fixes in this release:

- rubocop/rubocop#15438 and rubocop/rubocop#15442 stop
  `Style/ArrayIntersect` firing when the `include?` receiver in a block
  is not an array literal, so the cop is re-enabled. It still cannot
  guarantee the *outer* receiver is an `Array`, and in
  `cask/artifact/abstract_uninstall.rb` that receiver is the `Enumerator`
  from `Pathname#each_filename`, which has no `intersect?`. Convert with
  `to_a` there rather than taking the autocorrect verbatim.
- rubocop/rubocop#15452 fixes the `Layout/HashAlignment` false positive on
  multi-line hash keys, so the two `delegate` disable comments in
  `formula.rb` are dead and removed.

One suppression is added: rubocop/rubocop#15493 makes
`Style/IfUnlessModifier` respect `Layout/LineLength`'s exemptions rather
than its `Max`. Several of our exemption patterns are unescaped regexes
(`"#{version."` matches `#{version}`, `#{version_text}` and
`#{version_info[...]}`), so the cop demanded modifier form for statements
that then ran to 179 characters. Disable the cop. Reported upstream as
rubocop/rubocop#15531.

rubocop-sorbet 0.14.0 widens `Sorbet/SetterReturnType` to cover setters
taking splat and keyword arguments, so several `depends_on` and ENV
setters switch to `.void`. Under `HOMEBREW_SORBET_RUNTIME` a `.void`
method returns the sentinel `T::Private::Types::Void::VOID`, which breaks
the two callers that consumed a setter's return value. Sorbet does not
catch either statically:

- `DependsOn#load` stored the result of `send(:"#{key}=", ...)` into the
  delegated hash, so the whole `depends_on` stanza became `VOID`. Read the
  value back through the matching reader instead.
- `Superenv#cc=` assigned `super` to `HOMEBREW_CC`, raising `TypeError:
  no implicit conversion of Module into String`. Assign from `val`.

Drop `extend/ENV/shared.rbi`, which existed to widen `[]=` to accept
`Pathname` and `PATH`. Without it `[]=` resolves to Sorbet's own
`ENVClass#[]=`, which takes `T.nilable(String)`, so the ENV assignments
convert explicitly with `to_s`/`&.to_s`. Both `Pathname` and `PATH`
define `to_str`, so Ruby was already converting implicitly and behaviour
is unchanged.

The remaining changes are new offenses in this release:

- `Lint/UselessAssignment` (rubocop/rubocop#12269) catches the
  `root_url = root_url =` workaround in `dev-cmd/tap-new.rb`. The Ruby
  `assigned but unused variable` warning it silenced no longer fires on
  our vendored Ruby, so drop it.
- `Style/RedundantParentheses` (rubocop/rubocop#15472) and
  `Layout/MultilineMethodCallIndentation` autocorrections.

The redundant `T.let` on `GitHub::API::ERRORS` is also dropped.

Claude-Session: https://claude.ai/code/session_01AdSQcU5MmY4VWiFdfrPeu2
2026-08-07 17:00:27 +01:00
Douglas Eichelberger 7e2cd509d4 Remove unused instance variables in API code
These instance variables are assigned but never read:

- `@stale_seconds` and `@target` in `Homebrew::API::JSONDownloadStrategy`
  and `Homebrew::API::JSONDownload`; the value is used via `meta[:target]`/
  `meta[:stale_seconds]` and the `target`/`stale_seconds` arguments, not the
  ivars. (`JSONDownloadStrategy#initialize` then only called `super`, so drop
  it too.)
- `@old_homebrew_cellar` in `APIHashable`, which is saved during API
  generation but never restored (only the prefix, home and git config are).

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-28 21:45:48 -07:00
Douglas Eichelberger 678b955aff Remove unused WhichFormula ENDPOINT and DATABASE_FILE constants
`brew which-formula` is a `ShellCommand` implemented in Bash
(utils/executables.sh), so these Ruby constants were never read at runtime;
only the spec referenced `DATABASE_FILE`. Remove both and have the spec write
the database to the same path `Homebrew::API.write_executables_file!` uses.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-26 14:25:15 -07:00
Douglas Eichelberger c791ca532e Remove dead requirements_lines methods from brew info
`Info.requirements_lines` has no callers, and its only callee
`Info.cask_requirements_lines` is unused once it is gone. Remove both and
drop `cask_requirements_lines` from the `private_class_method` list.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-26 14:25:15 -07:00
Douglas Eichelberger 9391c398b8 Remove dead Homebrew::Services code and extract a test-only helper
`FormulaWrapper#plist?` and `System.user_of_process` have no callers, and
`System.reset_launchctl!`/`Systemctl.reset_executable!` existed only to let
specs clear memoized lookups. Remove all four from the runtime classes and
move the cache reset into a `Test::Helper::Services#reset_services_memoization!`
helper used by the specs that need it.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-26 12:16:42 -07:00
Douglas Eichelberger 29cb5e338a Document service block methods as public API
Annotate every method in the Formula Cookbook's "Service block methods"
table as `@api public` in `Service`, with documentation matching the
cookbook's descriptions, and add the missing `stop_timeout` row to the table.

Enforce a 1:1 correspondence between the table and the `service.rb`
annotations in the `Homebrew/PublicApiCookbook` cop, backed by a new
`SERVICE_COOKBOOK_METHODS` list, so the two cannot drift.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-26 12:16:42 -07:00
Douglas Eichelberger fa7c1ef68f Remove unused GitHub and Git helper methods
These definitions are no longer referenced anywhere after their last
callers were removed:

- GitHubRunnerMatrix's MacOSRunnerSpecHash and LinuxRunnerSpecHash type
  aliases, unused since #22239.
- Utils::Git.count_coauthors, GitHub.count_repository_commits,
  GitHub.repo_commits_for_user and
  GitHub.search_merged_pull_requests_in_user_or_organisation, unused since
  #23206.

Also remove the ::count_repo_commits spec block, which only covered the
removed GitHub commit-counting helpers.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-25 21:40:22 -07:00
Douglas Eichelberger 10e43c882d Remove test-only FormulaInstaller.clear_* class methods
`FormulaInstaller.clear_attempted`, `clear_installed` and `clear_fetched`
exist only to reset the class-level tracking sets between test examples;
they have no production callers. Keep such test-only helpers out of the
runtime class: remove the three methods and reset the sets directly with
`Set#clear` in the specs that need it.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-25 21:34:12 -07:00
Douglas Eichelberger 99e7f7f2ad Remove unused services subcommand TRIGGERS constants
Each `Homebrew::Cmd::Services::*Subcommand` defined a `TRIGGERS`
constant, but nothing reads it: the subcommand names and aliases used to
dispatch `brew services <subcommand>` come from `subcommand_name` and the
`subcommand_args aliases:` declaration in `AbstractCommand`. The
constants (and the four specs asserting their contents) are dead
duplication, so remove them.

Claude-Session: https://claude.ai/code/session_011BgWRBydtdkvt8ocqH4nj9
2026-07-19 21:39:18 -07:00
Douglas EichelbergerandDouglas Eichelberger d4fb3fc04b Remove unused default repository and product constants
The `HOMEBREW_PRODUCT`, `HOMEBREW_DEFAULT_REPOSITORY`,
`HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY` and
`HOMEBREW_LINUX_DEFAULT_REPOSITORY` constants in `global.rb` are never
referenced anywhere in the codebase. Remove them along with the now
unnecessary env var exports in `brew.sh`. The underlying shell variables
remain set and used within `brew.sh` where needed; only their exports
(which existed to populate the removed Ruby constants) are dropped.

Claude-Session: https://claude.ai/code/session_01XcY6NJn468hSt2n4WVkfoK
2026-07-18 17:54:06 -07:00
Douglas Eichelberger 83eb38c7f6 Remove dead API methods and move generated_hash! to tests
Extracted from the typecheck-deadcode branch (Homebrew/brew#22733 was the
first extraction), which uses Spoom to find code with no static callers.

Remove four methods with no callers:

- Homebrew::API.cached_formula_json_file_path
- Homebrew::API::Cask.all_renames
- Homebrew::API::Formula.all_renames
- APIHashable#generated_hash!

Renames are resolved through Homebrew::API.formula_renames and
Homebrew::API.cask_renames, which read the internal API, so the
all_renames pair on the JSON API classes is unused. The only remaining
references were vestigial RSpec stubs, so drop those too.

APIHashable#generated_hash! reverts the global monkeypatches applied by
generating_hash!. The generate-*-api commands exit once they are done and
never call it, so it is only needed to stop tests leaking global state.
Move it to a test helper rather than keeping it in production code.
2026-07-13 22:52:42 -07:00
Douglas Eichelberger f9bfe41c86 Experiment: no-op type constructors when sorbet runtime disabled 2026-07-13 00:22:58 -07:00
Douglas Eichelberger f27a018cf0 settings: read all settings with one git invocation per repository 2026-07-10 08:09:24 -07:00
Douglas Eichelberger e7277d9fa1 utils: add parallel_map for concurrent subprocess and network waits 2026-07-09 18:09:49 -07:00
Douglas Eichelberger 22a514b56f avoid filesystem checks from Pathname presence tests 2026-07-06 18:31:19 -07:00
Douglas Eichelberger 6955480c07 config: gather system configuration concurrently 2026-07-06 13:06:36 -07:00
Douglas Eichelberger 1e81b7fc08 api: avoid linear scans of core formula names and cask tokens 2026-07-06 09:46:57 -07:00
Douglas Eichelberger 6f92c66c7e tap-info: generate tap JSON hashes concurrently 2026-07-06 09:43:14 -07:00
Douglas Eichelberger 78032164c4 standalone/sorbet: skip sorbet-runtime dispatch when runtime disabled 2026-07-05 23:27:58 -07:00
Douglas Eichelberger 7ce8324e07 Remove redundant T.let from DEFAULT_CURL_ARGS
Without the annotation the frozen array constant infers as a
fixed-size tuple, which changed how Sorbet resolved the curl_output
calls that splat it, leaving stdout/status typed as NilClass and
SystemCommand::Result. Destructure via an explicit .to_a so the
multiple assignment typechecks against the tuple inference.
2026-07-05 17:31:51 -07:00
Douglas Eichelberger 3dec0b79b8 Remove redundant T.let annotations
Sorbet infers constant types from simple literals, literal arrays and
constructor calls (since 0.6.13304, including .freeze-d values), and
infers instance variable types assigned from signature parameters in
initialize. Remove T.let annotations that just restate those inferred
types, as found by the Sorbet/RedundantTLet and
Sorbet/RedundantTLetForLiteral cops proposed in
https://github.com/Shopify/rubocop-sorbet/pull/381.

dev-cmd/bump.rb's DEFAULT_CURL_ARGS is deliberately left annotated:
without T.let it infers as a fixed-size tuple, which changes how
Sorbet resolves the curl_output calls that splat it and fails brew
typecheck.
2026-07-05 17:24:26 -07:00
Douglas Eichelberger b0d8481e32 Remove T.let from frozen constants Sorbet can now infer
Sorbet 0.6.13304 infers `X = A.new.freeze` the same as `X = A.new`,
so constants assigned a direct `.new` call followed by `.freeze` no
longer need explicit `T.let` type annotations. `Pathname(...)`
kernel-method calls are not inferred, so those are converted to
`Pathname.new(...)` instead.

Similarly, pure-literal arrays are inferred through `.freeze` as
fixed-size tuple types, which are subtypes of the previously declared
`T::Array` types. Arrays containing splats, constant references,
method calls or no elements at all are still not inferred and keep
their `T.let` annotations.
2026-07-04 09:25:19 -07:00
Douglas Eichelberger 57bba2eb40 Convert Pathname constants to strings for system/exec calls
Sorbet 0.6.13304+ (sorbet/sorbet#10377) now infers `X = A.new.freeze`
with the same type as `X = A.new`, so `RUBY_PATH` and
`HOMEBREW_BREW_FILE` are typed as `Pathname` instead of `T.untyped`.
Passing them to `Kernel#system`, `Open3.capture3` and `String#gsub`,
whose RBIs only accept `String`, now fails typechecking, so call
`.to_s` at those sites and update the sandbox specs to match.
2026-06-27 17:49:59 -07:00
Douglas Eichelberger e46238b45f Remove dead Formula methods and annotate public DSL
Removes Formula methods with no callers in Homebrew or the official taps:
specified_name, installed_specified_name, full_formulae, prefix_linked?,
core_alias_files, internal_dependencies_hash and allow_network_access!
(also dropped from FORMULA_COMPONENT_PRECEDENCE_LIST and the generated
DSL RBI), along with their now-dead specs.

Annotates the formula DSL methods that the official taps rely on but
which lacked an `@api` tag as `@api public`: pypi_packages, test_fixtures,
xcodebuild and deny_network_access!.
2026-06-22 20:25:54 -07:00
Douglas Eichelberger 88984869fa Remove dead code in Library/Homebrew/utils/
Remove unused methods in utils/ identified by a Spoom-backed deadcode pass
(that respects `override` sigs and `@api` annotations), along with their
now-orphaned specs: Inreplace.inreplace_pairs, GitRepository.git_commit_message,
GitHub.permission, GitHub.public_member_usernames, AST::FormulaAST#remove_stanzas,
and others.

- Mark TopologicalHash#tsort_each_node/#tsort_each_child as `override`, since
  they override TSort's abstract methods.
- Relocate test-only cache resets (Svn.clear_version_cache,
  Tar.clear_executable_cache) into their specs, keeping the source focused on
  shipped behavior.
- Keep Utils.binary_linked_to_library? (`@api internal`) and Utils::Gzip.compress
  (`@api public`): nothing in brew calls them, but homebrew-core does (~58 and
  ~31 call sites respectively). Document Gzip.compress (covered by the
  Reproducible Builds guide) and add it to Style/Documentation's Include list.
2026-06-10 17:24:07 -07:00
Douglas Eichelberger 2677aedea8 system_command: avoid loading plist and URI libraries at startup
These two requires were loaded globally on every brew invocation via
extend/pathname → system_command, but neither was needed at startup:

- `plist`: only used in Result#plist method body; deferred with a lazy
  require inside the method. This avoids loading the plist gem and its
  transitive deps (cgi, date, stringio) for commands that don't parse
  plist output (the vast majority).

- `uri`: URI::Generic only appears in Sorbet sigs. Changed the six
  affected sigs to T::Sig::WithoutRuntime.sig so the sig blocks are
  not evaluated at runtime, allowing the require to be dropped
  entirely. Added an explicit require "stringio" since that was a
  transitive dep of plist relied on by utils/tty.rb.

Also adds an AGENTS.md note to always use `./bin/brew ruby` instead
of the system Ruby when running Ruby directly.
2026-05-03 15:20:54 -07:00
Douglas Eichelberger 9d32bcb4d0 perf: replace inject("+") with sum and use filter_map in utils
- Replace `results.values.inject("+")` with `results.values.sum` in
  analytics.rb (two call sites)
- Replace chained `.reject(&:build?).reject(&:test?).map(&:to_formula)`
  with `.filter_map { |d| d.to_formula if !d.build? && !d.test? }` in
  topological_hash.rb
2026-04-21 08:47:07 -07:00
Douglas Eichelberger 1cdad0b6c0 deps: skip recursive_req_includes when --include-requirements not passed
`deps_for_dependent` always called `recursive_req_includes` in the
recursive branch, even though `condense_requirements` immediately
discards any `Requirement` objects unless `--include-requirements` is
explicitly passed. Skipping the expansion avoids traversing the static
dependency tree and loading formula objects for transitive dependencies
of every installed formula.

This mirrors the existing pattern in `dependables`, which already guards
`select_includes(formula.requirements, ...)` behind
`args.include_requirements?`.

Also replaces `T.unsafe` with `T.cast` in `dependencies_helpers.rb`
since the return type is known.

Benchmarked on `brew deps --installed` with 235 installed formulae:
~10% wall-time improvement (~20% user-time improvement).
2026-04-15 21:44:45 -07:00
Douglas Eichelberger 8092337994 fix: handle renames and unavailable formulae in autoremove/doctor
- Use f.possible_names (name + oldnames + aliases) instead of f.name
  when checking against tab-derived dep name sets in autoremove, so
  renamed formulae are not incorrectly marked as removable.
- Rescue FormulaUnavailableError in the two callers that call
  to_installed_formula on missing_dependencies results (diagnostic.rb
  and installed_dependents.rb), matching the pre-refactor behaviour of
  silently skipping deps whose formula files are no longer available.
2026-04-12 21:38:34 -07:00
Douglas Eichelberger 1e8f1eeb03 perf: avoid Formulary.resolve per dep in autoremove/cleanup/doctor
autoremove / cleanup
--------------------
bottled_formulae_with_no_formula_dependents: replace
installed_runtime_formula_dependencies with direct tab data reads.
Build a Set of dep base names from tab.runtime_dependencies hashes
instead of resolving each dep via Formulary.resolve. Fallback kept for
pre-1.1.6 installations.

Rename formulae_with_cask_dependents to cask_dependent_formula_names,
returning T::Set[String] instead of T::Array[Formula]. Look up cask
formula deps by name in the already-loaded formulae array (O(1) hash)
instead of calling Formulary.resolve. Same tab-data path for transitive
deps.

brew autoremove --dry-run: 3.68s -> 1.65s (~55% faster)
brew cleanup --dry-run:    7.39s -> 5.72s (~23% faster)

brew doctor (check_missing_deps)
---------------------------------
missing_dependencies called dep.to_installed_formula.installed_prefixes.none?
for every runtime dep of every installed formula, triggering
Formulary.resolve per dep.

Replace with (HOMEBREW_CELLAR/base_name).directory? — a single
filesystem stat. Also extract base_name before the hide check, fixing a
pre-existing bug where tapnamed deps (e.g. "homebrew/core/wget") could
not be matched by base-name hide lists.

check_missing_deps:  0.95s -> 0.06s (~15x faster)
brew doctor overall: 6.24s -> 5.51s (~12% faster)

check_deprecated_disabled
--------------------------
Combine two Formula.installed.select calls into one pass.

Tests
-----
- formula_spec: add describe "#missing_dependencies" covering no tab
  data, installed dep, missing dep, hidden dep (even when installed),
  and tapnamed dep matched by base-name hide list (the bug-fix case).
- autoremove_spec: add context for when tab.runtime_dependencies returns
  actual hashes, asserting installed_runtime_formula_dependencies is not
  called (exercises the new fast path rather than only the nil fallback).
2026-04-12 19:01:02 -07:00
Douglas Eichelberger 3016643418 formula: use Pathname#empty? instead of children.empty? to check for installation
`Pathname#children.empty?` reads all directory entries into a Ruby Array
just to check whether any exist. `Pathname#empty?` (backed by
`Dir.empty?`) stops at the first entry, avoiding the full enumeration.

Microbenchmark (100,000 iterations, 11-entry Cellar keg directory):
  dir.children.empty? : 3084ms
  dir.empty?          : 2136ms (~1.44x faster)

`Formula#latest_version_installed?` and the prefix-installed check in
install.rb are called for every formula when commands like
`brew deps --installed` enumerate installed formulae, so the savings
compound across the full set.
2026-04-03 07:46:40 -07:00
Douglas EichelbergerandDouglas Eichelberger d03d51d887 Enable strict typing in Library/Homebrew/rubocops/ 2026-03-30 20:04:55 -07:00
Douglas Eichelberger 83843322c8 sorbet: enable experimental RSpec mode
Add `--enable-experimental-rspec` to the Sorbet config so that Sorbet
type-checks RSpec spec files. This is an isolated piece of the work in
#21690, separated so that the follow-up work of dialling up the `typed:`
level of individual specs can land independently.

Enabling the flag surfaced a pre-existing type error in
`formula-analytics/pycall-setup.rbi` where `InfluxDBClient3#initialize`
was incorrectly declared as a singleton method (`def self.initialize`)
rather than an instance method (`def initialize`). Fixed here since the
error is only visible with RSpec mode enabled.
2026-03-15 12:59:41 -07:00
Douglas Eichelberger 36a633a4d7 Remove RSpec/DescribedClass cop disables in specs
Use idiomatic RSpec patterns to avoid needing `rubocop:disable`
for `RSpec/DescribedClass`:

- `free_port_spec.rb`: Test the mixin via
  `Object.new.extend(described_class)` instead of `include`-ing
  the module into the example group.
- `virtualenv_spec.rb`: Capture `described_class` in a local
  variable before the `formula` DSL block so the closure carries
  it into the class scope where `described_class` is unavailable.
2026-02-21 20:14:25 -08:00
Douglas Eichelberger d01297127b Address review feedback for inject_dump_stats!
- Fix incorrect comment that claimed `Module` and `Regexp` are
  global variables; replace with accurate description of `$times`.
- Track wrapped method names in `injected_methods` to prevent
  duplicate wrapping on repeated calls.
- Fix `@injected_dump_stat_modules` type from `T::Array[String]`
  to `T::Array[Symbol]` to match `instance_methods` return type.
2026-02-21 16:58:21 -08:00
Douglas Eichelberger e836ef5679 Fix stack overflow in inject_dump_stats! with prepended modules
`inject_dump_stats!` captured methods via `instance_method` (which
returns the prepended module's version) then redefined them on the
class with `bind_call`. When the captured prepended method called
`super`, it resolved to the newly defined class method, creating an
infinite recursion.

Use an anonymous wrapper module with `super` instead of
`bind_call` to correctly delegate through the method resolution
order without cycles.

Fixes #21587
2026-02-21 16:58:05 -08:00
Douglas Eichelberger 599be9ee62 Extract Homebrew module from utils.rb into homebrew.rb
Split `utils.rb` into `homebrew.rb` (Homebrew module) and
`utils.rb` (Utils module) with a corresponding spec file.

This was motivated by rubocop-rspec disallowing multiple top-level
describes, and it also makes sense for files to match the namespace
they open.
2026-02-21 16:57:36 -08:00
Douglas Eichelberger 78d87cea45 Remove unnecessary T.let from literal constants
- Remove T.let from regexp literals in tap_constants, keg_relocate,
  extend/os/mac/keg_relocate, utils/github/api, livecheck/strategy/gnu
  (keep T.let for Regexp.new/union and interpolated regexes)
- Remove T.let from string constants in keg_relocate placeholders,
  utils/github/api (API_URL, etc.), services/system, mcp_server,
  rubocops/cask/uninstall_methods_order
- Remove T.let from integer constants in utils/github, services/system,
  dev-cmd/contributions, mcp_server
- Skip collection literals (arrays, hashes) and T::Boolean per convention
2026-02-07 17:03:50 -08:00
Douglas Eichelberger 1b695ecf25 Incorporate copilot feedback 2026-02-07 15:08:14 -08:00
Douglas Eichelberger 5a8c0dfd4f Fix test bot regressions and add regression specs
- test_formulae: use [] instead of fetch for @downloaded_artifacts so new
  SHAs use the hash default (empty array) and avoid KeyError
- junit: require rexml/document, xmldecl, cdata in #initialize so REXML
  is loaded before use (fixes uninitialized constant on Linux CI)
- test_cleanup: pass HOMEBREW_REPOSITORY.to_s to checkout_branch_if_needed,
  reset_if_needed, clean_if_needed (fixes Pathname type error when tap set)
- Add test_formulae_spec to prevent KeyError regression for new SHA access
- Add junit_spec to prevent REXML NameError regression
- Add test_cleanup_spec to prevent Pathname regression
2026-02-07 09:42:54 -08:00
Douglas Eichelberger 1a956e7b77 Reapply "Enable strict typing in Homebrew::TestBot"
This reverts commit 6bab83ccc9.
2026-02-07 09:10:28 -08:00
Douglas Eichelberger e6f2b58ea9 Incorporate feedback 2026-02-05 13:43:24 -08:00
Douglas Eichelberger cc7ef4e2a8 Enable strict typing in Homebrew::TestBot 2026-02-05 06:30:47 -08:00
Douglas Eichelberger 07b919c4c9 Remove OpenStruct, replace with test doubles 2026-02-04 16:51:14 -08:00
Douglas Eichelberger ae110cab71 Don't rescue Errno::ENOTEMPTY in recursive_rmdir 2026-02-02 21:17:03 -08:00
Douglas Eichelberger 4e37f2ad25 Fix Cleanup.stale_version? logic 2026-02-02 04:22:23 -08:00
Douglas Eichelberger 2d063961d5 Incorporate feedback 2026-02-01 23:48:02 -08:00
Douglas Eichelberger 3c7ecd136f cask/artifact: enable Sorbet typed: strict for abstract classes
Enable strict typing for the abstract base classes in `Cask::Artifact`:
- `AbstractArtifact`
- `AbstractFlightBlock`
- `AbstractUninstall`
- `Relocated`

This adds proper type signatures to all methods and updates the typing
level from `typed: true` to `typed: strict`.

Also marks `english_name` and `dirmethod` as `overridable` in
`AbstractArtifact` and adds `override` to subclasses that override them.

Advances https://github.com/Homebrew/brew/issues/17297
2026-02-01 05:34:18 -08:00
Douglas Eichelberger 1cb35b44c9 bottle_specification: add Sorbet strict typing
Add `typed: strict` sigil and explicit type signatures throughout
the BottleSpecification class for improved type safety.

Update callers in api/formula_struct, dev-cmd/bottle, and formula
to satisfy the stricter type requirements.
2026-02-01 04:46:23 -08:00
Douglas Eichelberger 47b2fbff6a bottle: add Sorbet strict typing
Add `typed: strict` sigil and explicit type signatures throughout
the Bottle class and Bottle::Filename class for improved type safety.

Update callers in attestation, cleanup, executables_db, formula_installer,
and utils/bottles to satisfy the stricter type requirements.
2026-01-30 10:08:06 -08:00
Douglas Eichelberger 02b2924aed Replace remainting T.must use 2026-01-25 15:59:20 -08:00
Douglas Eichelberger af2fd0fb20 cask/list: move tap_and_name_comparison from kernel
Move `tap_and_name_comparison` from `extend/kernel.rb` to `cask/list.rb`
as a class method since it's only used by the list commands. Update
call sites in `cmd/list.rb` and move corresponding specs.
2026-01-25 11:35:24 -08:00
Douglas Eichelberger 3426203e82 Apply utils/popen suggestions 2026-01-25 10:02:05 -08:00
Douglas Eichelberger 103bf7f9e8 utils/popen: enable typed: strict
Add Sorbet type signatures to all methods in `Library/Homebrew/utils/popen.rb`
and update callsites to resolve resulting type errors.

- Add `sig` blocks with type parameters to `popen_read`, `safe_popen_read`,
  `popen_write`, `safe_popen_write`, and `popen` methods
- Add `IO#wait_readable` type definition to `upstream.rbi`
- Fix callsite type errors across 13 files:
  - Use `.fetch()` instead of `.first`/`.last` for array access
  - Add `T.must()` for potentially nil values
  - Add `T.cast()` for regex scan results
  - Update return type signatures where needed

Contributes to #17297.
2026-01-25 09:41:43 -08:00
Douglas Eichelberger b95d9cef17 formatter: move formatting methods from kernel
Move `disk_usage_readable_size_unit`, `disk_usage_readable`,
`number_readable`, and `redact_secrets` from `extend/kernel.rb` to
`utils/formatter.rb` as class methods. These methods are formatting
utilities that fit better in the Formatter module.

Update all call sites and move corresponding specs to formatter_spec.rb.
2026-01-25 09:08:57 -08:00
Douglas Eichelberger 5858ef5078 gist-logs: move truncate_text_to_approximate_size from kernel
Move `truncate_text_to_approximate_size` from `extend/kernel.rb` to
`cmd/gist-logs.rb` as a public class method since `gist-logs` is its
only caller. Move the corresponding specs as well.
2026-01-24 20:50:35 -08:00
Douglas Eichelberger a2f1cee190 update-report: use Version class for version parsing
Refactors the update report version logic to use Homebrew's existing
`Version` class instead of manual string parsing:

- Use `fetch(0)` instead of `first` for safer array access
- Replace manual version string splitting with `Version#major_minor`
  and `Version#patch` methods
- Simplify URL construction using `major_minor` method

This improves code maintainability by leveraging existing version
handling infrastructure and provides better type safety.
2026-01-24 19:10:34 -08:00
Douglas Eichelberger 2a50a1e06f descriptions,search: use typed: strict and T::Enum
## Summary

- Add `Descriptions::SearchField` enum with `Name`, `Description`, and
  `Either` values to replace symbol-based field parameter
- Upgrade `descriptions.rb` and `search.rb` to `typed: strict`
- Add Sorbet type signatures to all methods in both files
- Use exhaustive case matching with `T.absurd` for type safety
- Remove redundant `cache_store_hash` parameter by using `is_a?` check

Contributes to #17297.
2026-01-24 13:54:56 -08:00
Douglas Eichelberger 239d748c9d deps: enable Sorbet strict typing
Add Sorbet `typed: strict` sigil and full type signatures to
`cmd/deps.rb`, promoting the last non-strict brew command to
strict typing.

Changes:
- Add `sig` type signatures to all private methods
- Replace block parameter in `deps_for_dependents` with a
  `DepsCombineMode` enum for better type safety
- Initialize `@use_runtime_dependencies` with `T.let` in constructor

Ref: https://github.com/Homebrew/brew/issues/17297
2026-01-19 15:25:08 -08:00
Douglas Eichelberger 8fcd61488c Replace numbered params with it params 2025-12-28 16:16:03 -08:00
Douglas Eichelberger b0e20591d0 Restore Style/RedundantLineContinuation following upstream fix 2025-11-02 17:28:11 -08:00
Douglas Eichelberger 11cfdaf823 Bump rubocop TargetRubyVersion 2025-11-02 08:57:48 -08:00
Douglas Eichelberger 7b2171a1d9 Resolve linux failures 2025-09-14 23:05:06 -07:00
Douglas Eichelberger 3646b17de7 Enable recursive typechecking in specs 2025-09-14 20:43:53 -07:00
Douglas Eichelberger b827a1337a Enable strict typing in Utils::Bottles 2025-09-08 10:48:23 -07:00
Douglas Eichelberger bbca610601 Use type-safe blocks 2025-09-07 12:13:36 -07:00
Douglas EichelbergerandDouglas Eichelberger fb6c51da07 Enable strict typing in SystemCommand 2025-09-02 10:26:40 -07:00
Douglas Eichelberger 240fd71e6f Avoid repeated calls to affix checks 2025-08-31 11:11:41 -07:00
Douglas Eichelberger 4d11307d41 Refactor T.must called on .last 2025-08-25 20:30:31 -07:00
Douglas Eichelberger d97933b38c Refactor T.must called on .first 2025-08-25 20:27:47 -07:00
Douglas Eichelberger 5ed25c4329 Enable Sorbet/Refinement 2025-08-25 07:40:22 -07:00
Douglas Eichelberger 6a25de5daf Rename formula_support to keg_only reason, refactor slightly 2025-08-24 14:57:19 -07:00
Douglas Eichelberger 2dc4c7a4d2 Rename Volumes.which to avoid incompatible override 2025-08-24 14:34:31 -07:00
Douglas Eichelberger ceb2291be1 Enable strict typing in Kernel extensions + utils.rb 2025-08-23 18:44:36 -07:00
Douglas Eichelberger 73bb781d1d Enable strict typing in yard extensions 2025-08-23 09:23:30 -07:00
Douglas Eichelberger bdc219a39a Move 'paths' out of Kernel 2025-08-16 16:38:27 -07:00
Douglas Eichelberger 793da6e0be Remove unused 'which_all' Kernel ext 2025-08-16 16:18:26 -07:00
Douglas Eichelberger 0e064fdc3a Type remaining Kernel log extensions 2025-08-16 13:07:19 -07:00
Douglas Eichelberger 899a6c5977 Try non-nil params 2025-08-10 09:37:57 -07:00
Douglas EichelbergerandDouglas Eichelberger 40c58a883d Enable strict typing in Tap 2025-08-04 13:11:15 -07:00
Douglas EichelbergerandDouglas Eichelberger 157992be17 Enable strict typing in Cask::Audit 2025-07-30 12:43:32 -07:00
Douglas Eichelberger 0a4b064059 Fix specs 2025-07-28 21:14:23 -07:00
Douglas Eichelberger 5177db7dc9 Remove redundant yard tags 2025-07-28 17:14:03 -07:00
Douglas Eichelberger c4b02465f5 Reduce shape variations in Homebrew::Service 2025-07-28 17:03:43 -07:00
Douglas Eichelberger c738d5c007 Fix type error in Readall 2025-07-27 10:07:34 -07:00
Douglas Eichelberger e78cc286e0 Keep exiting zero on already pinned formulae 2025-07-04 13:55:12 -07:00
Douglas Eichelberger f4bcda325a Exit non-zero when pinning uninstalled formula 2025-07-04 13:28:54 -07:00
Douglas Eichelberger fb01c0fa96 Update another overly narrow return type 2025-06-29 11:30:06 -07:00
Douglas Eichelberger 004c0a2a6c Refactor exec.rb type fixes 2025-06-29 09:02:24 -07:00
Douglas Eichelberger 8253e89eea Improve readability of disabled command message 2025-05-10 09:23:34 -07:00
Douglas Eichelberger b3b6c147fb perf: rubocop/tapioca parser optimizations 2025-04-01 21:26:09 -07:00
Douglas Eichelberger e58486cd4c fix: Allow Formula.url with no args to get url 2025-03-26 12:15:25 -07:00
Douglas Eichelberger b131f47d75 fix: DownloadStrategy meta params should be untyped 2025-03-14 18:18:58 -07:00
Douglas Eichelberger 39843b5d40 Resolve violations 2025-03-13 12:16:11 -07:00
Douglas Eichelberger c48870080e Incorporate feedback 2025-03-13 11:59:31 -07:00
Douglas Eichelberger f183d0a398 Enable strict typing in Cask::URL 2025-03-12 19:09:52 -07:00
Douglas Eichelberger e49a69679d Enable strict typing in TopologicalHash 2025-03-12 19:09:52 -07:00
Douglas Eichelberger 1ca5299f40 refactor: Enable strict typing in download_strategy 2025-03-12 15:15:20 -07:00
Douglas Eichelberger f181e4251b Include RBS rbi 2025-03-12 13:43:55 -07:00
Douglas Eichelberger 9627edd407 Convert rubocop-performance to plugin 2025-03-04 13:10:48 -08:00