diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index 5bb8666f2b..599e31d650 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -338,8 +338,7 @@ module RuboCop good_args = "Utils.#{command}({ \"#{match[1]}\" => \"#{match[2]}\" }, \"#{match[3]}\")" problem "Use `#{good_args}` instead of `#{method.source}`" do |corrector| - corrector.replace(@offensive_node.source_range, - "{ \"#{match[1]}\" => \"#{match[2]}\" }, \"#{match[3]}\"") + corrector.replace(method.source_range, good_args) end end end diff --git a/Library/Homebrew/test/rubocops/text/shell_variables_spec.rb b/Library/Homebrew/test/rubocops/text/shell_variables_spec.rb index f985b9192a..ddf39dc3cc 100644 --- a/Library/Homebrew/test/rubocops/text/shell_variables_spec.rb +++ b/Library/Homebrew/test/rubocops/text/shell_variables_spec.rb @@ -19,7 +19,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::ShellVariables do expect_correction(<<~RUBY) class Foo < Formula def install - Utils.popen { "SHELL" => "bash" }, "foo" + Utils.popen({ "SHELL" => "bash" }, "foo") end end RUBY @@ -38,7 +38,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::ShellVariables do expect_correction(<<~RUBY) class Foo < Formula def install - Utils.safe_popen_read { "SHELL" => "bash" }, "foo" + Utils.safe_popen_read({ "SHELL" => "bash" }, "foo") end end RUBY @@ -57,7 +57,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::ShellVariables do expect_correction(<<~RUBY) class Foo < Formula def install - Utils.safe_popen_write { "SHELL" => "bash" }, "foo" + Utils.safe_popen_write({ "SHELL" => "bash" }, "foo") end end RUBY @@ -76,7 +76,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::ShellVariables do expect_correction(<<~RUBY) class Foo < Formula def install - Utils.popen { "SHELL" => "bash" }, "\#{bin}/foo" + Utils.popen({ "SHELL" => "bash" }, "\#{bin}/foo") end end RUBY