From b2eafdf11d1bec99479e9a097f68cf5be31c2146 Mon Sep 17 00:00:00 2001 From: Frank Lam Date: Sat, 27 Jun 2020 02:37:57 +0800 Subject: [PATCH] Remove patch checks from audit --- Library/Homebrew/dev-cmd/audit.rb | 14 ------- Library/Homebrew/test/dev-cmd/audit_spec.rb | 41 --------------------- 2 files changed, 55 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index aade8065e9..9210c975f9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -168,14 +168,6 @@ module Homebrew @text.split("\n__END__").first end - def data? - /^[^#]*\bDATA\b/ =~ @text - end - - def end? - /^__END__$/ =~ @text - end - def trailing_newline? /\Z\n/ =~ @text end @@ -234,12 +226,6 @@ module Homebrew end def audit_file - # TODO: check could be in RuboCop - problem "'DATA' was found, but no '__END__'" if text.data? && !text.end? - - # TODO: check could be in RuboCop - problem "'__END__' was found, but 'DATA' is not used" if text.end? && !text.data? - # TODO: check could be in RuboCop if text.to_s.match?(/inreplace [^\n]* do [^\n]*\n[^\n]*\.gsub![^\n]*\n\ *end/m) problem "'inreplace ... do' was used for a single substitution (use the non-block form instead)." diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 0a437b20d6..992281d5c1 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -41,8 +41,6 @@ module Homebrew url "https://www.brew.sh/valid-1.0.tar.gz" RUBY - expect(ft).not_to have_data - expect(ft).not_to have_end expect(ft).to have_trailing_newline expect(ft =~ /\burl\b/).to be_truthy @@ -55,20 +53,6 @@ module Homebrew ft = formula_text "newline" expect(ft).to have_trailing_newline end - - specify "#data?" do - ft = formula_text "data", <<~RUBY - patch :DATA - RUBY - - expect(ft).to have_data - end - - specify "#end?" do - ft = formula_text "end", "", patch: "__END__\na patch here" - expect(ft).to have_end - expect(ft.without_patch).to eq("class End < Formula\n \nend") - end end describe FormulaAuditor do @@ -96,31 +80,6 @@ module Homebrew end describe "#audit_file" do - specify "DATA but no __END__" do - fa = formula_auditor "foo", <<~RUBY - class Foo < Formula - url "https://brew.sh/foo-1.0.tgz" - patch :DATA - end - RUBY - - fa.audit_file - expect(fa.problems).to eq(["'DATA' was found, but no '__END__'"]) - end - - specify "__END__ but no DATA" do - fa = formula_auditor "foo", <<~RUBY - class Foo < Formula - url "https://brew.sh/foo-1.0.tgz" - end - __END__ - a patch goes here - RUBY - - fa.audit_file - expect(fa.problems).to eq(["'__END__' was found, but 'DATA' is not used"]) - end - specify "no issue" do fa = formula_auditor "foo", <<~RUBY class Foo < Formula