Commit 0b67044c authored by seanmccullough's avatar seanmccullough Committed by Commit bot

[depot_tools] Add gendered pronoun presubmit check.

Review-Url: https://codereview.chromium.org/2046003002
parent 16e0b4e2
......@@ -211,6 +211,26 @@ def CheckChangeHasNoCrAndHasOnlyOneEol(input_api, output_api,
items=eof_files))
return outputs
def CheckGenderNeutral(input_api, output_api, source_file_filter=None):
"""Checks that there are no gendered pronouns in any of the text files to be
submitted.
"""
gendered_re = input_api.re.compile(
'(^|\s|\(|\[)([Hh]e|[Hh]is|[Hh]ers?|[Hh]im|[Ss]he|[Gg]uys?)\\b')
errors = []
for f in input_api.AffectedFiles(include_deletes=False,
file_filter=source_file_filter):
for line_num, line in f.ChangedContents():
if gendered_re.search(line):
errors.append('%s (%d): %s' % (f.LocalPath(), line_num, line))
if len(errors):
return [output_api.PresubmitPromptWarning('Found a gendered pronoun in:',
long_text='\n'.join(errors))]
return []
def _ReportErrorFileAndLine(filename, line_num, dummy_line):
"""Default error formatter for _FindNewViolationsOfRule."""
......
......@@ -1876,6 +1876,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
'CheckChangeWasUploaded',
'CheckDoNotSubmit',
'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles',
'CheckGenderNeutral',
'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks',
'CheckLicense',
'CheckOwners',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment