Module: Warnings Private

Defined in:
warnings.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper module for handling warnings.

Constant Summary collapse

COMMON_WARNINGS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

{
  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+\./,
    # FIXME: https://github.com/errata-ai/vale/issues/818
    # <!-- vale off -->
    %r{warning: please see https://github\.com/whitequark/parser#compatibility-with-ruby-mri\.},
    # <!-- vale on -->
  ],
}.freeze

Class Method Summary collapse

Class Method Details

.ignore(*warnings) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'warnings.rb', line 19

def self.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