Update msftidy to flag authors with unbalanced angle brackets

bug/bundler_fix
Jon Hart 2015-11-06 13:23:14 -08:00
parent 2df149b0a5
commit f34bf544d3
No known key found for this signature in database
GPG Key ID: 2FA9F0A3AFA8E9D3
1 changed files with 14 additions and 2 deletions

View File

@ -317,6 +317,8 @@ class Msftidy
next next
end end
# XXX: note that this is all very fragile and regularly incorrectly parses
# the author
# #
# Mark our 'Author' block # Mark our 'Author' block
# #
@ -328,10 +330,12 @@ class Msftidy
# #
# While in 'Author' block, check for Twitter handles # While in 'Author' block, check for malformed authors
# #
if in_super and in_author if in_super and in_author
if line =~ /Author/ if line =~ /Author['"]\s*=>\s*['"](.*)['"],/
author_name = Regexp.last_match(1)
elsif line =~ /Author/
author_name = line.scan(/\[[[:space:]]*['"](.+)['"]/).flatten[-1] || '' author_name = line.scan(/\[[[:space:]]*['"](.+)['"]/).flatten[-1] || ''
else else
author_name = line.scan(/['"](.+)['"]/).flatten[-1] || '' author_name = line.scan(/['"](.+)['"]/).flatten[-1] || ''
@ -344,6 +348,14 @@ class Msftidy
if not author_name.ascii_only? if not author_name.ascii_only?
error("Please avoid unicode or non-printable characters in Author") error("Please avoid unicode or non-printable characters in Author")
end end
unless author_name.empty?
author_open_brackets = author_name.scan('<').size
author_close_brackets = author_name.scan('>').size
if author_open_brackets != author_close_brackets
error("Author has unbalanced brackets: #{author_name}")
end
end
end end
end end
end end