Simplify a block of conditionals for git cl lint.

Use continues to reduce the amount of nesting in a loop. At the same
time, give the variable involved better names.

Bug: 1097674
Change-Id: I105ed4a99da783fb235e304bbad4edd1f8a38889
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2298659
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
changes/59/2298659/2
Lei Zhang 5 years ago committed by LUCI CQ
parent 6d938a0d85
commit 379d1ad115

@ -3786,18 +3786,20 @@ def CMDlint(parser, args):
command = ['--filter=' + ','.join(options.filter)] + command
filenames = cpplint.ParseArguments(command)
white_regex = re.compile(settings.GetLintRegex())
black_regex = re.compile(settings.GetLintIgnoreRegex())
include_regex = re.compile(settings.GetLintRegex())
ignore_regex = re.compile(settings.GetLintIgnoreRegex())
extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace]
for filename in filenames:
if white_regex.match(filename):
if black_regex.match(filename):
print('Ignoring file %s' % filename)
else:
cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level,
extra_check_functions)
else:
if not include_regex.match(filename):
print('Skipping file %s' % filename)
continue
if ignore_regex.match(filename):
print('Ignoring file %s' % filename)
continue
cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level,
extra_check_functions)
finally:
os.chdir(previous_cwd)
print('Total errors found: %d\n' % cpplint._cpplint_state.error_count)

Loading…
Cancel
Save