Skip to content

Commit

Permalink
[Fixes rubocop#9700] Have Style/RedundantArgument use correct parser
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Apr 16, 2021
1 parent 9455d4a commit 4a66788
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog/fix_have_styleredundantargument_use_correct.md
@@ -0,0 +1 @@
* [#9700](https://github.com/rubocop/rubocop/issues/9700): Avoid warning about Ruby version mismatch. ([@marcandre][])
13 changes: 2 additions & 11 deletions lib/rubocop/cop/style/redundant_argument.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'parser/current'

module RuboCop
module Cop
module Style
Expand Down Expand Up @@ -68,17 +66,10 @@ def redundant_argument?(node)
end

def redundant_arg_for_method(method_name)
return nil unless cop_config['Methods'].key?(method_name)
arg = cop_config['Methods'].fetch(method_name) { return }

@mem ||= {}
@mem[method_name] ||=
begin
arg = cop_config['Methods'].fetch(method_name)
buffer = Parser::Source::Buffer.new('(string)', 1)
buffer.source = arg.inspect
builder = RuboCop::AST::Builder.new
Parser::CurrentRuby.new(builder).parse(buffer)
end
@mem[method_name] ||= parse(arg.inspect).ast
end

def argument_range(node)
Expand Down

0 comments on commit 4a66788

Please sign in to comment.