audit: reorganize some checks
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
c36561f450
commit
ab19242d04
@ -199,6 +199,11 @@ def audit_formula_urls f
|
||||
problems << " * The homepage should start with http or https."
|
||||
end
|
||||
|
||||
# Google Code homepages should end in a slash
|
||||
if f.homepage =~ %r[^https?://code\.google\.com/p/[^/]+[^/]$]
|
||||
problems << " * Google Code homepage should end with a slash."
|
||||
end
|
||||
|
||||
urls = [(f.url rescue nil), (f.head rescue nil)].reject {|p| p.nil?}
|
||||
urls.uniq! # head-only formulae result in duplicate entries
|
||||
|
||||
@ -251,6 +256,24 @@ def audit_formula_urls f
|
||||
return problems
|
||||
end
|
||||
|
||||
def audit_formula_specs text
|
||||
problems = []
|
||||
|
||||
if text =~ /devel .+(url '.+').+(url '.+')/m
|
||||
problems << " * 'devel' block found before stable 'url'"
|
||||
end
|
||||
|
||||
if text =~ /devel .+(head '.+')/m
|
||||
problems << " * 'devel' block found before 'head'"
|
||||
end
|
||||
|
||||
if text =~ /devel do\s+end/
|
||||
problems << " * Empty 'devel' block found"
|
||||
end
|
||||
|
||||
return problems
|
||||
end
|
||||
|
||||
def audit_formula_instance f
|
||||
problems = []
|
||||
|
||||
@ -275,10 +298,7 @@ def audit_formula_instance f
|
||||
end
|
||||
end
|
||||
|
||||
# Google Code homepages should end in a slash
|
||||
if f.homepage =~ %r[^https?://code\.google\.com/p/[^/]+[^/]$]
|
||||
problems << " * Google Code homepage should end with a slash."
|
||||
end
|
||||
problems += [' * invalid or missing version'] if f.version.to_s.empty?
|
||||
|
||||
return problems
|
||||
end
|
||||
@ -310,15 +330,10 @@ module Homebrew extend self
|
||||
problems << " * 'DATA' was found, but no '__END__'"
|
||||
end
|
||||
|
||||
problems << " * File should end with a newline" if text =~ /.+\z/
|
||||
|
||||
problems += [' * invalid or missing version'] if f.version.to_s.empty?
|
||||
|
||||
problems << " * 'devel' block found before stable 'url'" if text =~ /devel .+(url '.+').+(url '.+')/m
|
||||
|
||||
problems << " * 'devel' block found before 'head'" if text =~ /devel .+(head '.+')/m
|
||||
|
||||
problems << " * Empty 'devel' block found" if text =~ /devel do\s+end/
|
||||
# files should end with a newline
|
||||
if text =~ /.+\z/
|
||||
problems << " * File should end with a newline"
|
||||
end
|
||||
|
||||
# Don't try remaining audits on text in __END__
|
||||
text_without_patch = (text.split("__END__")[0]).strip()
|
||||
@ -326,6 +341,7 @@ module Homebrew extend self
|
||||
problems += audit_formula_text(f.name, text_without_patch)
|
||||
problems += audit_formula_options(f, text_without_patch)
|
||||
problems += audit_formula_version(f, text_without_patch)
|
||||
problems += audit_formula_specs(text_without_patch)
|
||||
|
||||
unless problems.empty?
|
||||
errors = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user