mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
warnings: typed: strict
This commit is contained in:
parent
7156fb7d3a
commit
9bd85f30d8
@ -1,19 +1,20 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "warning"
|
require "warning"
|
||||||
|
|
||||||
# Helper module for handling warnings.
|
# Helper module for handling warnings.
|
||||||
module Warnings
|
module Warnings
|
||||||
COMMON_WARNINGS = {
|
COMMON_WARNINGS = T.let({
|
||||||
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+\./,
|
||||||
%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\.},
|
||||||
],
|
],
|
||||||
}.freeze
|
}.freeze, T::Hash[Symbol, T::Array[Regexp]])
|
||||||
|
|
||||||
def self.ignore(*warnings)
|
sig { params(warnings: T.any(Symbol, Regexp), _block: T.nilable(T.proc.void)).void }
|
||||||
|
def self.ignore(*warnings, &_block)
|
||||||
warnings.map! do |warning|
|
warnings.map! do |warning|
|
||||||
next warning if !warning.is_a?(Symbol) || !COMMON_WARNINGS.key?(warning)
|
next warning if !warning.is_a?(Symbol) || !COMMON_WARNINGS.key?(warning)
|
||||||
|
|
||||||
@ -25,8 +26,7 @@ module Warnings
|
|||||||
end
|
end
|
||||||
return unless block_given?
|
return unless block_given?
|
||||||
|
|
||||||
result = yield
|
yield
|
||||||
Warning.clear
|
Warning.clear
|
||||||
result
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user