Merge pull request #13433 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-1.30.1

build(deps): bump rubocop from 1.27.0 to 1.30.1 in /Library/Homebrew
This commit is contained in:
Bo Anderson 2022-06-17 20:31:00 +01:00 committed by GitHub
commit ee93d7e08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 537 additions and 291 deletions

View File

@ -107,7 +107,6 @@ jobs:
brew tap homebrew/cask-versions
brew tap homebrew/command-not-found
brew tap homebrew/formula-analytics
brew tap homebrew/linux-dev
brew tap homebrew/portable-ruby
brew tap homebrew/services
@ -136,7 +135,6 @@ jobs:
homebrew/autoupdate\
homebrew/command-not-found \
homebrew/formula-analytics \
homebrew/linux-dev \
homebrew/portable-ruby
- name: Run brew style on cask taps

View File

@ -97,7 +97,7 @@ Naming/InclusiveLanguage:
- "patches/13_fix_scope_for_show_slave_status_data.patch" # Used in formula `mytop`
Naming/MethodName:
IgnoredPatterns:
AllowedPatterns:
- '\A(fetch_)?HEAD\?\Z'
# Both styles are used depending on context,
@ -122,6 +122,14 @@ Style/BarePercentLiterals:
Style/CollectionMethods:
Enabled: true
# This is quite a large change, so don't enforce this yet for formulae.
# We should consider doing so in the future, but be aware of the impact on third-party taps.
Style/FetchEnvVar:
Exclude:
- "Taps/*/*/*.rb"
- "/**/Formula/*.rb"
- "**/Formula/*.rb"
# Prefer tokens with type annotations for consistency
# between formatting numbers and strings.
Style/FormatStringToken:
@ -389,7 +397,7 @@ Naming/MethodParameterName:
Layout/LineLength:
Max: 118
# ignore manpage comments and long single-line strings
IgnoredPatterns:
AllowedPatterns:
[
"#: ",
' url "',

View File

@ -123,13 +123,13 @@ GEM
rspec (>= 3, < 4)
rspec_junit_formatter (0.5.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.27.0)
rubocop (1.30.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.16.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.18.0)

View File

@ -11,35 +11,14 @@ raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unle
std_trap = trap("INT") { exit! 130 } # no backtrace thanks
# check ruby version before requiring any modules.
unless ENV["HOMEBREW_REQUIRED_RUBY_VERSION"]
raise "HOMEBREW_REQUIRED_RUBY_VERSION was not exported! Please call bin/brew directly!"
end
REQUIRED_RUBY_X, REQUIRED_RUBY_Y, = ENV["HOMEBREW_REQUIRED_RUBY_VERSION"].split(".").map(&:to_i)
REQUIRED_RUBY_X, REQUIRED_RUBY_Y, = ENV.fetch("HOMEBREW_REQUIRED_RUBY_VERSION").split(".").map(&:to_i)
RUBY_X, RUBY_Y, = RUBY_VERSION.split(".").map(&:to_i)
if RUBY_X < REQUIRED_RUBY_X || (RUBY_X == REQUIRED_RUBY_X && RUBY_Y < REQUIRED_RUBY_Y)
raise "Homebrew must be run under Ruby #{REQUIRED_RUBY_X}.#{REQUIRED_RUBY_Y}! " \
"You're running #{RUBY_VERSION}."
end
# Also define here so we can rescue regardless of location.
class MissingEnvironmentVariables < RuntimeError; end
begin
require_relative "global"
rescue MissingEnvironmentVariables => e
raise e if ENV["HOMEBREW_MISSING_ENV_RETRY"]
if ENV["HOMEBREW_DEVELOPER"]
$stderr.puts <<~EOS
Warning: #{e.message}
Retrying with `exec #{ENV["HOMEBREW_BREW_FILE"]}`!
EOS
end
ENV["HOMEBREW_MISSING_ENV_RETRY"] = "1"
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
end
require_relative "global"
begin
trap("INT", std_trap) # restore default CTRL-C handler
@ -74,8 +53,8 @@ begin
args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
Context.current = args.context
path = PATH.new(ENV["PATH"])
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
path = PATH.new(ENV.fetch("PATH"))
homebrew_path = PATH.new(ENV.fetch("HOMEBREW_PATH"))
# Add shared wrappers.
path.prepend(HOMEBREW_SHIMS_PATH/"shared")

View File

@ -734,7 +734,7 @@ then
fi
export HOMEBREW_BREW_GIT_REMOTE
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
export HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
if [[ -z "${HOMEBREW_CORE_GIT_REMOTE}" ]]
then
HOMEBREW_CORE_GIT_REMOTE="${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}"

View File

@ -106,7 +106,7 @@ module Cask
+"/Library/LaunchAgents/#{service}.plist",
+"/Library/LaunchDaemons/#{service}.plist",
]
paths.each { |elt| elt.prepend(ENV["HOME"]).freeze } unless with_sudo
paths.each { |elt| elt.prepend(Dir.home).freeze } unless with_sudo
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
paths.each do |path|
command.run!("/bin/rm", args: ["-f", "--", path], sudo: with_sudo)

View File

@ -39,7 +39,7 @@ module Cask
executable_path,
**args,
env: { "PATH" => PATH.new(
HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]
HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV.fetch("PATH")
) },
)
end

View File

@ -96,7 +96,7 @@ module Cask
end
def printable_target
target.to_s.sub(/^#{ENV['HOME']}(#{File::SEPARATOR}|$)/, "~/")
target.to_s.sub(/^#{Dir.home}(#{File::SEPARATOR}|$)/, "~/")
end
end
end

View File

@ -241,7 +241,7 @@ module Cask
def to_h_string_gsubs(string)
string.to_s
.gsub(ENV["HOME"], "$HOME")
.gsub(Dir.home, "$HOME")
.gsub(HOMEBREW_PREFIX, "$(brew --prefix)")
end

View File

@ -190,7 +190,7 @@ module Cask
key = "language"
value = T.cast(explicit.fetch(:languages, []), T::Array[String]).join(",")
end
"#{key}: \"#{value.to_s.sub(/^#{ENV['HOME']}/, "~")}\""
"#{key}: \"#{value.to_s.sub(/^#{Dir.home}/, "~")}\""
end.join(", ")
end

View File

@ -225,7 +225,7 @@ class URL < Delegator
@raw_interpolated_url =
Pathname(@caller_location.absolute_path)
.each_line.drop(@caller_location.lineno - 1)
.first&.yield_self { |line| line[/url\s+"([^"]+)"/, 1] }
.first&.then { |line| line[/url\s+"([^"]+)"/, 1] }
end
private :raw_interpolated_url

View File

@ -78,7 +78,7 @@ class Caveats
s << " #{Utils::Shell.export_value("CPPFLAGS", "-I#{f.opt_include}")}\n" if f.include.directory?
if which("pkg-config", ENV["HOMEBREW_PATH"]) &&
if which("pkg-config", ORIGINAL_PATHS) &&
((f.lib/"pkgconfig").directory? || (f.share/"pkgconfig").directory?)
s << <<~EOS
@ -109,7 +109,7 @@ class Caveats
def function_completion_caveats(shell)
return unless keg
return unless which(shell.to_s, ENV["HOMEBREW_PATH"])
return unless which(shell.to_s, ORIGINAL_PATHS)
completion_installed = keg.completion_installed?(shell)
functions_installed = keg.functions_installed?(shell)

View File

@ -391,7 +391,7 @@ module Homebrew
end
def cleanup_portable_ruby
rubies = [which("ruby"), which("ruby", ENV["HOMEBREW_PATH"])].compact
rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact
system_ruby = Pathname.new("/usr/bin/ruby")
rubies << system_ruby if system_ruby.exist?

View File

@ -38,7 +38,7 @@ module Homebrew
def cleanup
args = cleanup_args.parse
days = args.prune.presence&.yield_self do |prune|
days = args.prune.presence&.then do |prune|
case prune
when /\A\d+\Z/
prune.to_i

View File

@ -42,7 +42,7 @@ module Homebrew
# As this command is simplifying user-run commands then let's just use a
# user path, too.
ENV["PATH"] = ENV["HOMEBREW_PATH"]
ENV["PATH"] = PATH.new(ORIGINAL_PATHS).to_s
if args.no_named?
git_log HOMEBREW_REPOSITORY, args: args

View File

@ -54,9 +54,9 @@ module Homebrew
ENV["HOMEBREW_LINUXBREW_CORE_MIGRATION"].blank?
ohai "Re-running `brew update` for linuxbrew-core migration"
if ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"] != ENV["HOMEBREW_CORE_GIT_REMOTE"]
if HOMEBREW_CORE_DEFAULT_GIT_REMOTE != Homebrew::EnvConfig.core_git_remote
opoo <<~EOS
HOMEBREW_CORE_GIT_REMOTE was set: #{ENV["HOMEBREW_CORE_GIT_REMOTE"]}.
HOMEBREW_CORE_GIT_REMOTE was set: #{Homebrew::EnvConfig.core_git_remote}.
It has been unset for the migration.
You may need to change this from a linuxbrew-core mirror to a homebrew-core one.
@ -64,9 +64,9 @@ module Homebrew
end
ENV.delete("HOMEBREW_CORE_GIT_REMOTE")
if ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"] != ENV["HOMEBREW_BOTTLE_DOMAIN"]
if HOMEBREW_BOTTLE_DEFAULT_DOMAIN != Homebrew::EnvConfig.bottle_domain
opoo <<~EOS
HOMEBREW_BOTTLE_DOMAIN was set: #{ENV["HOMEBREW_BOTTLE_DOMAIN"]}.
HOMEBREW_BOTTLE_DOMAIN was set: #{Homebrew::EnvConfig.bottle_domain}.
It has been unset for the migration.
You may need to change this from a Linuxbrew package mirror to a Homebrew one.
@ -142,7 +142,7 @@ module Homebrew
end
Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"]
return if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
return if Homebrew::EnvConfig.disable_load_formula?
hub = ReporterHub.new
@ -608,9 +608,7 @@ class ReporterHub
private
def dump_new_formula_report
formulae = select_formula_or_cask(:A).sort.map do |name|
name unless installed?(name)
end.compact
formulae = select_formula_or_cask(:A).sort.reject { |name| installed?(name) }
output_dump_formula_or_cask_report "New Formulae", formulae
end

View File

@ -93,11 +93,11 @@ module Commands
# Ruby commands which are run by being `require`d.
def external_ruby_cmd_path(cmd)
which("brew-#{cmd}.rb", PATH.new(ENV["PATH"]).append(Tap.cmd_directories))
which("brew-#{cmd}.rb", PATH.new(ENV.fetch("PATH")).append(Tap.cmd_directories))
end
def external_cmd_path(cmd)
which("brew-#{cmd}", PATH.new(ENV["PATH"]).append(Tap.cmd_directories))
which("brew-#{cmd}", PATH.new(ENV.fetch("PATH")).append(Tap.cmd_directories))
end
def path(cmd)

View File

@ -37,7 +37,7 @@ class Dependency
alias eql? ==
def hash
name.hash ^ tags.hash
[name, tags].hash
end
def to_formula

View File

@ -121,7 +121,7 @@ module Homebrew
# TODO: 3.6.0: odeprecate not specifying args.all?, require args.installed?
audit_formulae, audit_casks = if args.tap
Tap.fetch(args.tap).yield_self do |tap|
Tap.fetch(args.tap).then do |tap|
[
tap.formula_names.map { |name| Formula[name] },
tap.cask_files.map { |path| Cask::CaskLoader.load(path) },

View File

@ -67,7 +67,7 @@ module Homebrew
# As this command is simplifying user-run commands then let's just use a
# user path, too.
ENV["PATH"] = ENV["HOMEBREW_PATH"]
ENV["PATH"] = PATH.new(ORIGINAL_PATHS).to_s
# Use the user's browser, too.
ENV["BROWSER"] = Homebrew::EnvConfig.browser

View File

@ -108,7 +108,7 @@ module Homebrew
# As this command is simplifying user-run commands then let's just use a
# user path, too.
ENV["PATH"] = ENV["HOMEBREW_PATH"]
ENV["PATH"] = PATH.new(ORIGINAL_PATHS).to_s
# Use the user's browser, too.
ENV["BROWSER"] = Homebrew::EnvConfig.browser

View File

@ -36,7 +36,7 @@ module Homebrew
# As this command is simplifying user-run commands then let's just use a
# user path, too.
ENV["PATH"] = ENV["HOMEBREW_PATH"]
ENV["PATH"] = PATH.new(ORIGINAL_PATHS).to_s
args.named.to_formulae.each do |formula|
current_revision = formula.revision

View File

@ -98,7 +98,7 @@ module Homebrew
return
end
last_check_time = state["check_time"]&.yield_self { |t| Time.parse(t) }
last_check_time = state["check_time"]&.then { |t| Time.parse(t) }
check_time = Time.now
if last_check_time && check_time < (last_check_time + 1.day)
@ -107,7 +107,7 @@ module Homebrew
end
last_sha256 = state["sha256"]
last_time = state["time"]&.yield_self { |t| Time.parse(t) }
last_time = state["time"]&.then { |t| Time.parse(t) }
last_file_size = state["file_size"]
download = Cask::Download.new(cask)

View File

@ -61,9 +61,7 @@ module Homebrew
unless Utils::Curl.curl_supports_tls13?
begin
unless Pathname.new(ENV["HOMEBREW_BREWED_CURL_PATH"]).exist?
ensure_formula_installed!("curl", reason: "Repology queries")
end
ensure_formula_installed!("curl", reason: "Repology queries") unless HOMEBREW_BREWED_CURL_PATH.exist?
rescue FormulaUnavailableError
opoo "A newer `curl` is required for Repology queries."
end

View File

@ -52,7 +52,7 @@ module Homebrew
if (macos = args.macos&.compact_blank) && macos.present?
runners += macos.map do |element|
# We accept runner name syntax (11-arm64) or bottle syntax (arm64_big_sur)
os, arch = element.yield_self do |s|
os, arch = element.then do |s|
tag = Utils::Bottles::Tag.from_symbol(s.to_sym)
[tag.to_macos_version, tag.arch]
rescue ArgumentError, MacOSVersionError

View File

@ -12,7 +12,7 @@ module Homebrew
module_function
WATCHLIST_PATH = (
ENV["HOMEBREW_LIVECHECK_WATCHLIST"] ||
Homebrew::EnvConfig.livecheck_watchlist ||
"#{Dir.home}/.brew_livecheck_watchlist"
).freeze
@ -58,7 +58,7 @@ module Homebrew
if args.debug? && args.verbose?
puts args
puts ENV["HOMEBREW_LIVECHECK_WATCHLIST"] if ENV["HOMEBREW_LIVECHECK_WATCHLIST"].present?
puts Homebrew::EnvConfig.livecheck_watchlist if Homebrew::EnvConfig.livecheck_watchlist.present?
end
formulae_and_casks_to_check = if args.tap

View File

@ -32,7 +32,7 @@ module Homebrew
if args.stackprof?
Homebrew.install_gem_setup_path! "stackprof"
with_env HOMEBREW_STACKPROF: "1" do
system ENV["HOMEBREW_RUBY_PATH"], brew_rb, *args.named
system RUBY_PATH, brew_rb, *args.named
end
output_filename = "prof/d3-flamegraph.html"
safe_system "stackprof --d3-flamegraph prof/stackprof.dump > #{output_filename}"

View File

@ -33,10 +33,9 @@ module Homebrew
ruby_sys_args << "-e #{args.e}" if args.e
ruby_sys_args += args.named
exec RUBY_PATH,
ENV["HOMEBREW_RUBY_WARNINGS"],
exec(*HOMEBREW_RUBY_EXEC_ARGS,
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
"-rglobal", "-rdev-cmd/irb",
*ruby_sys_args
*ruby_sys_args)
end
end

View File

@ -38,22 +38,24 @@ module Homebrew
ENV.setup_build_environment
if superenv?(args.env)
# superenv stopped adding brew's bin but generally users will want it
ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin")
ENV["PATH"] = PATH.new(ENV.fetch("PATH")).insert(1, HOMEBREW_PREFIX/"bin")
end
ENV["VERBOSE"] = "1" if args.verbose?
if args.cmd.present?
safe_system(ENV["SHELL"], "-c", args.cmd)
safe_system(preferred_shell, "-c", args.cmd)
elsif args.named.present?
safe_system(ENV["SHELL"], args.named.first)
safe_system(preferred_shell, args.named.first)
else
subshell = if ENV["SHELL"].include?("zsh")
"PS1='brew %B%F{green}%~%f%b$ ' #{ENV["SHELL"]} -d -f"
elsif ENV["SHELL"].include?("bash")
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]} --noprofile --norc"
shell_type = Utils::Shell.preferred
subshell = case shell_type
when :zsh
"PS1='brew %B%F{green}%~%f%b$ ' #{preferred_shell} -d -f"
when :bash
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{preferred_shell} --noprofile --norc"
else
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]}"
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{preferred_shell}"
end
puts <<~EOS
Your shell has been configured to use Homebrew's build environment;

