Merge pull request #10598 from Rylan12/allow-warnings
Set default ruby warning level to -W1
This commit is contained in:
commit
a05e9337d8
@ -576,7 +576,7 @@ fi
|
||||
|
||||
if [[ -z "$HOMEBREW_RUBY_WARNINGS" ]]
|
||||
then
|
||||
export HOMEBREW_RUBY_WARNINGS="-W0"
|
||||
export HOMEBREW_RUBY_WARNINGS="-W1"
|
||||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_BOTTLE_DOMAIN" ]]
|
||||
|
||||
@ -71,25 +71,29 @@ class AbstractDownloadStrategy
|
||||
# Unlike {Resource#stage}, this does not take a block.
|
||||
#
|
||||
# @api public
|
||||
def stage
|
||||
def stage(&block)
|
||||
UnpackStrategy.detect(cached_location,
|
||||
prioritise_extension: true,
|
||||
ref_type: @ref_type, ref: @ref)
|
||||
.extract_nestedly(basename: basename,
|
||||
prioritise_extension: true,
|
||||
verbose: verbose? && !quiet?)
|
||||
chdir
|
||||
chdir(&block)
|
||||
end
|
||||
|
||||
def chdir
|
||||
def chdir(&block)
|
||||
entries = Dir["*"]
|
||||
raise "Empty archive" if entries.length.zero?
|
||||
return if entries.length != 1
|
||||
|
||||
begin
|
||||
Dir.chdir entries.first
|
||||
rescue
|
||||
nil
|
||||
if entries.length != 1
|
||||
yield if block
|
||||
return
|
||||
end
|
||||
|
||||
if File.directory? entries.first
|
||||
Dir.chdir(entries.first, &block)
|
||||
elsif block
|
||||
yield
|
||||
end
|
||||
end
|
||||
private :chdir
|
||||
|
||||
@ -114,14 +114,15 @@ class Resource
|
||||
# A target or a block must be given, but not both.
|
||||
def unpack(target = nil)
|
||||
mktemp(download_name) do |staging|
|
||||
downloader.stage
|
||||
@source_modified_time = downloader.source_modified_time
|
||||
apply_patches
|
||||
if block_given?
|
||||
yield ResourceStageContext.new(self, staging)
|
||||
elsif target
|
||||
target = Pathname(target)
|
||||
target.install Pathname.pwd.children
|
||||
downloader.stage do
|
||||
@source_modified_time = downloader.source_modified_time
|
||||
apply_patches
|
||||
if block_given?
|
||||
yield ResourceStageContext.new(self, staging)
|
||||
elsif target
|
||||
target = Pathname(target)
|
||||
target.install Pathname.pwd.children
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -78,7 +78,13 @@ module Homebrew
|
||||
fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, reset_cache: false,
|
||||
debug: false, verbose: false)
|
||||
Homebrew.install_bundler_gems!
|
||||
require "rubocop"
|
||||
|
||||
require "warnings"
|
||||
|
||||
Warnings.ignore :parser_syntax do
|
||||
require "rubocop"
|
||||
end
|
||||
|
||||
require "rubocops"
|
||||
|
||||
args = %w[
|
||||
|
||||
@ -23,12 +23,17 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
|
||||
end
|
||||
|
||||
require_relative "../warnings"
|
||||
|
||||
Warnings.ignore :parser_syntax do
|
||||
require "rubocop"
|
||||
end
|
||||
|
||||
require "rspec/its"
|
||||
require "rspec/github"
|
||||
require "rspec/wait"
|
||||
require "rspec/retry"
|
||||
require "rspec/sorbet"
|
||||
require "rubocop"
|
||||
require "rubocop/rspec/support"
|
||||
require "find"
|
||||
require "byebug"
|
||||
|
||||
@ -2,18 +2,10 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "warning"
|
||||
require_relative "../warnings"
|
||||
|
||||
warnings = [
|
||||
%r{warning: parser/current is loading parser/ruby\d+, which recognizes},
|
||||
/warning: \d+\.\d+\.\d+-compliant syntax, but you are running \d+\.\d+\.\d+\./,
|
||||
%r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.},
|
||||
]
|
||||
|
||||
warnings.each do |warning|
|
||||
Warning.ignore warning
|
||||
Warnings.ignore :parser_syntax do
|
||||
require "rubocop"
|
||||
end
|
||||
|
||||
require "rubocop"
|
||||
|
||||
exit RuboCop::CLI.new.run
|
||||
|
||||
36
Library/Homebrew/warnings.rb
Normal file
36
Library/Homebrew/warnings.rb
Normal file
@ -0,0 +1,36 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "warning"
|
||||
|
||||
# Helper module for handling warnings.
|
||||
#
|
||||
# @api private
|
||||
module Warnings
|
||||
module_function
|
||||
|
||||
COMMON_WARNINGS = {
|
||||
parser_syntax: [
|
||||
%r{warning: parser/current is loading parser/ruby\d+, which recognizes},
|
||||
/warning: \d+\.\d+\.\d+-compliant syntax, but you are running \d+\.\d+\.\d+\./,
|
||||
%r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.},
|
||||
],
|
||||
}.freeze
|
||||
|
||||
def ignore(*warnings)
|
||||
warnings.map! do |warning|
|
||||
next warning if !warning.is_a?(Symbol) || !COMMON_WARNINGS.key?(warning)
|
||||
|
||||
COMMON_WARNINGS[warning]
|
||||
end
|
||||
|
||||
warnings.flatten.each do |warning|
|
||||
Warning.ignore warning
|
||||
end
|
||||
return unless block_given?
|
||||
|
||||
result = yield
|
||||
Warning.clear
|
||||
result
|
||||
end
|
||||
end
|
||||
5
Library/Homebrew/warnings.rbi
Normal file
5
Library/Homebrew/warnings.rbi
Normal file
@ -0,0 +1,5 @@
|
||||
# typed: strict
|
||||
|
||||
module Warnings
|
||||
include Kernel
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user