Tag cpplint errors

A typical cpplint error report during a presubmit looks like this:

    .../linux_ui.cc:64:  Almost always, snprintf is better than strcpy  [runtime/printf] [4]
    ...
    Changelist failed cpplint.py check.

The problem is that the details of the error go to stderr when
CheckChangeLintsClean is run, whereas the "Changelist failed cpplint.py
check." message is printed at the end of the run. If there a lot of
errors, warnings, or messages then the association between them can be
completely lost.

This change adds the tag (cpplint) to the error messages, and adds a
comment to the "failed cpplint.py check" message to suggest looking for
the tag.

Bug: 1309977
Change-Id: I0d073b57f215e28495cbc3e009cab6ac2f23b65e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3632947
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
changes/47/3632947/4
Bruce Dawson 3 years ago committed by LUCI CQ
parent 68df7954e3
commit ac96470e3e

12
cpplint.py vendored

@ -1192,14 +1192,14 @@ def Error(filename, linenum, category, confidence, message):
if _ShouldPrintError(category, confidence, linenum):
_cpplint_state.IncrementErrorCount(category)
if _cpplint_state.output_format == 'vs7':
sys.stderr.write('%s(%s): %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
sys.stderr.write('%s(%s): (cpplint) %s [%s] [%d]\n' %
(filename, linenum, message, category, confidence))
elif _cpplint_state.output_format == 'eclipse':
sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
sys.stderr.write('%s:%s: (cpplint) warning: %s [%s] [%d]\n' %
(filename, linenum, message, category, confidence))
else:
sys.stderr.write('%s:%s: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
sys.stderr.write('%s:%s: (cpplint) %s [%s] [%d]\n' %
(filename, linenum, message, category, confidence))
# Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard.

@ -267,7 +267,10 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None,
res_type = output_api.PresubmitError
else:
res_type = output_api.PresubmitPromptWarning
result = [res_type('Changelist failed cpplint.py check.')]
result = [
res_type('Changelist failed cpplint.py check. '
'Search the output for "(cpplint)"')
]
return result

Loading…
Cancel
Save