From 5ff7ad23ae082a11140e9c62fe1cb0252cf3a92c Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Fri, 19 Jun 2020 19:39:15 +0000 Subject: [PATCH] Remove lint checks for non-const references. These are now allowed by the Google style guide. Bug: none Change-Id: Ib182011ce489ee218cf673842be633626507cd60 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2248714 Commit-Queue: Edward Lesmes Reviewed-by: Edward Lesmes Auto-Submit: Peter Kasting --- presubmit_canned_checks.py | 43 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index a092f8a12..47753d12e 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -9,34 +9,39 @@ from __future__ import print_function import os as _os _HERE = _os.path.dirname(_os.path.abspath(__file__)) +# These filters will be disabled if callers do not explicitly supply a +# (possibly-empty) list. Ideally over time this list could be driven to zero. +# TODO(pkasting): If some of these look like "should never enable", move them +# to OFF_UNLESS_MANUALLY_ENABLED_LINT_FILTERS. +# # Justifications for each filter: # -# - build/include : Too many; fix in the future. -# - build/include_order : Not happening; #ifdefed includes. -# - build/namespace : I'm surprised by how often we violate this rule. -# - readability/casting : Mistakes a whole bunch of function pointer. +# - build/include : Too many; fix in the future +# TODO(pkasting): Try enabling subcategories +# - build/include_order : Not happening; #ifdefed includes +# - build/namespaces : TODO(pkasting): Try re-enabling +# - readability/casting : Mistakes a whole bunch of function pointers # - runtime/int : Can be fixed long term; volume of errors too high -# - runtime/virtual : Broken now, but can be fixed in the future? -# - whitespace/braces : We have a lot of explicit scoping in chrome code. -DEFAULT_LINT_FILTERS = [ +# - whitespace/braces : We have a lot of explicit scoping in chrome code +OFF_BY_DEFAULT_LINT_FILTERS = [ '-build/include', '-build/include_order', - '-build/namespace', + '-build/namespaces', '-readability/casting', '-runtime/int', - '-runtime/virtual', '-whitespace/braces', ] -# These filters will always be removed, even if the caller specifies a filter -# set, as they are problematic or broken in some way. +# These filters will be disabled unless callers explicitly enable them, because +# they are undesirable in some way. # # Justifications for each filter: -# - build/c++11 : Rvalue ref checks are unreliable (false positives), -# include file and feature blacklists are -# google3-specific. -BLACKLIST_LINT_FILTERS = [ +# - build/c++11 : Include file and feature blacklists are +# google3-specific +# - runtime/references : No longer banned by Google style guide +OFF_UNLESS_MANUALLY_ENABLED_LINT_FILTERS = [ '-build/c++11', + '-runtime/references', ] ### Description checks @@ -165,9 +170,11 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None, # pylint: disable=protected-access cpplint._cpplint_state.ResetErrorCounts() - lint_filters = lint_filters or DEFAULT_LINT_FILTERS - lint_filters.extend(BLACKLIST_LINT_FILTERS) - cpplint._SetFilters(','.join(lint_filters)) + filters = OFF_UNLESS_MANUALLY_ENABLED_LINT_FILTERS[:] + if lint_filters is None: + lint_filters = OFF_BY_DEFAULT_LINT_FILTERS + filters.extend(lint_filters) + cpplint._SetFilters(','.join(filters)) # We currently are more strict with normal code than unit tests; 4 and 5 are # the verbosity level that would normally be passed to cpplint.py through