From ac96470e3e50b92e177391a576f1e881836d73e3 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Fri, 27 May 2022 17:08:46 +0000 Subject: [PATCH] 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 Reviewed-by: Aravind Vasudevan --- cpplint.py | 12 ++++++------ presubmit_canned_checks.py | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cpplint.py b/cpplint.py index 6cb84adf3..330b926d0 100755 --- a/cpplint.py +++ b/cpplint.py @@ -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. diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 39675fbda..d3b8d4182 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -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