From cc3eceb04fce67c2966a20261d51254b1f53255d Mon Sep 17 00:00:00 2001 From: Markus Reiter <me@reitermark.us> Date: Sat, 19 Sep 2020 01:53:59 +0200 Subject: [PATCH] Fix `inreplace` signature. --- Library/Homebrew/sorbet/rbi/utils/inreplace.rbi | 3 +-- Library/Homebrew/utils/inreplace.rb | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi b/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi index 6c9bfb5b3e..b6d0be9a5a 100644 --- a/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi +++ b/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi @@ -3,9 +3,8 @@ module Utils::Inreplace include Kernel - sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(String), audit_result: T::Boolean).void } + sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(T.any(String, Symbol)), audit_result: T::Boolean).void } def inreplace(paths, before = nil, after = nil, audit_result = true); end - end class StringInreplaceExtension diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index 8367b9c3ff..ae3489b6c8 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -28,6 +28,8 @@ module Utils # # @api public def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter + after = after.to_s if after.is_a? Symbol + errors = {} errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.blank? @@ -39,7 +41,6 @@ module Utils if before.nil? && after.nil? yield s else - after = after.to_s if after.is_a? Symbol s.gsub!(before, after, audit_result) end -- GitLab