Ignore more parser warnings

This commit is contained in:
Rylan Polster 2021-02-14 11:56:32 -05:00
parent 1cc983f00d
commit 79e93f54e2
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
5 changed files with 57 additions and 13 deletions

View File

@ -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 "warnings"
Warnings.ignore :parser_syntax do
require "rubocop" require "rubocop"
end
require "rubocops" require "rubocops"
args = %w[ args = %w[

View File

@ -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"

View File

@ -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

View 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

View File

@ -0,0 +1,5 @@
# typed: strict
module Warnings
include Kernel
end