brew audit - refactor text checks to make easier to test
This commit is contained in:
parent
cd50954677
commit
664e2aebd9
@ -6,12 +6,9 @@ def ff
|
|||||||
return ARGV.formulae
|
return ARGV.formulae
|
||||||
end
|
end
|
||||||
|
|
||||||
ff.each do |f|
|
def audit_formula_text text
|
||||||
text = ""
|
|
||||||
problems = []
|
problems = []
|
||||||
|
|
||||||
File.open(f.path, "r") { |afile| text = afile.read }
|
|
||||||
|
|
||||||
# Commented-out cmake support from default template
|
# Commented-out cmake support from default template
|
||||||
if text =~ /# depends_on 'cmake'/
|
if text =~ /# depends_on 'cmake'/
|
||||||
problems << " * Commented cmake support found."
|
problems << " * Commented cmake support found."
|
||||||
@ -42,8 +39,8 @@ ff.each do |f|
|
|||||||
problems << " * \"#{$1}\" should be \"\#{#{$2}}\""
|
problems << " * \"#{$1}\" should be \"\#{#{$2}}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
if text =~ %r[(\#\{prefix\}/share/man/(man[1-8]))]
|
if text =~ %r[((\#\{prefix\}/share/man/|\#\{man\}/)(man[1-8]))]
|
||||||
problems << " * \"#{$1}\" should be \"\#{#{$2}}\""
|
problems << " * \"#{$1}\" should be \"\#{#{$3}}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
if text =~ %r[(\#\{prefix\}/share/(info|man))]
|
if text =~ %r[(\#\{prefix\}/share/(info|man))]
|
||||||
@ -66,15 +63,30 @@ ff.each do |f|
|
|||||||
problems << " * Trailing whitespace was found."
|
problems << " * Trailing whitespace was found."
|
||||||
end
|
end
|
||||||
|
|
||||||
# Don't depend_on aliases; use full name
|
return problems
|
||||||
aliases = Formula.aliases
|
end
|
||||||
f.deps.select {|d| aliases.include? d}.each do |d|
|
|
||||||
problems << " * Dep #{d} is an alias; switch to the real name."
|
|
||||||
end
|
|
||||||
|
|
||||||
unless problems.empty?
|
def audit_some_formulae
|
||||||
puts "#{f.name}:"
|
ff.each do |f|
|
||||||
puts problems * "\n"
|
problems = []
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
audit_some_formulae
|
||||||
|
Loading…
x
Reference in New Issue
Block a user