MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / ProcessFile

Function ProcessFile

src/tests/coding/cpplint.py:6591–6681  ·  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

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

Callers 1

mainFunction · 0.85

Calls 13

_SetVerboseLevelFunction · 0.85
_BackupFiltersFunction · 0.85
ProcessConfigOverridesFunction · 0.85
_RestoreFiltersFunction · 0.85
GetAllExtensionsFunction · 0.85
ProcessFileDataFunction · 0.85
ErrorFunction · 0.85
PrintErrorMethod · 0.80
PrintInfoMethod · 0.80
splitMethod · 0.45
readMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected