diff --git a/git_cl.py b/git_cl.py index 17e165fea..2166ea898 100755 --- a/git_cl.py +++ b/git_cl.py @@ -44,6 +44,7 @@ import metrics import metrics_utils import owners import owners_finder +import presubmit_canned_checks import presubmit_support import scm import setup_color @@ -3780,10 +3781,9 @@ def CMDlint(parser, args): print('Cannot lint an empty CL') return 1 - # Process cpplints arguments if any. - command = args + files - if options.filter: - command = ['--filter=' + ','.join(options.filter)] + command + # Process cpplint arguments, if any. + filters = presubmit_canned_checks.GetCppLintFilters(options.filter) + command = ['--filter=' + ','.join(filters)] + args + files filenames = cpplint.ParseArguments(command) include_regex = re.compile(settings.GetLintRegex()) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index ff49088bb..2e582014d 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -159,6 +159,14 @@ def CheckDoNotSubmitInFiles(input_api, output_api): return [] +def GetCppLintFilters(lint_filters=None): + filters = OFF_UNLESS_MANUALLY_ENABLED_LINT_FILTERS[:] + if lint_filters is None: + lint_filters = OFF_BY_DEFAULT_LINT_FILTERS + filters.extend(lint_filters) + return filters + + def CheckChangeLintsClean(input_api, output_api, source_file_filter=None, lint_filters=None, verbose_level=None): """Checks that all '.cc' and '.h' files pass cpplint.py.""" @@ -170,11 +178,7 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None, # pylint: disable=protected-access cpplint._cpplint_state.ResetErrorCounts() - 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)) + cpplint._SetFilters(','.join(GetCppLintFilters(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