File size: 699 Bytes
e98c0d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# typed: false
# frozen_string_literal: true

ALLOW_PATTERNS = [
  # Ignore `parser/current` warnings for ruby patch version mismatches.
  # This is a recurring issue that occurs whenever the parser gets
  # ahead of our installed ruby version.
  %r{parser/current is loading parser/ruby31},
  /3.1.\d-compliant syntax, but you are running 3.1.\d/,
  %r{whitequark/parser}
].freeze

# Called internally by Ruby for all warnings
module Warning
  def self.warn(message)
    $stderr.print(message)

    raise message if ENV["RAISE_ON_WARNINGS"].to_s == "true" && ALLOW_PATTERNS.none? { |pattern| pattern =~ message }

    return unless ENV["DEBUG_WARNINGS"]

    warn caller
    $stderr.puts
  end
end