Merge pull request #8774 from reitermarkus/sorbet-fixes

Fix some typechecking errors.
This commit is contained in:
Issy Long 2020-09-19 09:24:45 +01:00 committed by GitHub
commit cb027474f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 14 deletions

View File

@ -18,11 +18,11 @@ module Cask
attr_reader :token, :sourcefile_path, :config
def self.each
def self.each(&block)
return to_enum unless block_given?
Tap.flat_map(&:cask_files).each do |f|
yield CaskLoader::FromTapPathLoader.new(f).load
block.call CaskLoader::FromTapPathLoader.new(f).load
rescue CaskUnreadableError => e
opoo e.message
end

View File

@ -166,10 +166,12 @@ module SharedEnvExtension
# end</pre>
def compiler
@compiler ||= if (cc = @cc)
warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP
warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP)
fetch_compiler(cc, "--cc")
elsif (cc = homebrew_cc)
warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP
warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP)
compiler = fetch_compiler(cc, "HOMEBREW_CC")
if @formula

View File

@ -46,9 +46,9 @@ module Stdenv
send(compiler)
return unless cc =~ GNU_GCC_REGEXP
return unless cc.match?(GNU_GCC_REGEXP)
gcc_formula = gcc_version_formula($&)
gcc_formula = gcc_version_formula(cc)
append_path "PATH", gcc_formula.opt_bin.to_s
end
alias generic_setup_build_environment setup_build_environment

View File

@ -111,7 +111,7 @@ module Superenv
path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin")
begin
path.append(gcc_version_formula($&).opt_bin) if homebrew_cc =~ GNU_GCC_REGEXP
path.append(gcc_version_formula(homebrew_cc).opt_bin) if homebrew_cc.match?(GNU_GCC_REGEXP)
rescue FormulaUnavailableError
# Don't fail and don't add these formulae to the path if they don't exist.
nil

View File

@ -1459,9 +1459,9 @@ class Formula
end
# @private
def self.each
def self.each(&block)
files.each do |file|
yield Formulary.factory(file)
block.call Formulary.factory(file)
rescue FormulaUnavailableError, FormulaUnreadableError => e
# Don't let one broken formula break commands. But do complain.
onoe "Failed to import: #{file}"

View File

@ -3,9 +3,8 @@
module Utils::Inreplace
include Kernel
sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(String), audit_result: T::Boolean).void }
sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(T.any(String, Symbol)), audit_result: T::Boolean).void }
def inreplace(paths, before = nil, after = nil, audit_result = true); end
end
class StringInreplaceExtension

View File

@ -552,14 +552,14 @@ class Tap
self.class == other.class && name == other.name
end
def self.each
def self.each(&block)
return unless TAP_DIRECTORY.directory?
return to_enum unless block_given?
TAP_DIRECTORY.subdirs.each do |user|
user.subdirs.each do |repo|
yield fetch(user.basename.to_s, repo.basename.to_s)
block.call fetch(user.basename.to_s, repo.basename.to_s)
end
end
end

View File

@ -28,6 +28,8 @@ module Utils
#
# @api public
def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter
after = after.to_s if after.is_a? Symbol
errors = {}
errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.blank?
@ -39,7 +41,6 @@ module Utils
if before.nil? && after.nil?
yield s
else
after = after.to_s if after.is_a? Symbol
s.gsub!(before, after, audit_result)
end