From 18e684fad7a8decc0464370d205338b6a83b55aa Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 13 Oct 2019 11:02:34 +0100 Subject: [PATCH] Stringify dev-cmd/audit `text` variables when used in Regexp matching - To have the audit commands continue to work, and the tests passing (the previous error was [1]), everywhere we're trying to `.match?(text)`, instead do `.match?(text.to_s)`. [1] 5) Homebrew::FormulaAuditor#audit_file __END__ but no DATA Failure/Error: fa.audit_file TypeError: no implicit conversion of Homebrew::FormulaText into String # ./dev-cmd/audit.rb:267:in `match?' # ./dev-cmd/audit.rb:267:in `audit_file' # ./test/dev-cmd/audit_spec.rb:137:in `block (3 levels) in ' --- Library/Homebrew/dev-cmd/audit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 92bd38ab81..5f4e5359c2 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -264,7 +264,7 @@ module Homebrew problem "'__END__' was found, but 'DATA' is not used" if text.end? && !text.data? - if /inreplace [^\n]* do [^\n]*\n[^\n]*\.gsub![^\n]*\n\ *end/m.match?(text) + if /inreplace [^\n]* do [^\n]*\n[^\n]*\.gsub![^\n]*\n\ *end/m.match?(text.to_s) problem "'inreplace ... do' was used for a single substitution (use the non-block form instead)." end @@ -888,7 +888,7 @@ module Homebrew end bin_names.each do |name| ["system", "shell_output", "pipe_output"].each do |cmd| - if /test do.*#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]/m.match?(text) + if /test do.*#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]/m.match?(text.to_s) problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}") end end