Skip to content
Snippets Groups Projects
Commit 664e2aeb authored by Adam Vandenberg's avatar Adam Vandenberg
Browse files

brew audit - refactor text checks to make easier to test

parent cd509546
No related branches found
No related tags found
No related merge requests found
......@@ -6,12 +6,9 @@ def ff
return ARGV.formulae
end
ff.each do |f|
text = ""
def audit_formula_text text
problems = []
File.open(f.path, "r") { |afile| text = afile.read }
# Commented-out cmake support from default template
if text =~ /# depends_on 'cmake'/
problems << " * Commented cmake support found."
......@@ -42,8 +39,8 @@ ff.each do |f|
problems << " * \"#{$1}\" should be \"\#{#{$2}}\""
end
if text =~ %r[(\#\{prefix\}/share/man/(man[1-8]))]
problems << " * \"#{$1}\" should be \"\#{#{$2}}\""
if text =~ %r[((\#\{prefix\}/share/man/|\#\{man\}/)(man[1-8]))]
problems << " * \"#{$1}\" should be \"\#{#{$3}}\""
end
if text =~ %r[(\#\{prefix\}/share/(info|man))]
......@@ -66,15 +63,30 @@ ff.each do |f|
problems << " * Trailing whitespace was found."
end
# Don't depend_on aliases; use full name
aliases = Formula.aliases
f.deps.select {|d| aliases.include? d}.each do |d|
problems << " * Dep #{d} is an alias; switch to the real name."
end
return problems
end
def audit_some_formulae
ff.each do |f|
problems = []
unless problems.empty?
puts "#{f.name}:"
puts problems * "\n"
puts
# Don't depend_on aliases; use full name
aliases = Formula.aliases
f.deps.select {|d| aliases.include? d}.each do |d|
problems << " * Dep #{d} is an alias; switch to the real name."
end
text = ""
File.open(f.path, "r") { |afile| text = afile.read }
problems += audit_formula_text(text)
unless problems.empty?
puts "#{f.name}:"
puts problems * "\n"
puts
end
end
end
audit_some_formulae
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment