Skip to content

Commit

Permalink
Silence parser warning and patch version mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Apr 16, 2021
1 parent 816dfe7 commit 7081f7c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/rubocop/ast/processed_source.rb
Expand Up @@ -222,19 +222,19 @@ def tokenize(parser)
def parser_class(ruby_version)
case ruby_version
when 2.4
require 'parser/ruby24'
require_parser 'ruby24'
Parser::Ruby24
when 2.5
require 'parser/ruby25'
require_parser 'ruby25'
Parser::Ruby25
when 2.6
require 'parser/ruby26'
require_parser 'ruby26'
Parser::Ruby26
when 2.7
require 'parser/ruby27'
require_parser 'ruby27'
Parser::Ruby27
when 2.8, 3.0
require 'parser/ruby30'
require_parser 'ruby30'
Parser::Ruby30
else
raise ArgumentError,
Expand All @@ -243,6 +243,14 @@ def parser_class(ruby_version)
end
# rubocop:enable Metrics/MethodLength

def require_parser(path)
prev = $VERBOSE
$VERBOSE = nil
require "parser/#{path}"
ensure
$VERBOSE = prev
end

def create_parser(ruby_version)
builder = RuboCop::AST::Builder.new

Expand Down

0 comments on commit 7081f7c

Please sign in to comment.