Skip to content

Commit 9a2cb7e

Browse files
committed
Improve title casing check
Sometimes the first letter of a word shouldn't be capitalized. If you do, it may actually be technically incorrect. For example: a function name, a filename, or even a software name like freeFTPd. We should ignore scenarios like those.
1 parent d90d41d commit 9a2cb7e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tools/msftidy.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,14 @@ def check_disclosure_date
208208
end
209209
end
210210

211-
def check_title_format
211+
def check_title_casing
212212
if @source =~ /'Name'[[:space:]]*=>[[:space:]]*['|"](.+)['|"],*$/
213213
words = $1.split
214214
words.each do |word|
215-
if word =~ /^['"].+['"]$/ or word =~ /^[a-z].*[A-Z].+$/ or word =~ /^.+\(\)$/ or word =~ /^[vb][\d\.\-r]+$/
215+
if %w{and or the for via to in}.include?(word)
216216
next
217-
elsif %w{and or the for via to}.include?(word)
218-
next
219-
elsif word[0, 1] != word[0, 1].capitalize
220-
warn("Improper capitalization in module title: '#{word}...'")
217+
elsif word =~ /^[a-z]+$/
218+
warn("Improper capitalization in module title: '#{word}'")
221219
end
222220
end
223221
end
@@ -330,7 +328,7 @@ def run_checks(f_rel)
330328
tidy.test_old_rubies(f_rel)
331329
tidy.check_ranking
332330
tidy.check_disclosure_date
333-
tidy.check_title_format
331+
tidy.check_title_casing
334332
tidy.check_bad_terms
335333
tidy.check_function_basics
336334
tidy.check_lines

0 commit comments

Comments
 (0)