View File

@ -57,15 +57,15 @@ module Homebrew
reason: "reporting test flakiness")
end
ENV["BUILDPULSE_ACCESS_KEY_ID"] = ENV["HOMEBREW_BUILDPULSE_ACCESS_KEY_ID"]
ENV["BUILDPULSE_SECRET_ACCESS_KEY"] = ENV["HOMEBREW_BUILDPULSE_SECRET_ACCESS_KEY"]
ENV["BUILDPULSE_ACCESS_KEY_ID"] = ENV.fetch("HOMEBREW_BUILDPULSE_ACCESS_KEY_ID")
ENV["BUILDPULSE_SECRET_ACCESS_KEY"] = ENV.fetch("HOMEBREW_BUILDPULSE_SECRET_ACCESS_KEY")
ohai "Sending test results to BuildPulse"
safe_system Formula["buildpulse-test-reporter"].opt_bin/"buildpulse-test-reporter",
"submit", "#{HOMEBREW_LIBRARY_PATH}/test/junit",
"--account-id", ENV["HOMEBREW_BUILDPULSE_ACCOUNT_ID"],
"--repository-id", ENV["HOMEBREW_BUILDPULSE_REPOSITORY_ID"]
"--account-id", ENV.fetch("HOMEBREW_BUILDPULSE_ACCOUNT_ID"),
"--repository-id", ENV.fetch("HOMEBREW_BUILDPULSE_REPOSITORY_ID")
end
def changed_test_files
@ -212,7 +212,7 @@ module Homebrew
ENV["HOMEBREW_TESTS_GEM_USER_DIR"] = gem_user_dir
# Let `bundle` in PATH find its gem.
ENV["GEM_PATH"] = "#{ENV["GEM_PATH"]}:#{gem_user_dir}"
ENV["GEM_PATH"] = "#{ENV.fetch("GEM_PATH")}:#{gem_user_dir}"
# Submit test flakiness information using BuildPulse
# BUILDPULSE used in spec_helper.rb

View File

@ -123,7 +123,7 @@ module Homebrew
safe_system "git", "reset", "--hard", start_commit
# update ENV["PATH"]
ENV["PATH"] = PATH.new(ENV["PATH"]).prepend(curdir/"bin")
ENV["PATH"] = PATH.new(ENV.fetch("PATH")).prepend(curdir/"bin")
# run brew help to install portable-ruby (if needed)
quiet_system "brew", "help"

View File

@ -118,7 +118,7 @@ class DevelopmentTools
sig { returns(T::Hash[String, T.nilable(String)]) }
def build_system_info
{
"os" => ENV["HOMEBREW_SYSTEM"],
"os" => HOMEBREW_SYSTEM,
"os_version" => OS_VERSION,
"cpu_family" => Hardware::CPU.family.to_s,
}

View File

