Restore the accidentally deleted extra_check_functions in cpplint.py

This extra parameter was used when calling cpplint.ProcessFile
directly from depot_tools/gcl.py and depot_tools/git_cl.py.

Restoring it...

R=erg@google.com

Review URL: https://codereview.appspot.com/105820044
This commit is contained in:
avakulenko@google.com 2014-06-04 22:48:14 +00:00
parent 02af6281c6
commit 4b957b2edd

31
cpplint/cpplint.py vendored
View File

@ -5289,7 +5289,8 @@ def CheckDefaultLambdaCaptures(filename, clean_lines, linenum, error):
def ProcessLine(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error):
include_state, function_state, nesting_state, error,
extra_check_functions=[]):
"""Processes a single line in the file.
Args:
@ -5304,7 +5305,9 @@ def ProcessLine(filename, file_extension, clean_lines, line,
the current stack of nested blocks being parsed.
error: A callable to which errors are reported, which takes 4 arguments:
filename, line number, error level, and message
extra_check_functions: An array of additional check functions that will be
run on each source line. Each function takes 4
arguments: filename, clean_lines, line, error
"""
raw_lines = clean_lines.raw_lines
ParseNolintSuppressions(filename, raw_lines[line], line, error)
@ -5323,8 +5326,9 @@ def ProcessLine(filename, file_extension, clean_lines, line,
CheckInvalidIncrement(filename, clean_lines, line, error)
CheckMakePairUsesDeduction(filename, clean_lines, line, error)
CheckDefaultLambdaCaptures(filename, clean_lines, line, error)
for check_fn in extra_check_functions:
check_fn(filename, clean_lines, line, error)
def FlagCxx11Features(filename, clean_lines, linenum, error):
"""Flag those c++11 features that we only allow in certain places.
@ -5374,7 +5378,8 @@ def FlagCxx11Features(filename, clean_lines, linenum, error):
'they may let you use it.') % top_name)
def ProcessFileData(filename, file_extension, lines, error):
def ProcessFileData(filename, file_extension, lines, error,
extra_check_functions=[]):
"""Performs lint checks and reports any errors to the given error function.
Args:
@ -5383,6 +5388,10 @@ def ProcessFileData(filename, file_extension, lines, error):
lines: An array of strings, each representing a line of the file, with the
last element being empty if the file is terminated with a newline.
error: A callable to which errors are reported, which takes 4 arguments:
filename, line number, error level, and message
extra_check_functions: An array of additional check functions that will be
run on each source line. Each function takes 4
arguments: filename, clean_lines, line, error
"""
lines = (['// marker so line numbers and indices both start at 1'] + lines +
['// marker so line numbers end in a known way'])
@ -5402,7 +5411,8 @@ def ProcessFileData(filename, file_extension, lines, error):
clean_lines = CleansedLines(lines)
for line in xrange(clean_lines.NumLines()):
ProcessLine(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error)
include_state, function_state, nesting_state, error,
extra_check_functions)
FlagCxx11Features(filename, clean_lines, line, error)
nesting_state.CheckCompletedBlocks(filename, error)
@ -5415,7 +5425,7 @@ def ProcessFileData(filename, file_extension, lines, error):
CheckForNewlineAtEOF(filename, lines, error)
def ProcessFile(filename, vlevel):
def ProcessFile(filename, vlevel, extra_check_functions=[]):
"""Does google-lint on a single file.
Args:
@ -5423,6 +5433,10 @@ def ProcessFile(filename, vlevel):
vlevel: The level of errors to report. Every error of confidence
>= verbose_level will be reported. 0 is a good default.
extra_check_functions: An array of additional check functions that will be
run on each source line. Each function takes 4
arguments: filename, clean_lines, line, error
"""
_SetVerboseLevel(vlevel)
@ -5468,7 +5482,8 @@ def ProcessFile(filename, vlevel):
sys.stderr.write('Ignoring %s; not a valid file name '
'(%s)\n' % (filename, ', '.join(_valid_extensions)))
else:
ProcessFileData(filename, file_extension, lines, Error)
ProcessFileData(filename, file_extension, lines, Error,
extra_check_functions)
# If end-of-line sequences are a mix of LF and CR-LF, issue
# warnings on the lines with CR.