Skip to content

Commit

Permalink
PRESUBMIT: Skip TODO(crbug.com/ pattern for upload warning
Browse files Browse the repository at this point in the history
This CL admits the TODO(crbug.com/...) format for bug
references in the code base and avoids the presubmit
warning in those cases. This pattern is pervasive and
even necessary in some folders (e.g. ios/) so, although
it isn't linkified by cs.chromium.org, it's accepted.

Change-Id: Ifb6eda7967271acf76ddfb5fa555ed60f9bce415
Reviewed-on: https://chromium-review.googlesource.com/833203
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525052}
  • Loading branch information
yellowdoge authored and Commit Bot committed Dec 19, 2017
1 parent f79fcd1 commit 68bdb65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -2762,17 +2762,20 @@ def _CheckSyslogUseWarning(input_api, output_api, source_file_filter=None,


def _CheckCrbugLinksHaveHttps(input_api, output_api):
"""Checks that crbug(.com) links are correctly prefixed by https://"""
"""Checks that crbug(.com) links are correctly prefixed by https://,
unless they come in the accepted form TODO(crbug.com/...)
"""
white_list = r'.+%s' % _IMPLEMENTATION_EXTENSIONS
black_list = (_EXCLUDED_PATHS + _TEST_CODE_EXCLUDED_PATHS)
sources = lambda f: input_api.FilterSourceFile(
f, white_list=white_list, black_list=black_list)

pattern = input_api.re.compile(r'//.*(?<!:\/\/)crbug[.com]*')
accepted_pattern = input_api.re.compile(r'//.*TODO\(crbug[.com]*');
problems = []
for f in input_api.AffectedSourceFiles(sources):
for line_num, line in f.ChangedContents():
if pattern.search(line):
if pattern.search(line) and not accepted_pattern.search(line):
problems.append(' %s:%d %s' % (f.LocalPath(), line_num, line))

if problems:
Expand Down
4 changes: 3 additions & 1 deletion PRESUBMIT_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,11 +1298,13 @@ def testCheckCrbugLinksHaveHttps(self):
'// TODO(developer): (crbug.com) should be linkified',
'// TODO(developer): crbug/123 should be well formed',
'// TODO(developer): http://crbug.com it\'s OK',
'// TODO(developer): https://crbug.com is just great']),
'// TODO(developer): https://crbug.com is just great',
'// TODO(crbug.com/123456): this pattern it\'s also OK']),
]

warnings = PRESUBMIT._CheckCrbugLinksHaveHttps(input_api, MockOutputApi())
self.assertEqual(1, len(warnings))
self.assertEqual(3, warnings[0].message.count('\n'));


if __name__ == '__main__':
Expand Down

0 comments on commit 68bdb65

Please sign in to comment.