@ -70,7 +70,7 @@ module Homebrew
end
def user_tilde(path)
path.gsub(ENV["HOME"], "~")
path.gsub(Dir.home, "~")
end
sig { returns(String) }
@ -541,7 +541,7 @@ module Homebrew
end
def check_git_version
minimum_version = ENV["HOMEBREW_MINIMUM_GIT_VERSION"]
minimum_version = ENV.fetch("HOMEBREW_MINIMUM_GIT_VERSION")
return unless Utils::Git.available?
return if Version.create(Utils::Git.version) >= Version.create(minimum_version)
@ -668,7 +668,7 @@ module Homebrew
end
def check_tmpdir
tmpdir = ENV["TMPDIR"]
tmpdir = ENV.fetch("TMPDIR", nil)
return if tmpdir.nil? || File.directory?(tmpdir)
<<~EOS
@ -766,7 +766,7 @@ module Homebrew
end
def check_for_pydistutils_cfg_in_home
return unless File.exist? "#{ENV["HOME"]}/.pydistutils.cfg"
return unless File.exist? "#{Dir.home}/.pydistutils.cfg"
<<~EOS
A '.pydistutils.cfg' file was found in $HOME, which may cause Python
@ -828,7 +828,7 @@ module Homebrew
cmd_map.reject! { |_cmd_name, cmd_paths| cmd_paths.size == 1 }
return if cmd_map.empty?
if ENV["CI"] && cmd_map.keys.length == 1 &&
if ENV["CI"].present? && cmd_map.keys.length == 1 &&
cmd_map.keys.first == "brew-test-bot"
return
end
@ -1007,7 +1007,7 @@ module Homebrew
add_info "Cask Environment Variables:", ((locale_variables + environment_variables).sort.each do |var|
next unless ENV.key?(var)
var = %Q(#{var}="#{ENV[var]}")
var = %Q(#{var}="#{ENV.fetch(var)}")
user_tilde(var)
end)
end

View File

@ -1139,7 +1139,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
private
def env
{ "PATH" => PATH.new("/usr/bin", Formula["cvs"].opt_bin, ENV["PATH"]) }
{ "PATH" => PATH.new("/usr/bin", Formula["cvs"].opt_bin, ENV.fetch("PATH")) }
end
sig { returns(String) }
@ -1214,7 +1214,7 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
private
def env
{ "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV["PATH"]) }
{ "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV.fetch("PATH")) }
end
sig { returns(String) }
@ -1280,7 +1280,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
def env
{
"PATH" => PATH.new(Formula["bazaar"].opt_bin, ENV["PATH"]),
"PATH" => PATH.new(Formula["bazaar"].opt_bin, ENV.fetch("PATH")),
"BZR_HOME" => HOMEBREW_TEMP,
}
end
@ -1345,7 +1345,7 @@ class FossilDownloadStrategy < VCSDownloadStrategy
private
def env
{ "PATH" => PATH.new(Formula["fossil"].opt_bin, ENV["PATH"]) }
{ "PATH" => PATH.new(Formula["fossil"].opt_bin, ENV.fetch("PATH")) }
end
sig { returns(String) }

View File

@ -28,7 +28,7 @@ module Stdenv
self["HOMEBREW_ENV"] = "std"
PATH.new(ENV["HOMEBREW_PATH"]).reverse_each { |p| prepend_path "PATH", p }
ORIGINAL_PATHS.reverse_each { |p| prepend_path "PATH", p }
prepend_path "PATH", HOMEBREW_SHIMS_PATH/"shared"
# Set the default pkg-config search path, overriding the built-in paths

View File

@ -421,9 +421,9 @@ class Formula
return unless head.downloader.cached_location.exist?
path = if ENV["HOMEBREW_ENV"]
ENV["PATH"]
ENV.fetch("PATH")
else
ENV["HOMEBREW_PATH"]
PATH.new(ORIGINAL_PATHS)
end
with_env(PATH: path) do
@ -1103,7 +1103,7 @@ class Formula
TMP: HOMEBREW_TEMP,
_JAVA_OPTIONS: "-Djava.io.tmpdir=#{HOMEBREW_TEMP}",
HOMEBREW_PATH: nil,
PATH: ENV["HOMEBREW_PATH"],
PATH: PATH.new(ORIGINAL_PATHS),
}
with_env(new_env) do
@ -2077,7 +2077,7 @@ class Formula
TEMP: HOMEBREW_TEMP,
TMP: HOMEBREW_TEMP,
TERM: "dumb",
PATH: PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"),
PATH: PATH.new(ENV.fetch("PATH"), HOMEBREW_PREFIX/"bin"),
HOMEBREW_PATH: nil,
}.merge(common_stage_test_env)
test_env[:_JAVA_OPTIONS] += " -Djava.io.tmpdir=#{HOMEBREW_TEMP}"
@ -2433,7 +2433,7 @@ class Formula
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
GOPATH: "#{HOMEBREW_CACHE}/go_mod_cache",
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"],
CURL_HOME: ENV.fetch("CURL_HOME") { Dir.home },
}
end

View File

@ -299,7 +299,7 @@ module FormulaCellarChecks
objdump = Formula["llvm"].opt_bin/"llvm-objdump" if Formula["llvm"].any_version_installed?
objdump ||= Formula["binutils"].opt_bin/"objdump" if Formula["binutils"].any_version_installed?
objdump ||= which("objdump")
objdump ||= which("objdump", ENV["HOMEBREW_PATH"])
objdump ||= which("objdump", ORIGINAL_PATHS)
unless objdump
return <<~EOS

View File

@ -823,6 +823,7 @@ class FormulaInstaller
if formula.name == "curl" &&
!DevelopmentTools.curl_handles_most_https_certificates?
ENV["HOMEBREW_CURL"] = formula.opt_bin/"curl"
Utils::Curl.clear_path_cache
end
caveats
@ -903,7 +904,7 @@ class FormulaInstaller
sandbox = Sandbox.new
formula.logs.mkpath
sandbox.record_log(formula.logs/"build.sandbox.log")
sandbox.allow_write_path(ENV["HOME"]) if interactive?
sandbox.allow_write_path(Dir.home) if interactive?
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(formula)
sandbox.allow_cvs
@ -1083,12 +1084,12 @@ class FormulaInstaller
sig { void }
def post_install
args = %W[
nice #{RUBY_PATH}
#{ENV["HOMEBREW_RUBY_WARNINGS"]}
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
args = [
"nice",
*HOMEBREW_RUBY_EXEC_ARGS,
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
"--",
HOMEBREW_LIBRARY_PATH/"postinstall.rb"
]
# Use the formula from the keg if:

View File

@ -34,25 +34,28 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular "it", "they"
end
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"]
HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_BREW_DEFAULT_GIT_REMOTE"]
HOMEBREW_CORE_DEFAULT_GIT_REMOTE = ENV["HOMEBREW_CORE_DEFAULT_GIT_REMOTE"]
HOMEBREW_DEFAULT_CACHE = ENV["HOMEBREW_DEFAULT_CACHE"]
HOMEBREW_DEFAULT_LOGS = ENV["HOMEBREW_DEFAULT_LOGS"]
HOMEBREW_DEFAULT_TEMP = ENV["HOMEBREW_DEFAULT_TEMP"]
HOMEBREW_REQUIRED_RUBY_VERSION = ENV["HOMEBREW_REQUIRED_RUBY_VERSION"]
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_BOTTLE_DEFAULT_DOMAIN").freeze
HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ENV.fetch("HOMEBREW_BREW_DEFAULT_GIT_REMOTE").freeze
HOMEBREW_CORE_DEFAULT_GIT_REMOTE = ENV.fetch("HOMEBREW_CORE_DEFAULT_GIT_REMOTE").freeze
HOMEBREW_DEFAULT_CACHE = ENV.fetch("HOMEBREW_DEFAULT_CACHE").freeze
HOMEBREW_DEFAULT_LOGS = ENV.fetch("HOMEBREW_DEFAULT_LOGS").freeze
HOMEBREW_DEFAULT_TEMP = ENV.fetch("HOMEBREW_DEFAULT_TEMP").freeze
HOMEBREW_REQUIRED_RUBY_VERSION = ENV.fetch("HOMEBREW_REQUIRED_RUBY_VERSION").freeze
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
HOMEBREW_PRODUCT = ENV.fetch("HOMEBREW_PRODUCT").freeze
HOMEBREW_VERSION = ENV.fetch("HOMEBREW_VERSION").freeze
HOMEBREW_WWW = "https://brew.sh"
HOMEBREW_SYSTEM = ENV.fetch("HOMEBREW_SYSTEM").freeze
HOMEBREW_PROCESSOR = ENV.fetch("HOMEBREW_PROCESSOR").freeze
HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"]
HOMEBREW_BREWED_CURL_PATH = Pathname(ENV.fetch("HOMEBREW_BREWED_CURL_PATH")).freeze
HOMEBREW_USER_AGENT_CURL = ENV.fetch("HOMEBREW_USER_AGENT_CURL").freeze
HOMEBREW_USER_AGENT_RUBY =
"#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
"#{ENV.fetch("HOMEBREW_USER_AGENT")} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
HOMEBREW_USER_AGENT_FAKE_SAFARI =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 " \
"(KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
HOMEBREW_GITHUB_PACKAGES_AUTH = ENV["HOMEBREW_GITHUB_PACKAGES_AUTH"]
HOMEBREW_GITHUB_PACKAGES_AUTH = ENV.fetch("HOMEBREW_GITHUB_PACKAGES_AUTH").freeze
HOMEBREW_DEFAULT_PREFIX = "/usr/local"
HOMEBREW_DEFAULT_REPOSITORY = "#{HOMEBREW_DEFAULT_PREFIX}/Homebrew"
@ -116,8 +119,8 @@ require "cli/args"
require "PATH"
ENV["HOMEBREW_PATH"] ||= ENV["PATH"]
ORIGINAL_PATHS = PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
ENV["HOMEBREW_PATH"] ||= ENV.fetch("PATH")
ORIGINAL_PATHS = PATH.new(ENV.fetch("HOMEBREW_PATH")).map do |p|
Pathname.new(p).expand_path
rescue
nil

View File

@ -26,7 +26,7 @@ module Language
end
def self.each_python(build, &block)
original_pythonpath = ENV["PYTHONPATH"]
original_pythonpath = ENV.fetch("PYTHONPATH", nil)
pythons = { "python@3" => "python3",
"pypy" => "pypy",
"pypy3" => "pypy3" }

View File

@ -110,7 +110,7 @@ module Homebrew
version ||= item.elements["version"]&.text&.strip
title = item.elements["title"]&.text&.strip
pub_date = item.elements["pubDate"]&.text&.strip&.presence&.yield_self do |date_string|
pub_date = item.elements["pubDate"]&.text&.strip&.presence&.then do |date_string|
Time.parse(date_string)
rescue ArgumentError
# Omit unparseable strings (e.g. non-English dates)

View File

@ -43,7 +43,7 @@ module OS
@kernel_name ||= Utils.safe_popen_read("uname", "-s").chomp
end
::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]
::OS_VERSION = ENV.fetch("HOMEBREW_OS_VERSION").freeze
CI_GLIBC_VERSION = "2.23"
CI_OS_VERSION = "Ubuntu 16.04"
@ -54,8 +54,8 @@ module OS
if !OS::Mac.version.prerelease? &&
!OS::Mac.version.outdated_release? &&
ARGV.none? { |v| v.start_with?("--cc=") } &&
(ENV["HOMEBREW_PREFIX"] == HOMEBREW_DEFAULT_PREFIX ||
(ENV["HOMEBREW_PREFIX"] == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX && Hardware::CPU.arm?))
(HOMEBREW_PREFIX == HOMEBREW_DEFAULT_PREFIX ||
(HOMEBREW_PREFIX == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX && Hardware::CPU.arm?))
ISSUES_URL = "https://docs.brew.sh/Troubleshooting"
end
PATH_OPEN = "/usr/bin/open"

View File

@ -21,6 +21,9 @@ module OS
raise "Loaded OS::Mac on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]
VERSION = ENV.fetch("HOMEBREW_MACOS_VERSION").chomp.freeze
private_constant :VERSION
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
sig { returns(Version) }
@ -35,7 +38,7 @@ module OS
@full_version ||= if ENV["HOMEBREW_FAKE_EL_CAPITAN"] # for Portable Ruby building
Version.new("10.11.6")
else
Version.new((ENV["HOMEBREW_MACOS_VERSION"]).chomp)
Version.new(VERSION)
end
end

View File

@ -52,6 +52,6 @@ class PkgVersion
alias eql? ==
def hash
version.hash ^ revision.hash
[version, revision].hash
end
end

View File

@ -103,7 +103,7 @@ class Requirement
parent = satisfied_result_parent
return unless parent
return if ["#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/bin"].include?(parent.to_s)
return if PATH.new(ENV["PATH"]).include?(parent.to_s)
return if PATH.new(ENV.fetch("PATH")).include?(parent.to_s)
ENV.prepend_path("PATH", parent)
end
@ -122,7 +122,7 @@ class Requirement
alias eql? ==
def hash
name.hash ^ tags.hash
[name, tags].hash
end
sig { returns(String) }

View File

@ -508,8 +508,8 @@ class BottleSpecification
prefix = Pathname(cellar).parent.to_s
cellar_relocatable = cellar.size >= HOMEBREW_CELLAR.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"]
prefix_relocatable = prefix.size >= HOMEBREW_PREFIX.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"]
cellar_relocatable = cellar.size >= HOMEBREW_CELLAR.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"].present?
prefix_relocatable = prefix.size >= HOMEBREW_PREFIX.to_s.size && ENV["HOMEBREW_RELOCATE_BUILD_PREFIX"].present?
compatible_cellar = cellar == HOMEBREW_CELLAR.to_s || cellar_relocatable
compatible_prefix = prefix == HOMEBREW_PREFIX.to_s || prefix_relocatable

View File

@ -49,6 +49,8 @@ class RuboCop::CLI::Command::AutoGenerateConfig < ::RuboCop::CLI::Command::Base
def line_length_enabled?(config); end
def max_line_length(config); end
def maybe_run_line_length_cop; end
def options_config_in_root?; end
def relative_path_to_todo_from_options_config; end
def reset_config_and_auto_gen_file; end
def run_all_cops(line_length_contents); end
def run_line_length_cop; end
@ -319,6 +321,8 @@ class RuboCop::ConfigLoader
def ignore_parent_exclusion; end
def ignore_parent_exclusion=(_arg0); end
def ignore_parent_exclusion?; end
def ignore_unrecognized_cops; end
def ignore_unrecognized_cops=(_arg0); end
def load_file(file, check: T.unsafe(nil)); end
def load_yaml_configuration(absolute_path); end
def loaded_features; end
@ -564,6 +568,7 @@ class RuboCop::ConfigValidator
def check_obsoletions; end
def check_target_ruby; end
def each_invalid_parameter(cop_name); end
def list_unknown_cops(invalid_cop_names); end
def msg_not_boolean(parent, key, value); end
def reject_conflicting_safe_settings; end
def reject_mutually_exclusive_defaults; end
@ -638,6 +643,16 @@ module RuboCop::Cop::AllowedMethods
def allowed_methods; end
end
module RuboCop::Cop::AllowedPattern
private
def allowed_line?(line); end
def allowed_patterns; end
def ignored_line?(line); end
def matches_allowed_pattern?(line); end
def matches_ignored_pattern?(line); end
end
class RuboCop::Cop::AmbiguousCopName < ::RuboCop::Error
def initialize(name, origin, badges); end
end
@ -1528,6 +1543,49 @@ end
RuboCop::Cop::Gemspec::DateAssignment::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Gemspec::DependencyVersion < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::GemspecHelp
def add_dependency_method_declarations(param0); end
def includes_commit_reference?(param0 = T.unsafe(nil)); end
def includes_version_specification?(param0 = T.unsafe(nil)); end
def on_new_investigation; end
private
def add_dependency_method?(method_name); end
def add_dependency_method_nodes; end
def allowed_gem?(node); end
def allowed_gems; end
def forbidden_offense?(node); end
def forbidden_style?; end
def match_block_variable_name?(receiver_name); end
def message(range); end
def offense?(node); end
def required_offense?(node); end
def required_style?; end
def version_specification?(expression); end
end
RuboCop::Cop::Gemspec::DependencyVersion::FORBIDDEN_MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Gemspec::DependencyVersion::REQUIRED_MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Gemspec::DependencyVersion::VERSION_SPECIFICATION_REGEX = T.let(T.unsafe(nil), Regexp)
class RuboCop::Cop::Gemspec::DeprecatedAttributeAssignment < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
def gem_specification(param0 = T.unsafe(nil)); end
def on_block(block_node); end
private
def use_test_files?(node, block_parameter); end
end
RuboCop::Cop::Gemspec::DeprecatedAttributeAssignment::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Gemspec::DuplicatedAssignment < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
include ::RuboCop::Cop::GemspecHelp
@ -1537,7 +1595,6 @@ class RuboCop::Cop::Gemspec::DuplicatedAssignment < ::RuboCop::Cop::Base
private
def assignment_method?(method_name); end
def duplicated_assignment_method_nodes; end
def match_block_variable_name?(receiver_name); end
def register_offense(node, assignment, line_of_first_occurrence); end
@ -1745,6 +1802,7 @@ module RuboCop::Cop::HashShorthandSyntax
def enforced_shorthand_syntax; end
def ignore_hash_shorthand_syntax?(pair_node); end
def register_offense(node, message, replacement); end
def require_hash_value?(hash_key_source, node); end
def require_hash_value_for_around_hash_literal?(node); end
def use_element_of_hash_literal_as_receiver?(ancestor, parent); end
@ -1884,13 +1942,7 @@ module RuboCop::Cop::IgnoredNode
def ignored_nodes; end
end
module RuboCop::Cop::IgnoredPattern
private
def ignored_line?(line); end
def ignored_patterns; end
def matches_ignored_pattern?(line); end
end
RuboCop::Cop::IgnoredPattern = RuboCop::Cop::AllowedPattern
module RuboCop::Cop::IntegerNode
private
@ -1972,12 +2024,16 @@ class RuboCop::Cop::Layout::ArgumentAlignment < ::RuboCop::Cop::Base
def arguments_or_first_arg_pairs(node); end
def arguments_with_last_arg_pairs(node); end
def autocorrect(corrector, node); end
def autocorrect_incompatible_with_other_cops?; end
def base_column(node, first_argument); end
def enforce_hash_argument_with_separator?; end
def fixed_indentation?; end
def flattened_arguments(node); end
def hash_argument_config; end
def message(_node); end
def multiple_arguments?(node); end
def target_method_lineno(node); end
def with_first_argument_style?; end
end
RuboCop::Cop::Layout::ArgumentAlignment::ALIGN_PARAMS_MSG = T.let(T.unsafe(nil), String)
@ -2090,6 +2146,8 @@ class RuboCop::Cop::Layout::CaseIndentation < ::RuboCop::Cop::Base
def base_column(case_node, base); end
def check_when(when_node, branch_type); end
def detect_incorrect_style(when_node); end
def end_and_last_conditional_same_line?(node); end
def enforced_style_end?; end
def incorrect_style(when_node, branch_type); end
def indent_one_step?; end
def indentation_width; end
@ -2878,6 +2936,7 @@ class RuboCop::Cop::Layout::HashAlignment < ::RuboCop::Cop::Base
end
RuboCop::Cop::Layout::HashAlignment::MESSAGES = T.let(T.unsafe(nil), Hash)
RuboCop::Cop::Layout::HashAlignment::SEPARATOR_ALIGNMENT_STYLES = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::Layout::HeredocArgumentClosingParenthesis < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
@ -2997,7 +3056,7 @@ class RuboCop::Cop::Layout::IndentationWidth < ::RuboCop::Cop::Base
include ::RuboCop::Cop::EndKeywordAlignment
include ::RuboCop::Cop::Alignment
include ::RuboCop::Cop::CheckAssignment
include ::RuboCop::Cop::IgnoredPattern
include ::RuboCop::Cop::AllowedPattern
extend ::RuboCop::Cop::AutoCorrector
def access_modifier?(param0 = T.unsafe(nil)); end
@ -3118,7 +3177,7 @@ RuboCop::Cop::Layout::LineEndStringConcatenationIndentation::PARENT_TYPES_FOR_IN
class RuboCop::Cop::Layout::LineLength < ::RuboCop::Cop::Base
include ::RuboCop::Cop::CheckLineBreakable
include ::RuboCop::Cop::IgnoredPattern
include ::RuboCop::Cop::AllowedPattern
include ::RuboCop::Cop::RangeHelp
include ::RuboCop::Cop::LineLengthHelp
extend ::RuboCop::Cop::AutoCorrector
@ -3136,6 +3195,7 @@ class RuboCop::Cop::Layout::LineLength < ::RuboCop::Cop::Base
def allow_heredoc?; end
def allowed_heredoc; end
def allowed_line?(line, line_index); end
def breakable_block_range(block_node); end
def breakable_range; end
def breakable_range=(_arg0); end
@ -3151,7 +3211,6 @@ class RuboCop::Cop::Layout::LineLength < ::RuboCop::Cop::Base
def extract_heredocs(ast); end
def heredocs; end
def highlight_start(line); end
def ignored_line?(line, line_index); end
def line_in_heredoc?(line_number); end
def line_in_permitted_heredoc?(line_number); end
def max; end
@ -3295,6 +3354,8 @@ class RuboCop::Cop::Layout::MultilineMethodCallIndentation < ::RuboCop::Cop::Bas
def autocorrect(corrector, node); end
def base_source; end
def extra_indentation(given_style, parent); end
def first_call_has_a_dot(node); end
def get_dot_right_above(node); end
def message(node, lhs, rhs); end
def no_base_message(lhs, rhs, node); end
def offending_range(node, lhs, rhs, given_style); end
@ -3704,6 +3765,7 @@ class RuboCop::Cop::Layout::SpaceBeforeBrackets < ::RuboCop::Cop::Base
private
def dot_before_brackets?(node, receiver_end_pos, selector_begin_pos); end
def offense_range(node, begin_pos); end
def offense_range_for_assignment(node, begin_pos); end
def reference_variable_with_brackets?(node); end
@ -4046,6 +4108,7 @@ class RuboCop::Cop::LineBreakCorrector
def remove_semicolon(node, corrector); end
def semicolon(node); end
def trailing_class_definition?(token, body); end
end
end
@ -4465,6 +4528,9 @@ end
RuboCop::Cop::Lint::DuplicateRegexpCharacterClassElement::MSG_REPEATED_ELEMENT = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Lint::DuplicateRequire < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
def on_new_investigation; end
def on_send(node); end
def require_call?(param0 = T.unsafe(nil)); end
@ -4609,8 +4675,8 @@ RuboCop::Cop::Lint::EnsureReturn::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Lint::ErbNewArguments < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::TargetRubyVersion
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def erb_new_with_non_keyword_arguments(param0 = T.unsafe(nil)); end
def on_send(node); end
@ -5286,6 +5352,7 @@ RuboCop::Cop::Lint::RedundantDirGlobSort::RESTRICT_ON_SEND = T.let(T.unsafe(nil)
class RuboCop::Cop::Lint::RedundantRequireStatement < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def on_send(node); end
def unnecessary_require_statement?(param0 = T.unsafe(nil)); end
@ -5458,10 +5525,7 @@ class RuboCop::Cop::Lint::ReturnInVoidContext < ::RuboCop::Cop::Base
private
def method_name(context_node); end
def non_void_context(return_node); end
def setter_method?(method_name); end
def void_context_method?(method_name); end
end
RuboCop::Cop::Lint::ReturnInVoidContext::MSG = T.let(T.unsafe(nil), String)
@ -5469,6 +5533,7 @@ RuboCop::Cop::Lint::ReturnInVoidContext::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Lint::SafeNavigationChain < ::RuboCop::Cop::Base
include ::RuboCop::Cop::AllowedMethods
include ::RuboCop::Cop::NilMethods
extend ::RuboCop::Cop::TargetRubyVersion
def bad_method?(param0 = T.unsafe(nil)); end
def on_send(node); end
@ -5805,7 +5870,7 @@ end
RuboCop::Cop::Lint::UnreachableCode::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Lint::UnreachableLoop < ::RuboCop::Cop::Base
include ::RuboCop::Cop::IgnoredPattern
include ::RuboCop::Cop::AllowedPattern
def break_command?(param0 = T.unsafe(nil)); end
def on_block(node); end
@ -5956,12 +6021,6 @@ end
RuboCop::Cop::Lint::UselessAssignment::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Lint::UselessElseWithoutRescue < ::RuboCop::Cop::Base
def on_new_investigation; end
end
RuboCop::Cop::Lint::UselessElseWithoutRescue::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Lint::UselessMethodDefinition < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
@ -6311,6 +6370,7 @@ class RuboCop::Cop::Metrics::Utils::CodeLengthCalculator
private
def another_args?(node); end
def build_foldable_checks(types); end
def classlike_code_length(node); end
def classlike_node?(node); end
@ -6325,6 +6385,8 @@ class RuboCop::Cop::Metrics::Utils::CodeLengthCalculator
def line_numbers_of_inner_nodes(node, *types); end
def namespace_module?(node); end
def normalize_foldable_types(types); end
def omit_length(descendant); end
def parenthesized?(node); end
end
RuboCop::Cop::Metrics::Utils::CodeLengthCalculator::CLASSLIKE_TYPES = T.let(T.unsafe(nil), Array)
@ -6734,7 +6796,7 @@ class RuboCop::Cop::Naming::MethodName < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::ConfigurableFormatting
include ::RuboCop::Cop::ConfigurableNaming
include ::RuboCop::Cop::IgnoredPattern
include ::RuboCop::Cop::AllowedPattern
include ::RuboCop::Cop::RangeHelp
def on_def(node); end
@ -6801,6 +6863,7 @@ class RuboCop::Cop::Naming::VariableName < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::ConfigurableFormatting
include ::RuboCop::Cop::ConfigurableNaming
include ::RuboCop::Cop::AllowedPattern
def on_arg(node); end
def on_blockarg(node); end
@ -6813,6 +6876,7 @@ class RuboCop::Cop::Naming::VariableName < ::RuboCop::Cop::Base
def on_lvasgn(node); end
def on_optarg(node); end
def on_restarg(node); end
def valid_name?(node, name, given_style = T.unsafe(nil)); end
private
@ -6826,14 +6890,17 @@ class RuboCop::Cop::Naming::VariableNumber < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::ConfigurableFormatting
include ::RuboCop::Cop::ConfigurableNumbering
include ::RuboCop::Cop::AllowedPattern
def on_arg(node); end
def on_cvasgn(node); end
def on_def(node); end
def on_defs(node); end
def on_gvasgn(node); end
def on_ivasgn(node); end
def on_lvasgn(node); end
def on_sym(node); end
def valid_name?(node, name, given_style = T.unsafe(nil)); end
private
@ -7196,6 +7263,23 @@ end
module RuboCop::Cop::Security; end
class RuboCop::Cop::Security::CompoundHash < ::RuboCop::Cop::Base
def bad_hash_combinator?(param0 = T.unsafe(nil)); end
def contained_in_hash_method?(node, &block); end
def dynamic_hash_method_definition?(param0 = T.unsafe(nil)); end
def hash_method_definition?(param0 = T.unsafe(nil)); end
def monuple_hash?(param0 = T.unsafe(nil)); end
def on_op_asgn(node); end
def on_send(node); end
def outer_bad_hash_combinator?(node); end
def redundant_hash?(param0 = T.unsafe(nil)); end
def static_hash_method_definition?(param0 = T.unsafe(nil)); end
end
RuboCop::Cop::Security::CompoundHash::COMBINATOR_IN_HASH_MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Security::CompoundHash::MONUPLE_HASH_MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Security::CompoundHash::REDUNDANT_HASH_MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Security::Eval < ::RuboCop::Cop::Base
def eval?(param0 = T.unsafe(nil)); end
def on_send(node); end
@ -7691,6 +7775,7 @@ class RuboCop::Cop::Style::BlockDelimiters < ::RuboCop::Cop::Base
def special_method_proper_block_style?(node); end
def whitespace_after?(range, length = T.unsafe(nil)); end
def whitespace_before?(range); end
def with_block?(node); end
end
RuboCop::Cop::Style::BlockDelimiters::ALWAYS_BRACES_MESSAGE = T.let(T.unsafe(nil), String)
@ -7891,7 +7976,7 @@ class RuboCop::Cop::Style::CollectionCompact < ::RuboCop::Cop::Base
private
def good_method_name(method_name); end
def good_method_name(node); end
def offense_range(node); end
def range(begin_pos_node, end_pos_node); end
end
@ -8172,6 +8257,7 @@ RuboCop::Cop::Style::DefWithParentheses::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::Dir < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def dir_replacement?(param0 = T.unsafe(nil)); end
def on_send(node); end
@ -8283,6 +8369,7 @@ class RuboCop::Cop::Style::DoubleNegation < ::RuboCop::Cop::Base
private
def allowed_in_returns?(node); end
def define_mehod?(node); end
def double_negative_condition_return_value?(node, last_child, conditional_node); end
def end_of_method_definition?(node); end
def find_conditional_node_from_ascendant(node); end
@ -8491,6 +8578,16 @@ RuboCop::Cop::Style::EndlessMethod::CORRECTION_STYLES = T.let(T.unsafe(nil), Arr
RuboCop::Cop::Style::EndlessMethod::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::EndlessMethod::MSG_MULTI_LINE = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::EnvHome < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
def env_home?(param0 = T.unsafe(nil)); end
def on_send(node); end
end
RuboCop::Cop::Style::EnvHome::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::EnvHome::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::Style::EvalWithLocation < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
@ -8606,6 +8703,51 @@ end
RuboCop::Cop::Style::ExponentialNotation::MESSAGES = T.let(T.unsafe(nil), Hash)
class RuboCop::Cop::Style::FetchEnvVar < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
def block_control?(param0 = T.unsafe(nil)); end
def env_with_bracket?(param0 = T.unsafe(nil)); end
def offensive_nodes(param0); end
def on_send(node); end
def operand_of_or?(param0 = T.unsafe(nil)); end
private
def allowable_use?(node); end
def allowed_var?(node); end
def assigned?(node); end
def configured_indentation; end
def conterpart_rhs_of(node); end
def default_nil(node, name_node); end
def default_rhs(node, name_node); end
def default_rhs_in_outer_or(node, name_node); end
def default_rhs_in_same_or(node, name_node); end
def default_to_rhs?(node); end
def first_line_of(source); end
def left_end_of_or_chains?(node); end
def message_chained_with_dot?(node); end
def message_template_for(rhs); end
def new_code_default_nil(name_node); end
def new_code_default_rhs(node, name_node); end
def new_code_default_rhs_multiline(node, name_node); end
def new_code_default_rhs_single_line(node, name_node); end
def offensive?(node); end
def or_chain_root(node); end
def partial_matched?(node, condition); end
def rhs_can_be_default_value?(node); end
def rhs_is_block_control?(node); end
def right_end_of_or_chains?(node); end
def used_as_flag?(node); end
def used_if_condition_in_body(node); end
def used_in_condition?(node, condition); end
end
RuboCop::Cop::Style::FetchEnvVar::MSG_DEFAULT_NIL = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::FetchEnvVar::MSG_DEFAULT_RHS_MULTILINE_BLOCK = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::FetchEnvVar::MSG_DEFAULT_RHS_SECOND_ARG_OF_FETCH = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::FetchEnvVar::MSG_DEFAULT_RHS_SINGLE_LINE_BLOCK = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::FileRead < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
@ -8739,6 +8881,7 @@ class RuboCop::Cop::Style::FrozenStringLiteralComment < ::RuboCop::Cop::Base
include ::RuboCop::Cop::FrozenStringLiteral
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def on_new_investigation; end
@ -8806,7 +8949,9 @@ class RuboCop::Cop::Style::GuardClause < ::RuboCop::Cop::Base
def accepted_form?(node, ending: T.unsafe(nil)); end
def accepted_if?(node, ending); end
def allowed_consecutive_conditionals?; end
def check_ending_if(node); end
def consecutive_conditionals?(parent, node); end
def guard_clause_source(guard_clause); end
def opposite_keyword(node); end
def register_offense(node, scope_exiting_keyword, conditional_keyword); end
@ -8945,6 +9090,7 @@ RuboCop::Cop::Style::HashSyntax::MSG_NO_MIXED_KEYS = T.let(T.unsafe(nil), String
class RuboCop::Cop::Style::HashTransformKeys < ::RuboCop::Cop::Base
include ::RuboCop::Cop::HashTransformMethod
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def on_bad_each_with_object(param0 = T.unsafe(nil)); end
def on_bad_hash_brackets_map(param0 = T.unsafe(nil)); end
@ -8960,6 +9106,7 @@ end
class RuboCop::Cop::Style::HashTransformValues < ::RuboCop::Cop::Base
include ::RuboCop::Cop::HashTransformMethod
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def on_bad_each_with_object(param0 = T.unsafe(nil)); end
def on_bad_hash_brackets_map(param0 = T.unsafe(nil)); end
@ -9031,7 +9178,7 @@ RuboCop::Cop::Style::IfInsideElse::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::IfUnlessModifier < ::RuboCop::Cop::Base
include ::RuboCop::Cop::LineLengthHelp
include ::RuboCop::Cop::StatementModifier
include ::RuboCop::Cop::IgnoredPattern
include ::RuboCop::Cop::AllowedPattern
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
@ -9039,10 +9186,10 @@ class RuboCop::Cop::Style::IfUnlessModifier < ::RuboCop::Cop::Base
private
def allowed_patterns; end
def another_statement_on_same_line?(node); end
def autocorrect(corrector, node); end
def extract_heredoc_from(last_argument); end
def ignored_patterns; end
def line_length_enabled_at_line?(line); end
def named_capture_in_condition?(node); end
def non_eligible_node?(node); end
@ -9306,6 +9453,23 @@ RuboCop::Cop::Style::LineEndConcatenation::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::LineEndConcatenation::QUOTE_DELIMITERS = T.let(T.unsafe(nil), Array)
RuboCop::Cop::Style::LineEndConcatenation::SIMPLE_STRING_TOKEN_TYPE = T.let(T.unsafe(nil), Symbol)
class RuboCop::Cop::Style::MapCompactWithConditionalBlock < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
def map_and_compact?(param0 = T.unsafe(nil)); end
def on_send(node); end
private
def range(node); end
def returns_block_argument?(block_argument_node, return_value_node); end
def truthy_branch?(node); end
def truthy_branch_for_guard?(node); end
def truthy_branch_for_if?(node); end
end
RuboCop::Cop::Style::MapCompactWithConditionalBlock::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::MapToHash < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
@ -9325,7 +9489,7 @@ RuboCop::Cop::Style::MapToHash::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::Style::MethodCallWithArgsParentheses < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::IgnoredMethods
include ::RuboCop::Cop::IgnoredPattern
include ::RuboCop::Cop::AllowedPattern
include ::RuboCop::Cop::Style::MethodCallWithArgsParentheses::RequireParentheses
include ::RuboCop::Cop::Style::MethodCallWithArgsParentheses::OmitParentheses
extend ::RuboCop::Cop::IgnoredMethods::Config
@ -9657,10 +9821,15 @@ class RuboCop::Cop::Style::MultilineTernaryOperator < ::RuboCop::Cop::Base
private
def enforce_single_line_ternary_operator?(node); end
def offense?(node); end
def replacement(node); end
def use_assignment_method?(node); end
end
RuboCop::Cop::Style::MultilineTernaryOperator::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::MultilineTernaryOperator::MSG_IF = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::MultilineTernaryOperator::MSG_SINGLE_LINE = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::MultilineTernaryOperator::SINGLE_LINE_TYPES = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::Style::MultilineWhenThen < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
@ -10093,6 +10262,7 @@ class RuboCop::Cop::Style::NumericPredicate < ::RuboCop::Cop::Base
def invert; end
def parenthesized_source(node); end
def replacement(numeric, operation); end
def replacement_supported?(operator); end
def require_parentheses?(node); end
end
@ -10100,6 +10270,22 @@ RuboCop::Cop::Style::NumericPredicate::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::NumericPredicate::REPLACEMENTS = T.let(T.unsafe(nil), Hash)
RuboCop::Cop::Style::NumericPredicate::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::Style::ObjectThen < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
extend ::RuboCop::Cop::AutoCorrector
def on_block(node); end
def on_send(node); end
private
def check_method_node(node); end
def message(node); end
def preferred_method(node); end
end
RuboCop::Cop::Style::ObjectThen::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::OneLineConditional < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::OnNormalIfUnless
@ -10485,6 +10671,7 @@ class RuboCop::Cop::Style::RedundantBegin < ::RuboCop::Cop::Base
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
def offensive_kwbegins(param0); end
def on_block(node); end
def on_def(node); end
def on_defs(node); end
@ -10492,6 +10679,7 @@ class RuboCop::Cop::Style::RedundantBegin < ::RuboCop::Cop::Base
private
def allowable_kwbegin?(node); end
def begin_block_has_multiline_statements?(node); end
def condition_range(node); end
def contain_rescue_or_ensure?(node); end
@ -10530,13 +10718,24 @@ class RuboCop::Cop::Style::RedundantCondition < ::RuboCop::Cop::Base
private
def asgn_type?(node); end
def branches_have_assignment?(node); end
def branches_have_method?(node); end
def correct_ternary(corrector, node); end
def else_source(else_branch); end
def else_source_if_has_assignment(else_branch); end
def else_source_if_has_method(else_branch); end
def if_source(if_branch); end
def make_ternary_form(node); end
def message(node); end
def offense?(node); end
def range_of_offense(node); end
def redundant_condition?(node); end
def require_braces?(node); end
def require_parentheses?(node); end
def same_method?(if_branch, else_branch); end
def synonymous_condition_and_branch?(node); end
def use_hash_key_access?(node); end
def use_hash_key_assignment?(else_branch); end
def use_if_branch?(else_branch); end
def without_argument_parentheses_method?(node); end
@ -10635,12 +10834,19 @@ RuboCop::Cop::Style::RedundantFreeze::MSG = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::RedundantFreeze::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
class RuboCop::Cop::Style::RedundantInitialize < ::RuboCop::Cop::Base
include ::RuboCop::Cop::CommentsHelp
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
def initialize_forwards?(param0 = T.unsafe(nil)); end
def on_def(node); end
private
def acceptable?(node); end
def allow_comments?(node); end
def forwards?(node); end
def register_offense(node, message); end
def same_args?(super_node, args); end
end
@ -10757,6 +10963,7 @@ class RuboCop::Cop::Style::RedundantRegexpCharacterClass < ::RuboCop::Cop::Base
def backslash_b?(elem); end
def each_redundant_character_class(node); end
def each_single_element_character_class(node); end
def multiple_codepoins?(expression); end
def redundant_single_element_character_class?(node, char_class); end
def requires_escape_outside_char_class?(elem); end
def whitespace_in_free_space_mode?(node, elem); end
@ -10999,7 +11206,7 @@ class RuboCop::Cop::Style::RescueStandardError < ::RuboCop::Cop::Base
private
def offense_for_exlicit_enforced_style(node); end
def offense_for_explicit_enforced_style(node); end
def offense_for_implicit_enforced_style(node, error); end
end
@ -11031,6 +11238,7 @@ class RuboCop::Cop::Style::SafeNavigation < ::RuboCop::Cop::Base
include ::RuboCop::Cop::NilMethods
include ::RuboCop::Cop::RangeHelp
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def check_node(node); end
def modifier_if_safe_navigation_candidate(param0 = T.unsafe(nil)); end
@ -11276,14 +11484,16 @@ class RuboCop::Cop::Style::SoleNestedConditional < ::RuboCop::Cop::Base
def autocorrect_outer_condition_modify_form(corrector, node, if_branch); end
def correct_for_basic_condition_style(corrector, node, if_branch, and_operator); end
def correct_for_comment(corrector, node, if_branch); end
def correct_for_guard_condition_style(corrector, node, if_branch, and_operator); end
def correct_for_guard_condition_style(corrector, outer_condition, if_branch, and_operator); end
def correct_for_outer_condition_modify_form_style(corrector, node, if_branch); end
def correct_from_unless_to_if(corrector, node, is_modify_form: T.unsafe(nil)); end
def correct_outer_condition(corrector, condition); end
def insert_bang(corrector, node, is_modify_form); end
def insert_bang_for_and(corrector, node); end
def offending_branch?(node, branch); end
def outer_condition_modify_form?(node, if_branch); end
def replace_condition(condition); end
def requrie_parentheses?(condition); end
def require_parentheses?(condition); end
def use_variable_assignment_in_condition?(condition, if_branch); end
def wrap_condition?(node); end
@ -11303,6 +11513,7 @@ class RuboCop::Cop::Style::SpecialGlobalVars < ::RuboCop::Cop::Base
def autocorrect(corrector, node, global_var); end
def message(global_var); end
def on_gvar(node); end
def on_new_investigation; end
private
@ -11311,11 +11522,13 @@ class RuboCop::Cop::Style::SpecialGlobalVars < ::RuboCop::Cop::Base
def format_english_message(global_var); end
def format_list(items); end
def format_message(english, regular, global); end
def matching_styles(global); end
def preferred_names(global); end
def replacement(node, global_var); end
def should_require_english?(global_var); end
end
RuboCop::Cop::Style::SpecialGlobalVars::BUILTIN_VARS = T.let(T.unsafe(nil), Hash)
RuboCop::Cop::Style::SpecialGlobalVars::ENGLISH_VARS = T.let(T.unsafe(nil), Hash)
RuboCop::Cop::Style::SpecialGlobalVars::LIBRARY_NAME = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::SpecialGlobalVars::MSG_BOTH = T.let(T.unsafe(nil), String)
@ -11323,6 +11536,7 @@ RuboCop::Cop::Style::SpecialGlobalVars::MSG_ENGLISH = T.let(T.unsafe(nil), Strin
RuboCop::Cop::Style::SpecialGlobalVars::MSG_REGULAR = T.let(T.unsafe(nil), String)
RuboCop::Cop::Style::SpecialGlobalVars::NON_ENGLISH_VARS = T.let(T.unsafe(nil), Set)
RuboCop::Cop::Style::SpecialGlobalVars::PERL_VARS = T.let(T.unsafe(nil), Hash)
RuboCop::Cop::Style::SpecialGlobalVars::STYLE_VARS_MAP = T.let(T.unsafe(nil), Hash)
class RuboCop::Cop::Style::StabbyLambdaParentheses < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
@ -11403,7 +11617,7 @@ class RuboCop::Cop::Style::StringConcatenation < ::RuboCop::Cop::Base
def handle_quotes(parts); end
def heredoc?(node); end
def line_end_concatenation?(node); end
def offensive_for_mode?(receiver_node); end
def mode; end
def plus_node?(node); end
def register_offense(topmost_plus_node, parts); end
def replacement(parts); end
@ -11531,6 +11745,7 @@ class RuboCop::Cop::Style::SymbolArray < ::RuboCop::Cop::Base
include ::RuboCop::Cop::ConfigurableEnforcedStyle
include ::RuboCop::Cop::PercentArray
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def on_array(node); end
@ -11559,6 +11774,7 @@ end
RuboCop::Cop::Style::SymbolLiteral::MSG = T.let(T.unsafe(nil), String)
class RuboCop::Cop::Style::SymbolProc < ::RuboCop::Cop::Base
include ::RuboCop::Cop::CommentsHelp
include ::RuboCop::Cop::RangeHelp
include ::RuboCop::Cop::IgnoredMethods
extend ::RuboCop::Cop::IgnoredMethods::Config
@ -11573,7 +11789,8 @@ class RuboCop::Cop::Style::SymbolProc < ::RuboCop::Cop::Base
private
def allow_if_method_has_argument?(node); end
def allow_comments?; end
def allow_if_method_has_argument?(send_node); end
def autocorrect(corrector, node); end
def autocorrect_with_args(corrector, node, args, method_name); end
def autocorrect_without_args(corrector, node); end
@ -11791,11 +12008,11 @@ class RuboCop::Cop::Style::TrivialAccessors < ::RuboCop::Cop::Base
def allowed_method_name?(node); end
def allowed_method_names; end
def allowed_reader?(node); end
def allowed_writer?(method_name); end
def allowed_writer?(node); end
def autocorrect(corrector, node); end
def autocorrect_class(corrector, node); end
def autocorrect_instance(corrector, node); end
def dsl_writer?(method_name); end
def dsl_writer?(node); end
def exact_name_match?; end
def ignore_class_methods?; end
def in_module_or_instance_eval?(node); end
@ -11841,6 +12058,7 @@ RuboCop::Cop::Style::UnlessLogicalOperators::FORBID_MIXED_LOGICAL_OPERATORS = T.
class RuboCop::Cop::Style::UnpackFirst < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
extend ::RuboCop::Cop::TargetRubyVersion
def on_send(node); end
def unpack_and_first_element?(param0 = T.unsafe(nil)); end
@ -12763,10 +12981,11 @@ class RuboCop::Formatter::DisabledConfigFormatter < ::RuboCop::Formatter::BaseFo
def output_exclude_path(output_buffer, exclude_path, parent); end
def output_offending_files(output_buffer, cfg, cop_name); end
def output_offenses; end
def safe_autocorrect?(config); end
def set_max(cfg, cop_name); end
def show_offense_counts?; end
def show_timestamp?; end
def supports_safe_auto_correct?(cop_class, default_cfg); end
def supports_safe_autocorrect?(cop_class, default_cfg); end
def supports_unsafe_autocorrect?(cop_class, default_cfg); end
def timestamp; end
@ -12955,6 +13174,28 @@ class RuboCop::Formatter::JUnitFormatter < ::RuboCop::Formatter::BaseFormatter
def reset_count; end
end
class RuboCop::Formatter::MarkdownFormatter < ::RuboCop::Formatter::BaseFormatter
include ::RuboCop::Formatter::TextUtil
include ::RuboCop::PathUtil
def initialize(output, options = T.unsafe(nil)); end
def file_finished(file, offenses); end
def files; end
def finished(inspected_files); end
def started(target_files); end
def summary; end
private
def possible_ellipses(location); end
def render_markdown; end
def write_code(offense); end
def write_context(offense); end
def write_file_messages; end
def write_heading(file); end
end
class RuboCop::Formatter::OffenseCountFormatter < ::RuboCop::Formatter::BaseFormatter
def file_finished(_file, offenses); end
def finished(_inspected_files); end
@ -12984,8 +13225,8 @@ end
RuboCop::Formatter::PacmanFormatter::FALLBACK_TERMINAL_WIDTH = T.let(T.unsafe(nil), Integer)
RuboCop::Formatter::PacmanFormatter::GHOST = T.let(T.unsafe(nil), String)
RuboCop::Formatter::PacmanFormatter::PACDOT = T.let(T.unsafe(nil), Rainbow::Presenter)
RuboCop::Formatter::PacmanFormatter::PACMAN = T.let(T.unsafe(nil), Rainbow::Presenter)
RuboCop::Formatter::PacmanFormatter::PACDOT = T.let(T.unsafe(nil), Rainbow::NullPresenter)
RuboCop::Formatter::PacmanFormatter::PACMAN = T.let(T.unsafe(nil), Rainbow::NullPresenter)
class RuboCop::Formatter::ProgressFormatter < ::RuboCop::Formatter::ClangStyleFormatter
include ::RuboCop::Formatter::TextUtil
@ -13096,6 +13337,8 @@ class RuboCop::MagicComment
def frozen_string_literal_specified?; end
def shareable_constant_value; end
def shareable_constant_value_specified?; end
def typed; end
def typed_specified?; end
def valid?; end
def valid_literal_value?; end
def valid_shareable_constant_value?; end
@ -13125,6 +13368,7 @@ class RuboCop::MagicComment::EmacsComment < ::RuboCop::MagicComment::EditorComme
def extract_frozen_string_literal; end
def extract_shareable_constant_value; end
def extract_typed; end
end
RuboCop::MagicComment::EmacsComment::FORMAT = T.let(T.unsafe(nil), String)
@ -13141,12 +13385,14 @@ class RuboCop::MagicComment::SimpleComment < ::RuboCop::MagicComment
def extract_frozen_string_literal; end
def extract_shareable_constant_value; end
def extract_typed; end
end
RuboCop::MagicComment::TOKEN = T.let(T.unsafe(nil), Regexp)
class RuboCop::MagicComment::VimComment < ::RuboCop::MagicComment::EditorComment
def encoding; end
def extract_typed; end
def frozen_string_literal; end
def shareable_constant_value; end
end
@ -13191,6 +13437,7 @@ class RuboCop::Options
def args_from_env; end
def args_from_file; end
def define_options; end
def handle_deprecated_option(old_option, new_option); end
def long_opt_symbol(args); end
def option(opts, *args); end
def rainbow; end
@ -13214,13 +13461,16 @@ class RuboCop::OptionsValidator
def display_only_fail_level_offenses_with_autocorrect?; end
def except_syntax?; end
def incompatible_options; end
def invalid_arguments_for_parallel; end
def only_includes_redundant_disable?; end
def validate_auto_correct; end
def validate_auto_gen_config; end
def validate_autocorrect; end
def validate_cache_enabled_for_cache_root; end
def validate_compatibility; end
def validate_cop_options; end
def validate_display_only_correctable_and_autocorrect; end
def validate_display_only_failed; end
def validate_display_only_failed_and_display_only_correctable; end
def validate_exclude_limit_option; end
class << self
@ -13343,6 +13593,7 @@ class RuboCop::Runner
def check_for_infinite_loop(processed_source, offenses_by_iteration); end
def check_for_redundant_disables?(source); end
def considered_failure?(offense); end
def default_config(cop_name); end
def do_inspection_loop(file); end
def each_inspected_file(files); end
def file_finished(file, offenses); end
@ -13358,15 +13609,18 @@ class RuboCop::Runner
def inspect_files(files); end
def iterate_until_no_changes(source, offenses_by_iteration); end
def list_files(paths); end
def mark_as_safe_by_config?(config); end
def minimum_severity_to_fail; end
def mobilize_team(processed_source); end
def mobilized_cop_classes(config); end
def offenses_to_report(offenses); end
def process_file(file); end
def qualify_option_cop_names; end
def redundant_cop_disable_directive(file); end
def save_in_cache(cache, offenses); end
def standby_team(config); end
def style_guide_cops_only?(config); end
def supports_safe_autocorrect?(offense); end
def team_for_redundant_disables(file, offenses, source); end
def warm_cache(target_files); end
end
@ -13469,7 +13723,7 @@ class RuboCop::TargetRuby::GemspecFile < ::RuboCop::TargetRuby::Source
private
def find_minimal_known_ruby(right_hand_side); end
def find_default_minimal_known_ruby(right_hand_side); end
def find_version; end
def gemspec_filename; end
def gemspec_filepath; end

View File

@ -3538,6 +3538,7 @@ class Object
FORMULA_COMPONENT_PRECEDENCE_LIST = ::T.let(nil, ::T.untyped)
HOMEBREW_BOTTLES_EXTNAME_REGEX = ::T.let(nil, ::T.untyped)
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ::T.let(nil, ::T.untyped)
HOMEBREW_BREWED_CURL_PATH = ::T.let(nil, ::T.untyped)
HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ::T.let(nil, ::T.untyped)
HOMEBREW_BREW_FILE = ::T.let(nil, ::T.untyped)
HOMEBREW_CACHE = ::T.let(nil, ::T.untyped)
@ -3564,6 +3565,7 @@ class Object
HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = ::T.let(nil, ::T.untyped)
HOMEBREW_PINNED_KEGS = ::T.let(nil, ::T.untyped)
HOMEBREW_PREFIX = ::T.let(nil, ::T.untyped)
HOMEBREW_PROCESSOR = ::T.let(nil, ::T.untyped)
HOMEBREW_PRODUCT = ::T.let(nil, ::T.untyped)
HOMEBREW_PULL_API_REGEX = ::T.let(nil, ::T.untyped)
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = ::T.let(nil, ::T.untyped)
@ -3571,6 +3573,7 @@ class Object
HOMEBREW_REQUIRED_RUBY_VERSION = ::T.let(nil, ::T.untyped)
HOMEBREW_RUBY_EXEC_ARGS = ::T.let(nil, ::T.untyped)
HOMEBREW_SHIMS_PATH = ::T.let(nil, ::T.untyped)
HOMEBREW_SYSTEM = ::T.let(nil, ::T.untyped)
HOMEBREW_TAP_CASK_REGEX = ::T.let(nil, ::T.untyped)
HOMEBREW_TAP_DIR_REGEX = ::T.let(nil, ::T.untyped)
HOMEBREW_TAP_FORMULA_REGEX = ::T.let(nil, ::T.untyped)
@ -4942,6 +4945,8 @@ module RuboCop::AST::NodePattern::Sets
SET_INCLUDE_WITH_WITHOUT = ::T.let(nil, ::T.untyped)
SET_SYSTEM_SHELL_OUTPUT_PIPE_OUTPUT = ::T.let(nil, ::T.untyped)
SET_WITH_WITHOUT = ::T.let(nil, ::T.untyped)
SET__FETCH = ::T.let(nil, ::T.untyped)
SET_____2 = ::T.let(nil, ::T.untyped)
end
class RuboCop::Cask::AST::CaskHeader

View File

@ -1,11 +1,11 @@
# typed: false
# frozen_string_literal: true
homebrew_bootsnap_enabled = !ENV["HOMEBREW_NO_BOOTSNAP"] && ENV["HOMEBREW_BOOTSNAP"]
homebrew_bootsnap_enabled = ENV["HOMEBREW_NO_BOOTSNAP"].nil? && !ENV["HOMEBREW_BOOTSNAP"].nil?
# portable ruby doesn't play nice with bootsnap
# Can't use .exclude? here because we haven't required active_support yet.
homebrew_bootsnap_enabled &&= !ENV["HOMEBREW_RUBY_PATH"].to_s.include?("/vendor/portable-ruby/") # rubocop:disable Rails/NegateInclude
homebrew_bootsnap_enabled &&= !RUBY_PATH.to_s.include?("/vendor/portable-ruby/") # rubocop:disable Rails/NegateInclude
homebrew_bootsnap_enabled &&= if ENV["HOMEBREW_MACOS_VERSION"]
# Apple Silicon doesn't play nice with bootsnap
@ -24,14 +24,14 @@ if homebrew_bootsnap_enabled
Homebrew.install_bundler_gems!(only_warn_on_failure: true)
ENV["HOMEBREW_BOOTSNAP_RETRY"] = "1"
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
exec ENV.fetch("HOMEBREW_BREW_FILE"), *ARGV
end
end
ENV.delete("HOMEBREW_BOOTSNAP_RETRY")
if defined?(Bootsnap)
cache = ENV["HOMEBREW_CACHE"] || ENV["HOMEBREW_DEFAULT_CACHE"]
cache = ENV.fetch("HOMEBREW_CACHE", nil) || ENV.fetch("HOMEBREW_DEFAULT_CACHE", nil)
# Can't use .blank? here because we haven't required active_support yet.
raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? # rubocop:disable Rails/Blank

View File

@ -4,29 +4,16 @@
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`
HOMEBREW_BREW_FILE = Pathname(ENV["HOMEBREW_BREW_FILE"]).freeze
class MissingEnvironmentVariables < RuntimeError; end
# Helper module for getting environment variables which must be set.
#
# @api private
module EnvVar
def self.[](env)
raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env]
ENV.fetch(env)
end
end
HOMEBREW_BREW_FILE = Pathname(ENV.fetch("HOMEBREW_BREW_FILE")).freeze
# Where we link under
HOMEBREW_PREFIX = Pathname(EnvVar["HOMEBREW_PREFIX"]).freeze
HOMEBREW_PREFIX = Pathname(ENV.fetch("HOMEBREW_PREFIX")).freeze
# Where `.git` is found
HOMEBREW_REPOSITORY = Pathname(EnvVar["HOMEBREW_REPOSITORY"]).freeze
HOMEBREW_REPOSITORY = Pathname(ENV.fetch("HOMEBREW_REPOSITORY")).freeze
# Where we store most of Homebrew, taps, and various metadata
HOMEBREW_LIBRARY = Pathname(EnvVar["HOMEBREW_LIBRARY"]).freeze
HOMEBREW_LIBRARY = Pathname(ENV.fetch("HOMEBREW_LIBRARY")).freeze
# Where shim scripts for various build and SCM tools are stored
HOMEBREW_SHIMS_PATH = (HOMEBREW_LIBRARY/"Homebrew/shims").freeze
@ -44,19 +31,19 @@ HOMEBREW_PINNED_KEGS = (HOMEBREW_PREFIX/"var/homebrew/pinned").freeze
HOMEBREW_LOCKS = (HOMEBREW_PREFIX/"var/homebrew/locks").freeze
# Where we store built products
HOMEBREW_CELLAR = Pathname(EnvVar["HOMEBREW_CELLAR"]).freeze
HOMEBREW_CELLAR = Pathname(ENV.fetch("HOMEBREW_CELLAR")).freeze
# Where downloads (bottles, source tarballs, etc.) are cached
HOMEBREW_CACHE = Pathname(EnvVar["HOMEBREW_CACHE"]).freeze
HOMEBREW_CACHE = Pathname(ENV.fetch("HOMEBREW_CACHE")).freeze
# Where formulae installed via URL are cached
HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze
# Where build, postinstall, and test logs of formulae are written to
HOMEBREW_LOGS = Pathname(EnvVar["HOMEBREW_LOGS"]).expand_path.freeze
HOMEBREW_LOGS = Pathname(ENV.fetch("HOMEBREW_LOGS")).expand_path.freeze
# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
HOMEBREW_TEMP = Pathname(EnvVar["HOMEBREW_TEMP"]).yield_self do |tmp|
HOMEBREW_TEMP = Pathname(ENV.fetch("HOMEBREW_TEMP")).then do |tmp|
tmp.mkpath unless tmp.exist?
tmp.realpath
end.freeze
@ -64,5 +51,5 @@ end.freeze
# The Ruby path and args to use for forked Ruby calls
HOMEBREW_RUBY_EXEC_ARGS = [
RUBY_PATH,
ENV["HOMEBREW_RUBY_WARNINGS"],
ENV.fetch("HOMEBREW_RUBY_WARNINGS"),
].freeze

View File

@ -97,7 +97,7 @@ module Homebrew
--force-exclusion
]
args << if fix
"--auto-correct-all"
"--autocorrect-all"
else
"--parallel"
end

View File

@ -34,7 +34,7 @@ describe Cask::Artifact::Installer, :cask do
expect(command).to receive(:run!).with(
executable,
a_hash_including(
env: { "PATH" => PATH.new("#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin", ENV["PATH"]) },
env: { "PATH" => PATH.new("#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin", ENV.fetch("PATH")) },
),
)

View File

@ -19,9 +19,9 @@ describe Cask::Artifact::Pkg, :cask do
sudo: true,
print_stdout: true,
env: {
"LOGNAME" => ENV["USER"],
"USER" => ENV["USER"],
"USERNAME" => ENV["USER"],
"LOGNAME" => ENV.fetch("USER"),
"USER" => ENV.fetch("USER"),
"USERNAME" => ENV.fetch("USER"),
},
)
@ -68,9 +68,9 @@ describe Cask::Artifact::Pkg, :cask do
sudo: true,
print_stdout: true,
env: {
"LOGNAME" => ENV["USER"],
"USER" => ENV["USER"],
"USERNAME" => ENV["USER"],
"LOGNAME" => ENV.fetch("USER"),
"USER" => ENV.fetch("USER"),
"USERNAME" => ENV.fetch("USER"),
},
)

View File

@ -8,7 +8,7 @@ describe "brew --caskroom" do
it "prints Homebrew's Caskroom", :integration_test do
expect { brew_sh "--caskroom" }
.to output("#{ENV["HOMEBREW_PREFIX"]}/Caskroom\n").to_stdout
.to output("#{ENV.fetch("HOMEBREW_PREFIX")}/Caskroom\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end

View File

@ -8,7 +8,7 @@ describe "brew --cellar" do
it "prints Homebrew's Cellar", :integration_test do
expect { brew_sh "--cellar" }
.to output("#{ENV["HOMEBREW_CELLAR"]}\n").to_stdout
.to output("#{ENV.fetch("HOMEBREW_CELLAR")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end

View File

@ -8,14 +8,14 @@ describe "brew --prefix" do
it "prints Homebrew's prefix", :integration_test do
expect { brew_sh "--prefix" }
.to output("#{ENV["HOMEBREW_PREFIX"]}\n").to_stdout
.to output("#{ENV.fetch("HOMEBREW_PREFIX")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
it "prints the prefix for a Formula", :integration_test do
expect { brew_sh "--prefix", "wget" }
.to output("#{ENV["HOMEBREW_PREFIX"]}/opt/wget\n").to_stdout
.to output("#{ENV.fetch("HOMEBREW_PREFIX")}/opt/wget\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end

View File

@ -8,7 +8,7 @@ describe "brew --repository" do
it "prints Homebrew's repository", :integration_test do
expect { brew_sh "--repository" }
.to output("#{ENV["HOMEBREW_REPOSITORY"]}\n").to_stdout
.to output("#{ENV.fetch("HOMEBREW_REPOSITORY")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end

View File

@ -13,7 +13,7 @@ describe "brew custom-external-command", :integration_test do
SH
FileUtils.chmod "+x", file
expect { brew cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
expect { brew cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV.fetch("PATH")}" }
.to output("I am #{cmd}.\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

View File

@ -20,7 +20,7 @@ describe Homebrew::Diagnostic::Checks do
FileUtils.chmod 0755, anaconda
FileUtils.chmod 0755, python
ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV.fetch("PATH")}"
expect(checks.check_for_anaconda).to match("Anaconda")
end
@ -75,10 +75,12 @@ describe Homebrew::Diagnostic::Checks do
specify "#check_user_path_3" do
sbin = HOMEBREW_PREFIX/"sbin"
ENV["HOMEBREW_PATH"] =
(sbin/"something").mkpath
homebrew_path =
"#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
ENV["HOMEBREW_PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
(sbin/"something").mkpath
stub_const("ORIGINAL_PATHS", PATH.new(homebrew_path).map { |path| Pathname.new(path).expand_path }.compact)
expect(checks.check_user_path_1).to be_nil
expect(checks.check_user_path_2).to be_nil
@ -93,8 +95,7 @@ describe Homebrew::Diagnostic::Checks do
file = "#{path}/foo-config"
FileUtils.touch file
FileUtils.chmod 0755, file
ENV["HOMEBREW_PATH"] = ENV["PATH"] =
"#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV.fetch("PATH")}"
expect(checks.check_for_config_scripts)
.to match('"config" scripts exist')

View File

@ -35,7 +35,7 @@ require "find"
require "byebug"
require "timeout"
$LOAD_PATH.push(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
$LOAD_PATH.push(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib"))
require_relative "../global"
@ -150,7 +150,7 @@ RSpec.configure do |config|
skip "Subversion is not installed." unless quiet_system svn_shim, "--version"
svn_shim_path = Pathname(Utils.popen_read(svn_shim, "--homebrew=print-path").chomp.presence)
svn_paths = PATH.new(ENV["PATH"])
svn_paths = PATH.new(ENV.fetch("PATH"))
svn_paths.prepend(svn_shim_path.dirname)
if OS.mac?
@ -164,13 +164,13 @@ RSpec.configure do |config|
svnadmin = which("svnadmin", svn_paths)
skip "svnadmin is not installed." unless svnadmin
ENV["PATH"] = PATH.new(ENV["PATH"])
ENV["PATH"] = PATH.new(ENV.fetch("PATH"))
.append(svn.dirname)
.append(svnadmin.dirname)
end
config.before(:each, :needs_homebrew_curl) do
ENV["HOMEBREW_CURL"] = ENV["HOMEBREW_BREWED_CURL_PATH"]
ENV["HOMEBREW_CURL"] = HOMEBREW_BREWED_CURL_PATH
skip "A `curl` with TLS 1.3 support is required." unless curl_supports_tls13?
rescue FormulaUnavailableError
skip "No `curl` formula is available."
@ -203,6 +203,7 @@ RSpec.configure do |config|
FormulaInstaller.clear_attempted
FormulaInstaller.clear_installed
FormulaInstaller.clear_fetched
Utils::Curl.clear_path_cache
TEST_DIRECTORIES.each(&:mkpath)

View File

@ -8,9 +8,9 @@ cask "with-uninstall-script-user-relative" do
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
postflight do
File.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH
File.write "#{Dir.home}/MyFancyApp.app/uninstall.sh", <<~SH
#!/bin/sh
/bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app"
/bin/rm -r "#{Dir.home}/MyFancyApp.app"
SH
end

View File

@ -73,7 +73,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
env["PATH"],
(HOMEBREW_LIBRARY_PATH/"test/support/helper/cmd").realpath.to_s,
(HOMEBREW_PREFIX/"bin").realpath.to_s,
ENV["PATH"],
ENV.fetch("PATH"),
].compact.join(File::PATH_SEPARATOR)
env.merge!(
@ -82,7 +82,6 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
"HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
"HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"],
"HOMEBREW_DEV_CMD_RUN" => "true",
"GEM_HOME" => nil,
)
@ -127,7 +126,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
def brew_sh(*args)
Bundler.with_clean_env do
stdout, stderr, status = Open3.capture3("#{ENV["HOMEBREW_PREFIX"]}/bin/brew", *args)
stdout, stderr, status = Open3.capture3("#{ENV.fetch("HOMEBREW_PREFIX")}/bin/brew", *args)
$stdout.print stdout
$stderr.print stderr
status
@ -216,7 +215,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
full_name = Tap.fetch(name).full_name
# Check to see if the original Homebrew process has taps we can use.
system_tap_path = Pathname("#{ENV["HOMEBREW_LIBRARY"]}/Taps/#{full_name}")
system_tap_path = Pathname("#{ENV.fetch("HOMEBREW_LIBRARY")}/Taps/#{full_name}")
if system_tap_path.exist?
system "git", "clone", "--shared", system_tap_path, tap.path
system "git", "-C", tap.path, "checkout", "master"

View File

@ -3,10 +3,10 @@
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]).freeze
HOMEBREW_BREW_FILE = Pathname.new(ENV.fetch("HOMEBREW_BREW_FILE")).freeze
TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
dir = Dir.mktmpdir("homebrew-tests-", ENV["HOMEBREW_TEMP"] || "/tmp")
dir = Dir.mktmpdir("homebrew-tests-", ENV.fetch("HOMEBREW_TEMP"))
at_exit do
# Child processes inherit this at_exit handler, but we don't want them
# to clean TEST_TMPDIR up prematurely (i.e., when they exit early for a test).
@ -35,7 +35,7 @@ HOMEBREW_LOGS = (HOMEBREW_PREFIX.parent/"logs").freeze
HOMEBREW_TEMP = (HOMEBREW_PREFIX.parent/"temp").freeze
HOMEBREW_RUBY_EXEC_ARGS = [
RUBY_PATH,
ENV["HOMEBREW_RUBY_WARNINGS"],
ENV.fetch("HOMEBREW_RUBY_WARNINGS"),
"-I", HOMEBREW_LIBRARY_PATH/"test/support/lib"
].freeze

View File

@ -6,7 +6,7 @@ require "utils/user"
describe User do
subject { described_class.current }
it { is_expected.to eq ENV["USER"] }
it { is_expected.to eq ENV.fetch("USER") }
describe "#gui?" do
before do
@ -17,8 +17,8 @@ describe User do
context "when the current user is in a console session" do
let(:who_output) {
<<~EOS
#{ENV["USER"]} console Oct 1 11:23
#{ENV["USER"]} ttys001 Oct 1 11:25
#{ENV.fetch("USER")} console Oct 1 11:23
#{ENV.fetch("USER")} ttys001 Oct 1 11:25
EOS
}
@ -28,8 +28,8 @@ describe User do
context "when the current user is not in a console session" do
let(:who_output) {
<<~EOS
#{ENV["USER"]} ttys001 Oct 1 11:25
fake_user ttys002 Oct 1 11:27
#{ENV.fetch("USER")} ttys001 Oct 1 11:25
fake_user ttys002 Oct 1 11:27
EOS
}

View File

@ -114,10 +114,10 @@ describe "globally-scoped helper methods" do
ENV["LC_ALL"] = "en_US.UTF-8"
with_custom_locale("C") do
expect(ENV["LC_ALL"]).to eq("C")
expect(ENV.fetch("LC_ALL")).to eq("C")
end
expect(ENV["LC_ALL"]).to eq("en_US.UTF-8")
expect(ENV.fetch("LC_ALL")).to eq("en_US.UTF-8")
end
end
@ -274,17 +274,19 @@ describe "globally-scoped helper methods" do
describe "#with_env" do
it "sets environment variables within the block" do
expect(ENV["PATH"]).not_to eq("/bin")
expect(ENV.fetch("PATH")).not_to eq("/bin")
with_env(PATH: "/bin") do
expect(ENV["PATH"]).to eq("/bin")
expect(ENV.fetch("PATH", nil)).to eq("/bin")
end
end
it "restores ENV after the block" do
with_env(PATH: "/bin") do
expect(ENV["PATH"]).to eq("/bin")
expect(ENV.fetch("PATH", nil)).to eq("/bin")
end
expect(ENV["PATH"]).not_to eq("/bin")
path = ENV.fetch("PATH", nil)
expect(path).not_to be_nil
expect(path).not_to eq("/bin")
end
it "restores ENV if an exception is raised" do
@ -294,7 +296,9 @@ describe "globally-scoped helper methods" do
end
}.to raise_error(StandardError)
expect(ENV["PATH"]).not_to eq("/bin")
path = ENV.fetch("PATH", nil)
expect(path).not_to be_nil
expect(path).not_to eq("/bin")
end
end

View File

@ -23,7 +23,7 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "cabextract",
args: ["-d", unpack_dir, "--", path],
env: { "PATH" => PATH.new(Formula["cabextract"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["cabextract"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end

View File

@ -39,7 +39,7 @@ module UnpackStrategy
system_command! "fossil",
args: ["open", path, *args],
chdir: unpack_dir,
env: { "PATH" => PATH.new(Formula["fossil"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["fossil"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -32,7 +32,7 @@ module UnpackStrategy
"-force-overwrite", "-quiet", "-no-directory",
"-output-directory", unpack_dir, "--", path
],
env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["unar"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -29,7 +29,7 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "lha",
args: ["xq2w=#{unpack_dir}", path],
env: { "PATH" => PATH.new(Formula["lha"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["lha"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -31,7 +31,7 @@ module UnpackStrategy
quiet_flags = verbose ? [] : ["-q"]
system_command! "lzip",
args: ["-d", *quiet_flags, unpack_dir/basename],
env: { "PATH" => PATH.new(Formula["lzip"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["lzip"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -31,7 +31,7 @@ module UnpackStrategy
quiet_flags = verbose ? [] : ["-q"]
system_command! "unlzma",
args: [*quiet_flags, "--", unpack_dir/basename],
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -17,7 +17,7 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "hg",
args: ["--cwd", path, "archive", "--subrepos", "-y", "-t", "files", unpack_dir],
env: { "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["mercurial"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -29,7 +29,7 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "7zr",
args: ["x", "-y", "-bd", "-bso0", path, "-o#{unpack_dir}"],
env: { "PATH" => PATH.new(Formula["p7zip"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["p7zip"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -29,7 +29,7 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "unrar",
args: ["x", "-inul", path, unpack_dir],
env: { "PATH" => PATH.new(Formula["unrar"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["unrar"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -31,7 +31,7 @@ module UnpackStrategy
quiet_flags = verbose ? [] : ["-q"]
system_command! "unxz",
args: [*quiet_flags, "-T0", "--", unpack_dir/basename],
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["xz"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -37,7 +37,7 @@ module UnpackStrategy
quiet_flags = verbose ? [] : ["-qq"]
result = system_command! "unzip",
args: [*quiet_flags, "-o", path, "-d", unpack_dir],
env: { "PATH" => PATH.new(unzip&.opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(unzip&.opt_bin, ENV.fetch("PATH")) },
verbose: verbose,
print_stderr: false

View File

@ -31,7 +31,7 @@ module UnpackStrategy
quiet_flags = verbose ? [] : ["-q"]
system_command! "unzstd",
args: [*quiet_flags, "-T0", "--rm", "--", unpack_dir/basename],
env: { "PATH" => PATH.new(Formula["zstd"].opt_bin, ENV["PATH"]) },
env: { "PATH" => PATH.new(Formula["zstd"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose
end
end

View File

@ -130,7 +130,7 @@ module Homebrew
Dir.mktmpdir do |dir|
dir = Pathname(dir)
installer.yield_self do |i|
installer.then do |i|
i.extract_primary_container(to: dir)
rescue ErrorDuringExecution => e
onoe e

View File

@ -291,12 +291,12 @@ module Kernel
ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name
end
if ENV["SHELL"].include?("zsh") && (home = ENV["HOME"])&.start_with?(HOMEBREW_TEMP.resolved_path.to_s)
if Utils::Shell.preferred == :zsh && (home = Dir.home).start_with?(HOMEBREW_TEMP.resolved_path.to_s)
FileUtils.mkdir_p home
FileUtils.touch "#{home}/.zshrc"
end
Process.wait fork { exec ENV.fetch("SHELL") }
Process.wait fork { exec preferred_shell }
return if $CHILD_STATUS.success?
raise "Aborted due to non-zero exit status (#{$CHILD_STATUS.exitstatus})" if $CHILD_STATUS.exited?
@ -305,7 +305,7 @@ module Kernel
end
def with_homebrew_path(&block)
with_env(PATH: PATH.new(ENV["HOMEBREW_PATH"]), &block)
with_env(PATH: PATH.new(ORIGINAL_PATHS), &block)
end
def with_custom_locale(locale, &block)
@ -329,7 +329,7 @@ module Kernel
end
end
def which(cmd, path = ENV["PATH"])
def which(cmd, path = ENV.fetch("PATH"))
PATH.new(path).each do |p|
begin
pcmd = File.expand_path(cmd, p)
@ -343,7 +343,7 @@ module Kernel
nil
end
def which_all(cmd, path = ENV["PATH"])
def which_all(cmd, path = ENV.fetch("PATH"))
PATH.new(path).map do |p|
begin
pcmd = File.expand_path(cmd, p)
@ -362,7 +362,7 @@ module Kernel
# Find Atom, Sublime Text, VS Code, Textmate, BBEdit / TextWrangler, or vim
editor = %w[atom subl code mate edit vim].find do |candidate|
candidate if which(candidate, ENV["HOMEBREW_PATH"])
candidate if which(candidate, ORIGINAL_PATHS)
end
editor ||= "vim"
@ -387,7 +387,7 @@ module Kernel
ENV["DISPLAY"] = Homebrew::EnvConfig.display
with_env(DBUS_SESSION_BUS_ADDRESS: ENV["HOMEBREW_DBUS_SESSION_BUS_ADDRESS"]) do
with_env(DBUS_SESSION_BUS_ADDRESS: ENV.fetch("HOMEBREW_DBUS_SESSION_BUS_ADDRESS", nil)) do
safe_system(browser, *args)
end
end
@ -499,7 +499,7 @@ module Kernel
executable = [
which(name),
which(name, ENV["HOMEBREW_PATH"]),
which(name, ORIGINAL_PATHS),
HOMEBREW_PREFIX/"bin/#{name}",
].compact.first
return executable if executable.exist?
@ -508,11 +508,7 @@ module Kernel
end
def paths
@paths ||= PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
File.expand_path(p).chomp("/")
rescue ArgumentError
onoe "The following PATH component is invalid: #{p}"
end.uniq.compact
@paths ||= ORIGINAL_PATHS.uniq.map(&:to_s)
end
def parse_author!(author)
@ -608,6 +604,11 @@ module Kernel
end
end
sig { returns(String) }
def preferred_shell
ENV.fetch("SHELL", "/bin/sh")
end
sig { returns(String) }
def shell_profile
Utils::Shell.profile

View File

@ -34,7 +34,7 @@ module Utils
--data aip=1
--data t=#{type}
--data tid=#{analytics_id}
--data cid=#{ENV["HOMEBREW_ANALYTICS_USER_UUID"]}
--data cid=#{ENV.fetch("HOMEBREW_ANALYTICS_USER_UUID")}
--data an=#{HOMEBREW_PRODUCT}
--data av=#{HOMEBREW_VERSION}
]
@ -47,18 +47,19 @@ module Utils
args << "--data" << "#{key}=#{value}"
end
curl = Utils::Curl.curl_executable
# Send analytics. Don't send or store any personally identifiable information.
# https://docs.brew.sh/Analytics
# https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
if ENV["HOMEBREW_ANALYTICS_DEBUG"]
url = "https://www.google-analytics.com/debug/collect"
puts "#{ENV["HOMEBREW_CURL"]} #{args.join(" ")} #{url}"
puts Utils.popen_read ENV["HOMEBREW_CURL"], *args, url
puts "#{curl} #{args.join(" ")} #{url}"
puts Utils.popen_read(curl, *args, url)
else
pid = fork do
exec ENV["HOMEBREW_CURL"],
*args,
exec curl, *args,
"--silent", "--output", "/dev/null",
"https://www.google-analytics.com/collect"
end

View File

@ -15,8 +15,8 @@ module Utils
def tag(symbol = nil)
return Tag.from_symbol(symbol) if symbol.present?
@tag ||= Tag.new(system: T.must(ENV["HOMEBREW_SYSTEM"]).downcase.to_sym,
arch: T.must(ENV["HOMEBREW_PROCESSOR"]).downcase.to_sym)
@tag ||= Tag.new(system: HOMEBREW_SYSTEM.downcase.to_sym,
arch: HOMEBREW_PROCESSOR.downcase.to_sym)
end
def built_as?(f)

View File

@ -33,7 +33,7 @@ module Utils
module_function
def curl_executable(use_homebrew_curl: false)
return Pathname.new(ENV["HOMEBREW_BREWED_CURL_PATH"]) if use_homebrew_curl
return HOMEBREW_BREWED_CURL_PATH if use_homebrew_curl
@curl_executable ||= HOMEBREW_SHIMS_PATH/"shared/curl"
end
@ -42,6 +42,10 @@ module Utils
@curl_path ||= Utils.popen_read(curl_executable, "--homebrew=print-path").chomp.presence
end
def clear_path_cache
@curl_path = nil
end
sig {
params(
extra_args: T.untyped,
@ -413,7 +417,7 @@ module Utils
@curl_supports_tls13 ||= Hash.new do |h, key|
h[key] = quiet_system(curl_executable, "--tlsv1.3", "--head", "https://brew.sh/")
end
@curl_supports_tls13[ENV["HOMEBREW_CURL"]]
@curl_supports_tls13[curl_path]
end
def http_status_ok?(status)

View File

@ -18,7 +18,7 @@ module Homebrew
end
def gem_user_dir
ENV["HOMEBREW_TESTS_GEM_USER_DIR"] || Gem.user_dir
ENV.fetch("HOMEBREW_TESTS_GEM_USER_DIR", nil) || Gem.user_dir
end
def gem_user_bindir
@ -60,7 +60,7 @@ module Homebrew
# Set TMPDIR so Xcode's `make` doesn't fall back to `/var/tmp/`,
# which may be not user-writable.
ENV["TMPDIR"] = ENV["HOMEBREW_TEMP"]
ENV["TMPDIR"] = ENV.fetch("HOMEBREW_TEMP", nil)
return unless setup_path
@ -108,7 +108,7 @@ module Homebrew
odie_if_defined <<~EOS
the '#{name}' gem is installed but couldn't find '#{executable}' in the PATH:
#{ENV["PATH"]}
#{ENV.fetch("PATH")}
EOS
end
@ -129,11 +129,11 @@ module Homebrew
end
def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: [])
old_path = ENV["PATH"]
old_gem_path = ENV["GEM_PATH"]
old_gem_home = ENV["GEM_HOME"]
old_bundle_gemfile = ENV["BUNDLE_GEMFILE"]
old_bundle_with = ENV["BUNDLE_WITH"]
old_path = ENV.fetch("PATH", nil)
old_gem_path = ENV.fetch("GEM_PATH", nil)
old_gem_home = ENV.fetch("GEM_HOME", nil)
old_bundle_gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
old_bundle_with = ENV.fetch("BUNDLE_WITH", nil)
install_bundler!

View File

@ -124,7 +124,7 @@ module Utils
gnupg_bin = HOMEBREW_PREFIX/"opt/gnupg/bin"
return unless gnupg_bin.directory?
ENV["PATH"] = PATH.new(ENV["PATH"])
ENV["PATH"] = PATH.new(ENV.fetch("PATH"))
.prepend(gnupg_bin)
end

View File

@ -49,7 +49,7 @@ module Utils
def profile
case preferred
when :bash
bash_profile = "#{ENV["HOME"]}/.bash_profile"
bash_profile = "#{Dir.home}/.bash_profile"
return bash_profile if File.exist? bash_profile
when :zsh
return "#{ENV["ZDOTDIR"]}/.zshrc" if ENV["ZDOTDIR"].present?

View File

@ -84,7 +84,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec_junit_formatter
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.18.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.27.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.30.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.15.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.1/lib"