Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warnings: typed: strict #18443

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Library/Homebrew/warnings.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# typed: true # rubocop:todo Sorbet/StrictSigil
# typed: strict
# frozen_string_literal: true

require "warning"

# Helper module for handling warnings.
module Warnings
COMMON_WARNINGS = {
COMMON_WARNINGS = T.let({
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
}.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|
next warning if !warning.is_a?(Symbol) || !COMMON_WARNINGS.key?(warning)

Expand All @@ -25,8 +26,7 @@ def self.ignore(*warnings)
end
return unless block_given?

result = yield
yield
Warning.clear
result
end
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
end
Loading