diff --git a/changelog/fix_have_styleredundantargument_use_correct.md b/changelog/fix_have_styleredundantargument_use_correct.md new file mode 100644 index 00000000000..035bcdcd465 --- /dev/null +++ b/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][]) diff --git a/lib/rubocop/cop/style/redundant_argument.rb b/lib/rubocop/cop/style/redundant_argument.rb index c211f2fa009..6e091a54c2f 100644 --- a/lib/rubocop/cop/style/redundant_argument.rb +++ b/lib/rubocop/cop/style/redundant_argument.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'parser/current' - module RuboCop module Cop module Style @@ -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)