63 lines
2.2 KiB
Ruby
Raw Normal View History

rubocop: Use `Sorbet/StrictSigil` as it's better than comments - Previously I thought that comments were fine to discourage people from wasting their time trying to bump things that used `undef` that Sorbet didn't support. But RuboCop is better at this since it'll complain if the comments are unnecessary. - Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501. - I've gone for a mixture of `rubocop:disable` for the files that can't be `typed: strict` (use of undef, required before everything else, etc) and `rubocop:todo` for everything else that should be tried to make strictly typed. There's no functional difference between the two as `rubocop:todo` is `rubocop:disable` with a different name. - And I entirely disabled the cop for the docs/ directory since `typed: strict` isn't going to gain us anything for some Markdown linting config files. - This means that now it's easier to track what needs to be done rather than relying on checklists of files in our big Sorbet issue: ```shell $ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l 268 ``` - And this is confirmed working for new files: ```shell $ git status On branch use-rubocop-for-sorbet-strict-sigils Untracked files: (use "git add <file>..." to include in what will be committed) Library/Homebrew/bad.rb Library/Homebrew/good.rb nothing added to commit but untracked files present (use "git add" to track) $ brew style Offenses: bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true. ^^^^^^^^^^^^^ 1340 files inspected, 1 offense detected ```
2024-08-12 10:30:59 +01:00
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
# Path to `bin/brew` main executable in `HOMEBREW_PREFIX`
2022-05-30 04:05:07 +01:00
HOMEBREW_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_BREW_FILE")).freeze
# Where we link under
2022-05-30 04:05:07 +01:00
HOMEBREW_PREFIX = Pathname(ENV.fetch("HOMEBREW_PREFIX")).freeze
# Where `.git` is found
2022-05-30 04:05:07 +01:00
HOMEBREW_REPOSITORY = Pathname(ENV.fetch("HOMEBREW_REPOSITORY")).freeze
2024-04-30 11:10:23 +02:00
# Where we store most of Homebrew, taps and various metadata
2022-05-30 04:05:07 +01:00
HOMEBREW_LIBRARY = Pathname(ENV.fetch("HOMEBREW_LIBRARY")).freeze
# Where shim scripts for various build and SCM tools are stored
2019-04-19 21:46:20 +09:00
HOMEBREW_SHIMS_PATH = (HOMEBREW_LIBRARY/"Homebrew/shims").freeze
# Where external data that has been incorporated into Homebrew is stored
HOMEBREW_DATA_PATH = (HOMEBREW_LIBRARY/"Homebrew/data").freeze
# Where we store symlinks to currently linked kegs
2019-04-19 21:46:20 +09:00
HOMEBREW_LINKED_KEGS = (HOMEBREW_PREFIX/"var/homebrew/linked").freeze
# Where we store symlinks to currently version-pinned kegs
2019-04-19 21:46:20 +09:00
HOMEBREW_PINNED_KEGS = (HOMEBREW_PREFIX/"var/homebrew/pinned").freeze
# Where we store lock files
2019-04-19 21:46:20 +09:00
HOMEBREW_LOCKS = (HOMEBREW_PREFIX/"var/homebrew/locks").freeze
# Where we store built products
2022-05-30 04:05:07 +01:00
HOMEBREW_CELLAR = Pathname(ENV.fetch("HOMEBREW_CELLAR")).freeze
# Where we store Casks
HOMEBREW_CASKROOM = Pathname(ENV.fetch("HOMEBREW_CASKROOM")).freeze
2016-05-03 16:01:42 +08:00
# Where downloads (bottles, source tarballs, etc.) are cached
2022-05-30 04:05:07 +01:00
HOMEBREW_CACHE = Pathname(ENV.fetch("HOMEBREW_CACHE")).freeze
2016-05-03 16:01:42 +08:00
2021-01-26 15:21:24 -05:00
# Where formulae installed via URL are cached
2019-04-19 21:46:20 +09:00
HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze
2016-05-03 16:01:42 +08:00
2024-04-30 11:10:23 +02:00
# Where build, postinstall and test logs of formulae are written to
2022-05-30 04:05:07 +01:00
HOMEBREW_LOGS = Pathname(ENV.fetch("HOMEBREW_LOGS")).expand_path.freeze
# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
2022-05-30 04:05:07 +01:00
HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
tmp.mkpath unless tmp.exist?
tmp.realpath
2019-04-19 21:46:20 +09:00
end.freeze
# Where installed taps live
HOMEBREW_TAP_DIRECTORY = (HOMEBREW_LIBRARY/"Taps").freeze
# The Ruby path and args to use for forked Ruby calls
HOMEBREW_RUBY_EXEC_ARGS = [
RUBY_PATH,
2022-05-30 04:37:09 +01:00
ENV.fetch("HOMEBREW_RUBY_WARNINGS"),
2022-11-05 01:58:12 +00:00
ENV.fetch("HOMEBREW_RUBY_DISABLE_OPTIONS"),
].freeze