Globally silence default gem warnings

This commit is contained in:
Bo Anderson 2024-09-05 01:35:28 +01:00
parent 615c53d0ab
commit eb5f47637f
No known key found for this signature in database
4 changed files with 14 additions and 14 deletions

View File

@ -4,10 +4,7 @@
require "api/analytics" require "api/analytics"
require "api/cask" require "api/cask"
require "api/formula" require "api/formula"
require "warnings" require "base64" # TODO: vendor this for Ruby 3.4.
Warnings.ignore :default_gems do
require "base64" # TODO: Add this to the Gemfile or remove it before moving to Ruby 3.4.
end
module Homebrew module Homebrew
# Helper functions for using Homebrew's formulae.brew.sh API. # Helper functions for using Homebrew's formulae.brew.sh API.

View File

@ -124,10 +124,7 @@ module Homebrew
sig { params(totals: T::Hash[String, T::Hash[Symbol, Integer]]).returns(String) } sig { params(totals: T::Hash[String, T::Hash[Symbol, Integer]]).returns(String) }
def generate_csv(totals) def generate_csv(totals)
require "warnings" require "csv" # TODO: this will be removed from Ruby 3.4
Warnings.ignore :default_gems do
require "csv"
end
CSV.generate do |csv| CSV.generate do |csv|
csv << %w[user repo author committer coauthor review total] csv << %w[user repo author committer coauthor review total]

View File

@ -52,3 +52,15 @@ require "portable_ruby_gems" if HOMEBREW_USING_PORTABLE_RUBY
$LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \ $LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \
"bundler-#{Homebrew::HOMEBREW_BUNDLER_VERSION}/lib" "bundler-#{Homebrew::HOMEBREW_BUNDLER_VERSION}/lib"
$LOAD_PATH.uniq! $LOAD_PATH.uniq!
# These warnings are nice but often flag problems that are not even our responsibly,
# including in some cases from other Ruby standard library gems.
# We strictly only allow one version of Ruby at a time so future compatibility
# doesn't need to be handled ahead of time.
if defined?(Gem::BUNDLED_GEMS)
[Kernel.singleton_class, Kernel].each do |kernel_class|
next unless kernel_class.respond_to?(:no_warning_require, true)
kernel_class.alias_method :require, :no_warning_require
end
end

View File

@ -9,13 +9,7 @@ module Warnings
parser_syntax: [ parser_syntax: [
%r{warning: parser/current is loading parser/ruby\d+, which recognizes}, %r{warning: parser/current is loading parser/ruby\d+, which recognizes},
/warning: \d+\.\d+\.\d+-compliant syntax, but you are running \d+\.\d+\.\d+\./, /warning: \d+\.\d+\.\d+-compliant syntax, but you are running \d+\.\d+\.\d+\./,
# FIXME: https://github.com/errata-ai/vale/issues/818
# <!-- vale off -->
%r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.}, %r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.},
# <!-- vale on -->
],
default_gems: [
/warning: .+\.rb was loaded from the standard library, .+ default gems since Ruby \d+\.\d+\.\d+\./,
], ],
}.freeze }.freeze