MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ProcessFile

Function ProcessFile

Tools/cpplint.py:5952–6037  ·  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=[])

Source from the content-addressed store, hash-verified

5950
5951
5952def ProcessFile(filename, vlevel, extra_check_functions=[]):
5953 """Does google-lint on a single file.
5954
5955 Args:
5956 filename: The name of the file to parse.
5957
5958 vlevel: The level of errors to report. Every error of confidence
5959 >= verbose_level will be reported. 0 is a good default.
5960
5961 extra_check_functions: An array of additional check functions that will be
5962 run on each source line. Each function takes 4
5963 arguments: filename, clean_lines, line, error
5964 """
5965
5966 _SetVerboseLevel(vlevel)
5967 _BackupFilters()
5968
5969 if not ProcessConfigOverrides(filename):
5970 _RestoreFilters()
5971 return
5972
5973 lf_lines = []
5974 crlf_lines = []
5975 try:
5976 # Support the UNIX convention of using "-" for stdin. Note that
5977 # we are not opening the file with universal newline support
5978 # (which codecs doesn't support anyway), so the resulting lines do
5979 # contain trailing '\r' characters if we are reading a file that
5980 # has CRLF endings.
5981 # If after the split a trailing '\r' is present, it is removed
5982 # below.
5983 if filename == '-':
5984 lines = codecs.StreamReaderWriter(sys.stdin,
5985 codecs.getreader('utf8'),
5986 codecs.getwriter('utf8'),
5987 'replace').read().split('\n')
5988 else:
5989 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
5990
5991 # Remove trailing '\r'.
5992 # The -1 accounts for the extra trailing blank line we get from split()
5993 for linenum in range(len(lines) - 1):
5994 if lines[linenum].endswith('\r'):
5995 lines[linenum] = lines[linenum].rstrip('\r')
5996 crlf_lines.append(linenum + 1)
5997 else:
5998 lf_lines.append(linenum + 1)
5999
6000 except IOError:
6001 sys.stderr.write(
6002 "Skipping input '%s': Can't open for reading\n" % filename)
6003 _RestoreFilters()
6004 return
6005
6006 # Note, if no dot is found, this will give the entire filename as the ext.
6007 file_extension = filename[filename.rfind('.') + 1:]
6008
6009 # When reading from stdin, the extension is unknown, so no cpplint tests

Callers 1

mainFunction · 0.85

Calls 13

_SetVerboseLevelFunction · 0.85
_BackupFiltersFunction · 0.85
ProcessConfigOverridesFunction · 0.85
_RestoreFiltersFunction · 0.85
rangeFunction · 0.85
ProcessFileDataFunction · 0.85
ErrorFunction · 0.70
splitMethod · 0.45
readMethod · 0.45
openMethod · 0.45
appendMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected