From b6795643ec0305ba2ff862fcd0f450756aa5e58c Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Fri, 12 Dec 2014 00:03:49 +0000 Subject: [PATCH] Add lint_filters parameter to CheckChangeLintsClean function. The idea here is that when one of the filters are cleaned up in Chromium, they should not be filtered out, otherwise we won't catch them in the presubmit step. See for example -> https://codereview.chromium.org/788493002/ BUG=None R=agable@chromium.org, dpranke@chromium.org Review URL: https://codereview.chromium.org/779033003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@293357 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 40 +++++++++++++++++++++++-------------- tests/presubmit_unittest.py | 1 + 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index a93a4fddd..34b7df451 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -7,6 +7,27 @@ import os as _os _HERE = _os.path.dirname(_os.path.abspath(__file__)) +# 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. +# - 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. +# - readability/inheritance : Temporary, while the OVERRIDE and FINAL fixup +# is in progress. +DEFAULT_LINT_FILTERS = [ + '-build/include', + '-build/include_order', + '-build/namespace', + '-readability/casting', + '-runtime/int', + '-runtime/virtual', + '-whitespace/braces', + '-readability/inheritance' +] ### Description checks @@ -90,7 +111,8 @@ def CheckDoNotSubmitInFiles(input_api, output_api): return [] -def CheckChangeLintsClean(input_api, output_api, source_file_filter=None): +def CheckChangeLintsClean(input_api, output_api, source_file_filter=None, + lint_filters=None): """Checks that all '.cc' and '.h' files pass cpplint.py.""" _RE_IS_TEST = input_api.re.compile(r'.*tests?.(cc|h)$') result = [] @@ -100,20 +122,8 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None): # pylint: disable=W0212 cpplint._cpplint_state.ResetErrorCounts() - # 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. - # - 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. - # - readability/inheritance : Temporary, while the OVERRIDE and FINAL fixup - # is in progress. - cpplint._SetFilters('-build/include,-build/include_order,-build/namespace,' - '-readability/casting,-runtime/int,-runtime/virtual,' - '-whitespace/braces,-readability/inheritance') + lint_filters = lint_filters or DEFAULT_LINT_FILTERS + cpplint._SetFilters(','.join(lint_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 diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 593708068..fdd801e2b 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -1861,6 +1861,7 @@ class CannedChecksUnittest(PresubmitTestsBase): def testMembersChanged(self): self.mox.ReplayAll() members = [ + 'DEFAULT_LINT_FILTERS', 'CheckBuildbotPendingBuilds', 'CheckChangeHasBugField', 'CheckChangeHasDescription', 'CheckChangeHasNoStrayWhitespace',