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 <module:Homebrew>'
This commit is contained in:
Issy Long 2019-10-13 11:02:34 +01:00
parent fed1bbe029
commit 18e684fad7
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -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