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" ]]
|
if [[ -z "$HOMEBREW_RUBY_WARNINGS" ]]
|
||||||
then
|
then
|
||||||
export HOMEBREW_RUBY_WARNINGS="-W0"
|
export HOMEBREW_RUBY_WARNINGS="-W1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_BOTTLE_DOMAIN" ]]
|
if [[ -z "$HOMEBREW_BOTTLE_DOMAIN" ]]
|
||||||
|
|||||||
@ -71,25 +71,29 @@ class AbstractDownloadStrategy
|
|||||||
# Unlike {Resource#stage}, this does not take a block.
|
# Unlike {Resource#stage}, this does not take a block.
|
||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
def stage
|
def stage(&block)
|
||||||
UnpackStrategy.detect(cached_location,
|
UnpackStrategy.detect(cached_location,
|
||||||
prioritise_extension: true,
|
prioritise_extension: true,
|
||||||
ref_type: @ref_type, ref: @ref)
|
ref_type: @ref_type, ref: @ref)
|
||||||
.extract_nestedly(basename: basename,
|
.extract_nestedly(basename: basename,
|
||||||
prioritise_extension: true,
|
prioritise_extension: true,
|
||||||
verbose: verbose? && !quiet?)
|
verbose: verbose? && !quiet?)
|
||||||
chdir
|
chdir(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def chdir
|
def chdir(&block)
|
||||||
entries = Dir["*"]
|
entries = Dir["*"]
|
||||||
raise "Empty archive" if entries.length.zero?
|
raise "Empty archive" if entries.length.zero?
|
||||||
return if entries.length != 1
|
|
||||||
|
|
||||||
begin
|
if entries.length != 1
|
||||||
Dir.chdir entries.first
|
yield if block
|
||||||
rescue
|
return
|
||||||
nil
|
end
|
||||||
|
|
||||||
|
if File.directory? entries.first
|
||||||
|
Dir.chdir(entries.first, &block)
|
||||||
|
elsif block
|
||||||
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :chdir
|
private :chdir
|
||||||
|
|||||||
@ -114,14 +114,15 @@ class Resource
|
|||||||
# A target or a block must be given, but not both.
|
# A target or a block must be given, but not both.
|
||||||
def unpack(target = nil)
|
def unpack(target = nil)
|
||||||
mktemp(download_name) do |staging|
|
mktemp(download_name) do |staging|
|
||||||
downloader.stage
|
downloader.stage do
|
||||||
@source_modified_time = downloader.source_modified_time
|
@source_modified_time = downloader.source_modified_time
|
||||||
apply_patches
|
apply_patches
|
||||||
if block_given?
|
if block_given?
|
||||||
yield ResourceStageContext.new(self, staging)
|
yield ResourceStageContext.new(self, staging)
|
||||||
elsif target
|
elsif target
|
||||||
target = Pathname(target)
|
target = Pathname(target)
|
||||||
target.install Pathname.pwd.children
|
target.install Pathname.pwd.children
|
||||||
|
end
|
||||||
end
|
end
|
||||||
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,
|
fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, reset_cache: false,
|
||||||
debug: false, verbose: false)
|
debug: false, verbose: false)
|
||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!
|
||||||
require "rubocop"
|
|
||||||
|
require "warnings"
|
||||||
|
|
||||||
|
Warnings.ignore :parser_syntax do
|
||||||
|
require "rubocop"
|
||||||
|
end
|
||||||
|
|
||||||
require "rubocops"
|
require "rubocops"
|
||||||
|
|
||||||
args = %w[
|
args = %w[
|
||||||
|
|||||||
@ -23,12 +23,17 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
|
|||||||
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
|
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require_relative "../warnings"
|
||||||
|
|
||||||
|
Warnings.ignore :parser_syntax do
|
||||||
|
require "rubocop"
|
||||||
|
end
|
||||||
|
|
||||||
require "rspec/its"
|
require "rspec/its"
|
||||||
require "rspec/github"
|
require "rspec/github"
|
||||||
require "rspec/wait"
|
require "rspec/wait"
|
||||||
require "rspec/retry"
|
require "rspec/retry"
|
||||||
require "rspec/sorbet"
|
require "rspec/sorbet"
|
||||||
require "rubocop"
|
|
||||||
require "rubocop/rspec/support"
|
require "rubocop/rspec/support"
|
||||||
require "find"
|
require "find"
|
||||||
require "byebug"
|
require "byebug"
|
||||||
|
|||||||
@ -2,18 +2,10 @@
|
|||||||
# typed: false
|
# typed: false
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "warning"
|
require_relative "../warnings"
|
||||||
|
|
||||||
warnings = [
|
Warnings.ignore :parser_syntax do
|
||||||
%r{warning: parser/current is loading parser/ruby\d+, which recognizes},
|
require "rubocop"
|
||||||
/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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require "rubocop"
|
|
||||||
|
|
||||||
exit RuboCop::CLI.new.run
|
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