MCPcopy Create free account
hub / github.com/alibaba/GraphScope / ProcessFile

Function ProcessFile

analytical_engine/misc/cpplint.py:6594–6684  ·  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

6592
6593
6594def ProcessFile(filename, vlevel, extra_check_functions=None):
6595 """Does google-lint on a single file.
6596
6597 Args:
6598 filename: The name of the file to parse.
6599
6600 vlevel: The level of errors to report. Every error of confidence
6601 >= verbose_level will be reported. 0 is a good default.
6602
6603 extra_check_functions: An array of additional check functions that will be
6604 run on each source line. Each function takes 4
6605 arguments: filename, clean_lines, line, error
6606 """
6607
6608 _SetVerboseLevel(vlevel)
6609 _BackupFilters()
6610 old_errors = _cpplint_state.error_count
6611
6612 if not ProcessConfigOverrides(filename):
6613 _RestoreFilters()
6614 return
6615
6616 lf_lines = []
6617 crlf_lines = []
6618 try:
6619 # Support the UNIX convention of using "-" for stdin. Note that
6620 # we are not opening the file with universal newline support
6621 # (which codecs doesn't support anyway), so the resulting lines do
6622 # contain trailing '\r' characters if we are reading a file that
6623 # has CRLF endings.
6624 # If after the split a trailing '\r' is present, it is removed
6625 # below.
6626 if filename == '-':
6627 lines = codecs.StreamReaderWriter(sys.stdin,
6628 codecs.getreader('utf8'),
6629 codecs.getwriter('utf8'),
6630 'replace').read().split('\n')
6631 else:
6632 with codecs.open(filename, 'r', 'utf8', 'replace') as target_file:
6633 lines = target_file.read().split('\n')
6634
6635 # Remove trailing '\r'.
6636 # The -1 accounts for the extra trailing blank line we get from split()
6637 for linenum in range(len(lines) - 1):
6638 if lines[linenum].endswith('\r'):
6639 lines[linenum] = lines[linenum].rstrip('\r')
6640 crlf_lines.append(linenum + 1)
6641 else:
6642 lf_lines.append(linenum + 1)
6643
6644 except IOError:
6645 _cpplint_state.PrintError(
6646 "Skipping input '%s': Can't open for reading\n" % filename)
6647 _RestoreFilters()
6648 return
6649
6650 # Note, if no dot is found, this will give the entire filename as the ext.
6651 file_extension = filename[filename.rfind('.') + 1:]

Callers 1

mainFunction · 0.85

Calls 14

_SetVerboseLevelFunction · 0.85
_BackupFiltersFunction · 0.85
ProcessConfigOverridesFunction · 0.85
_RestoreFiltersFunction · 0.85
GetAllExtensionsFunction · 0.85
ProcessFileDataFunction · 0.85
splitMethod · 0.80
PrintErrorMethod · 0.80
PrintInfoMethod · 0.80
ErrorFunction · 0.70
readMethod · 0.65
appendMethod · 0.65

Tested by

no test coverage detected