Skip to content

Commit

Permalink
PRESUBMIT: only check against diffed lines when searching for LOG(INFO)
Browse files Browse the repository at this point in the history
R=jochen@chromium.org
CC=enne@chromium.org,alokp@chromium.org

Review-Url: https://codereview.chromium.org/2772403003
Cr-Commit-Position: refs/heads/master@{#460313}
  • Loading branch information
tanderson-google authored and Commit bot committed Mar 29, 2017
1 parent 8a34493 commit 625d393
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,20 +1205,20 @@ def _CheckSpamLogging(input_api, output_api):
source_file_filter = lambda x: input_api.FilterSourceFile(
x, white_list=(file_inclusion_pattern,), black_list=black_list)

log_info = []
printf = []
log_info = set([])
printf = set([])

for f in input_api.AffectedSourceFiles(source_file_filter):
contents = input_api.ReadFile(f, 'rb')
if input_api.re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents):
log_info.append(f.LocalPath())
elif input_api.re.search(r"\bD?LOG_IF\s*\(\s*INFO\s*,", contents):
log_info.append(f.LocalPath())

if input_api.re.search(r"\bprintf\(", contents):
printf.append(f.LocalPath())
elif input_api.re.search(r"\bfprintf\((stdout|stderr)", contents):
printf.append(f.LocalPath())
for _, line in f.ChangedContents():
if input_api.re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", line):
log_info.add(f.LocalPath())
elif input_api.re.search(r"\bD?LOG_IF\s*\(\s*INFO\s*,", line):
log_info.add(f.LocalPath())

if input_api.re.search(r"\bprintf\(", line):
printf.add(f.LocalPath())
elif input_api.re.search(r"\bfprintf\((stdout|stderr)", line):
printf.add(f.LocalPath())

if log_info:
return [output_api.PresubmitError(
Expand Down

0 comments on commit 625d393

Please sign in to comment.