MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / ProcessFile

Function ProcessFile

steps/cpplint.py:6603–6693  ·  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

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

Callers 1

mainFunction · 0.85

Calls 10

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

Tested by

no test coverage detected