MCPcopy Create free account
hub / github.com/alibaba/graph-learn / ProcessFile

Function ProcessFile

dynamic_graph_service/ci/cpplint.py:6304–6393  ·  view source on GitHub ↗

Does google-lint on a single file. Args: filename: The name of the file to parse. 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

(filename, vlevel, extra_check_functions=None)

Source from the content-addressed store, hash-verified

6302
6303
6304def ProcessFile(filename, vlevel, extra_check_functions=None):
6305 """Does google-lint on a single file.
6306
6307 Args:
6308 filename: The name of the file to parse.
6309
6310 vlevel: The level of errors to report. Every error of confidence
6311 >= verbose_level will be reported. 0 is a good default.
6312
6313 extra_check_functions: An array of additional check functions that will be
6314 run on each source line. Each function takes 4
6315 arguments: filename, clean_lines, line, error
6316 """
6317
6318 _SetVerboseLevel(vlevel)
6319 _BackupFilters()
6320 old_errors = _cpplint_state.error_count
6321
6322 if not ProcessConfigOverrides(filename):
6323 _RestoreFilters()
6324 return
6325
6326 lf_lines = []
6327 crlf_lines = []
6328 try:
6329 # Support the UNIX convention of using "-" for stdin. Note that
6330 # we are not opening the file with universal newline support
6331 # (which codecs doesn't support anyway), so the resulting lines do
6332 # contain trailing '\r' characters if we are reading a file that
6333 # has CRLF endings.
6334 # If after the split a trailing '\r' is present, it is removed
6335 # below.
6336 if filename == '-':
6337 lines = codecs.StreamReaderWriter(sys.stdin,
6338 codecs.getreader('utf8'),
6339 codecs.getwriter('utf8'),
6340 'replace').read().split('\n')
6341 else:
6342 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
6343
6344 # Remove trailing '\r'.
6345 # The -1 accounts for the extra trailing blank line we get from split()
6346 for linenum in range(len(lines) - 1):
6347 if lines[linenum].endswith('\r'):
6348 lines[linenum] = lines[linenum].rstrip('\r')
6349 crlf_lines.append(linenum + 1)
6350 else:
6351 lf_lines.append(linenum + 1)
6352
6353 except IOError:
6354 _cpplint_state.PrintError(
6355 "Skipping input '%s': Can't open for reading\n" % filename)
6356 _RestoreFilters()
6357 return
6358
6359 # Note, if no dot is found, this will give the entire filename as the ext.
6360 file_extension = filename[filename.rfind('.') + 1:]
6361

Callers 1

mainFunction · 0.85

Calls 12

_SetVerboseLevelFunction · 0.85
_BackupFiltersFunction · 0.85
ProcessConfigOverridesFunction · 0.85
_RestoreFiltersFunction · 0.85
GetAllExtensionsFunction · 0.85
ProcessFileDataFunction · 0.85
ErrorFunction · 0.85
PrintErrorMethod · 0.80
rfindMethod · 0.80
joinMethod · 0.80
PrintInfoMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected