Remove patch checks from audit

This commit is contained in:
Frank Lam 2020-06-27 02:37:57 +08:00
parent afb8445380
commit b2eafdf11d
No known key found for this signature in database
GPG Key ID: 771022A2327531C7
2 changed files with 0 additions and 55 deletions

View File

@ -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)."

View File

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