Skip to content

Commit f34bf54

Browse files
committed
Update msftidy to flag authors with unbalanced angle brackets
1 parent 2df149b commit f34bf54

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tools/dev/msftidy.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ def check_badchars
317317
next
318318
end
319319

320+
# XXX: note that this is all very fragile and regularly incorrectly parses
321+
# the author
320322
#
321323
# Mark our 'Author' block
322324
#
@@ -328,10 +330,12 @@ def check_badchars
328330

329331

330332
#
331-
# While in 'Author' block, check for Twitter handles
333+
# While in 'Author' block, check for malformed authors
332334
#
333335
if in_super and in_author
334-
if line =~ /Author/
336+
if line =~ /Author['"]\s*=>\s*['"](.*)['"],/
337+
author_name = Regexp.last_match(1)
338+
elsif line =~ /Author/
335339
author_name = line.scan(/\[[[:space:]]*['"](.+)['"]/).flatten[-1] || ''
336340
else
337341
author_name = line.scan(/['"](.+)['"]/).flatten[-1] || ''
@@ -344,6 +348,14 @@ def check_badchars
344348
if not author_name.ascii_only?
345349
error("Please avoid unicode or non-printable characters in Author")
346350
end
351+
352+
unless author_name.empty?
353+
author_open_brackets = author_name.scan('<').size
354+
author_close_brackets = author_name.scan('>').size
355+
if author_open_brackets != author_close_brackets
356+
error("Author has unbalanced brackets: #{author_name}")
357+
end
358+
end
347359
end
348360
end
349361
end

0 commit comments

Comments
 (0)